Is it possible to have multiple listeners listening to the same queue using spring amqp - spring-amqp

We have 2 different applications which interact with each by sending messages. Is it possible to have multiple listeners listening to the same queue. May be we could pass some header while pushing the message to the queue and then on the basis of header, the message would arrive in a single consumer.

No; RabbitMQ doesn't work that way; unlike JMS, there is no notion of a message selector.
Each consumer needs its own queue and you use a routing key to tell the broker which queue to route the message to.

Related

REST - Route messages to different HTTP Consumers

Goal - to configure Solace Message-Broker to route messages to different HTTP consumer based on either http-headers or request-target's path.
I'm new to Solace... and I think it would be possible if I configure a separate message-vpn and assign different ports for REST. But ability to dynamically route based on payload might have some merit.
Messages in Solace are routed based on the topic or queues. With Solace's REST messaging feature, the topic or queue that the producer is publishing to is determined by the HTTP request-target.
e.g.
To send to topic "A", use http://[solaceIP:restPort]/TOPIC/A
To send to queue "B", use http://[solaceIP:restPort]/QUEUE/Q/B
Solace REST messaging makes use of standard HTTP headers and introduces some custom headers specifically related to the Solace REST implementation. These headers do not determine where the message is routed but can determine other behavior related to the messaging. e.g. Setting the "Solace-DMQ-Eligible" header to true will allow for the message to be eligible to expire to the Dead Message Queue.
All headers are explained here: https://docs.solace.com/RESTMessagingPrtl/Solace-REST-Message-Encoding.htm#_Ref393979969
On the receiving end, a REST Delivery Point can be bound to one or more queues. Any messages delivered to these queues will be sent to the configured REST consumer.

Acknowledgement from RabbitMQ

After publishing message on RabbitMQ like that :
[exchange publishMessage:#"YOUR MESSAGE" usingRoutingKey:routingQueue propertiesMessage:props mandatory:NO immediate:NO error:&error];
It works perfectly but is it possible to receive the acknowledgement from RabbitMQ for each message with this lib ?
https://github.com/profmaad/librabbitmq-objc
So these publisher acknowledgments (since you wrote in the comment you are interested in broker->publisher) are on the amqp level, handled by RMQ itself. In the "API" level you may get a exception or a return value or some indication depends on the library.
Quote from the aforementioned link:
For unroutable messages, the broker will issue a confirm once the
exchange verifies a message won't route to any queue (returns an empty
list of queues). If the message is also published as mandatory, the
basic.return is sent to the client before basic.ack. The same is true
for negative acknowledgements (basic.nack).
For routable messages, the basic.ack is sent when a message has been
accepted by all the queues. For persistent messages routed to durable
queues, this means persisting to disk. For mirrored queues, this means
that all mirrors have accepted the message.

Is it possible to route message based on header to particular Queue in Solace Message Router

Is it possible to route message based on header to particular Queue in Solace Message Router ?
Please give brief details.
Solace Message Router routes messages via topics.
You can publish a message to either:
A topic (e.g. customer/uk/event/logon)
Directly into a queue (e.g. uk_Queue)
Queues on the Solace Message Router can be configured to receive one or more topics. For example, the uk_Queue can be configured to spool messages that were published to both customer/uk/event/logon and customer/uk/event/logoff.
You can add an egress selector to consumers that are bound to a queue. With the egress selector, only messages with headers that matches the selector string will be delivered to the consumers. Note that this only applies to delivery of messages to the consumers only. Messages that match the configured topics on the queue will be spooled regardless of whether or not the consumer's selectors match the messages.
Alternatively, you can create a topic endpoint, which allows ingress selectors. Topic endpoints will receive messages that match both the configurable topic and the header fields that matches the configured ingress selector.
You might also be interested in looking at
http://dev.solacesystems.com/get-started/java-tutorials/topic-queue-mapping_java/
which gives a brief introduction about topic to queue mappings.

SQS - Get Message By Id

Is it possible for me to get a message from the SQS queue based on the message ID with the Amazon PHP SDK? Do I have to just grab all of the messages on the queue and then filter it on my server?
My server receives a SNS instigated request with a queue message Id and I'm having to filter the message from an array of messages from SQS.
The purpose of a queue is to use it as a buffer to store messages before a certain processing task. This should not be confused with a storage service or a database service. Amazon SQS allows a process to retrieve messages from a queue (buffer) and process them as needed. If needed Standard or FIFO queues can be used.
In answer to your question: SQS does not provide a mechanism to retrieve by Message ID. So as you suggested, you can have separate workers to retrieve all messages in parallel and look for the message with the ID you want. (This can be exhaustive)
Since your use case is similar to that of a storage service, I suggest writing to a storage service and retrieving from it based on a column named "Message ID".
Just so that it may help someone else. I couldn't find a straight forward method to do this. Instead, implementing another set of queue workers to delegate the tasks solved the performance issue. These workers performed only two tasks
Retrieve queue item
Associative valid id
Send it to the processing server (after performing load checks, availability etc)
I would have to know more about your use case to know, but it sounds like you are using SQS as a database. Might I recommend instead of sending messages to SQS and sending the message ID to SNS, instead adding a row in DynamoDB, and sending to key through SNS?
Or even better yet, just send the raw data through SNS?

Message broadcasting using rabbitmq, genbunny and cowboy event notifier

I have two instances of cowboy server running which are connected to RabbitMQ. I am using gen_bunny as RabbitMQ client to connect to RabbitMQ.
I can consume the message to from rabbitMQ if using bunnyc:consume(). However for that I need to fire this method explicitly. What I want is to bind an event on cowboy so as soon as there is a message in the Queue it should automatically notify to cowboy.
Is it possible using gen_bunny or other erlang client?
Dont know about gen_bunny, but with official erlang client you can subscribing to queue (look at http://www.rabbitmq.com/erlang-client-user-guide.html, "Subscribing To Queues" section)
As far as i understand, you need send messages from queue through WebSockets to clients. So you need subscribe to queue in process that communicate with client. And recieve messages in "receive ... end" or in handle_info (depends on realization)
ADDITION
I looked in gen_bunny sources... mochi/gen_bunny depends on mochi/amqp_client which provide amqp_channel:subscribe/3 (see https://github.com/mochi/amqp_client/blob/master/src/amqp_channel.erl#L177) you can use it for subscribing
Got it worked ... After some tweaking in the bunnyc.erl source. Now, In init function i have added subscription function and in start_link function in bunnyc.erl passing the process id of my cowboy process so as soon as there is a message in the queue I can get it in websocket_info function of cowboy..

Resources