RabbitMQ– selectively retrieving messages from a queue

RabbitMQ is perfect for this situation. You have a number of options to do what you want. I suggest reading the documentation to get a better understanding. I would suggest that you use a topic or direct exchange. Topic is more flexible. It goes like this.

Producer code connects to the RabbitMQ Broker and creates and Exchange with a specific name.

Producer publishes to exchange. Each message published will be published with a routing key.

Consumer connects to RabbitMQ broker.

Consumer creates Queue

Consumer binds Queue to the exchange, the same exchange defined in the producer. The binding also includes the routing keys for each message require for this particular consumer.

Lets say you were publishing log messages. The routing key might be something like “log.info”, “log.warn”, “log.error”. Each message published by the producer will have the relevant routing key attached. You will then have a consumer that sends and email for all the error messages and another one that writes all the error messages to a file. So the emailer will define the binding from its queue to the exchange with the routing key “log.error”. This way though the exchange receives all messages, the queue defined for the emailer will only contain the error messages. The filelogger will define a new separate queue bound to the same exchange and set up a different routing key. You could do three separate bindings for the three different routing keys require or just use the wildcard “log.*” to request all messages from the exchange starting with log.

This is a simple example that shows how you can achieve what you want to do.

look here for code examples specifically number tutorial number 5.

Leave a Comment

casinojojobetpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casinocanlı bahis casino siteleriOnwin Güncel Girişcasinoholiganbet girişholiganbet güncel giriş