Can consumers act as producers and send messages to the message broker in RabbitMQ? - rabbitmq

Can we design pub-sub patterns in RabbitMQ where a consumer can also act as a producer and send messages to the message broker?
pub-sub with the same service

Did you try to use producer API in consumer code? It should work...
You can find API docs for many languages in Client Documentation
Regarding design, consumers may consume, do some processing and then produce - publish to some other exchange of the same or other messaging broker instance...
It's design decision...

Yes, the consumer can also act as a producer. It's a common use case that the consumer sends back a new message/task about something else once the first message has been processed.
Make sure that you separate the connections for the publisher and the consumer.
RabbitMQ can apply back pressure on the TCP connection when the publisher is sending too many messages for the server to handle. If you consume on the same TCP connection, the server might not receive the message acknowledgments from the client, thus effecting the consume performance. With a lower consume speed, the server will be overwhelmed.

Related

ActiveMQ persistent store is full and consumer is blocked

I'm doing a test to see how the flow control behaves. I created a fast producer and slow consumers and set my destination queue policy highwater mark to 60 percent..
the queue did reach 60% so messages now went to the store, now the store is full and blocking as expected..
But now i cannot get my consumer to connect and pull from the queue.. Seem that blocking is also blocking the consumer from getting in to start pulling from the queue..
Is this the correct behavior?
The consumer should not be blocked by flow-control. Otherwise messages could not be consumed to free up space on the broker for producers to send additional messages.
So this issues surfaced when I was using a on demand jms service. The service will queue or dequeue via a REST services. The consumers are created on demand.. If the broker is being blocked as im my case being out of resource, then you cannot create a new consumer.
I've since modified the jms service to use a consumer pool(implemented a object pool pattern). The consumer pool is initialized when the application starts and this resolved the blocking issue

How to push messages to AMQP consumer Artemis

Is it possible for Artemis to push messages to a REST API/consumer, rather the consumer pulling from it. I can implement a Listener on the consumer side, but I am trying to see if Artemis can push messages to consumers.
Any help is much appreciated.
Don't think it's possible, the JMS provider is a server and always waits for consumer connections. Then, it pushes messages to consumer's buffer as soon as it is ready and there are available messages. Anyway, depending on your application's technology, you may want to leverage the Artemis REST interface to implement your consumer.

RabbitMQ RPC multiple senders one receiver

Hi i'm really new to RabbitMQ. I want implement the RPC pattern but with multiple clients and one server. Can anyone recommend a responsive way of implementing this. I'm a bit concerned the code I have implementing one client and one server will introduce blocking issues, ideally I'd like the client to get a response fairly quickly.
First just to get terminology straight:
in RMQ context, RMQ is a broker (server) whose clients are producers and consumers.
in RPC context (and in example on the tutorial) we have a RPC client(s) and a RPC server(s). So when we "map"this to RMQ context, we say that RPC client is actually both RMQ producer and RMQ consumer (because it sends the request and receives a reply) and that RPC server is both RMQ consumer and RMQ producer (because it waits for requests and then sends a reply)
Now, if you implement it the same way that's done in the tutorial (aforementioned link), you won't have any problems. You should simply start more RPC servers, so that more requests may be handled in parallel.

What is good practice to strore application config at RabbitMQ queue?

There is a set of same listeners that listens TCP ports and publishes received data to RabbitMQ queue. I need to have ability to configure listeners from backend at other side of the queue. There is no other connection to listeners except RMQ. What is the good practice to store application config within queue? Must it be a separate queue and exchange? Which parameters queue should have, where to read more? Thanks for any advising.
RabbitMQ doesn't store data. After message is consumed, it will be deleted. If you want to use rmq to send NOTIFICATION to consumers, that is doable. For configuration, my suggestion is zookeeper which also support listener on change.

RabbitMQ & MQTT : how to alert a third party of non consumed messages?

I am using RabbitMQ with the MQTT plugin, with both producer and consumer on QoS=1.
I am still very new to RabbitMQ so I would like to understand if there is a way/efficient pattern to ensure a fallback in case a consumer is not consuming the messages of the topic he has subscribed to.
For instance, the idea being to be able to send an alert to a server trigger another channel (email, push notification) after a few seconds if a client is not consuming the messages of the MQTT topic?
Thank you for your help!
You can set per-message or per-queue TTL and then catch expired messages with the help of Dead Letter Exchanges extension. That will act as a notification of stalled or slow consumer or no consumers at all.