RabbitMQ is a well known messaging broker. It gives a common platform for sending and receiving messages. RabbitMQ has some good tutorials in five programming languages. This post wants to show a little example about a message receiver likes a bridge between two message queues. Actually it’s very simple, the receiver send messages from the first messaging queue, after the processing of messages it sends them the second messaging queue.
The skeleton of our example is:
Producer#1 -> Queue#1 -> Worker (in another perspective Producer#2) -> Queue#2 -> Receiver
Producer#1 -> Queue#1
The first part is establishment of the first messaging queue and producer code sends messages to our message receiver (let be “worker”). This part is almost same as official tutorial.
Queue#1 -> Worker (in another perspective Producer#2) -> Queue#2
The second part is heart of our example, this part receives messages from the first queue and send it to the second queue. The worker code has two different queue definitions.
The first queue definition.
The second queue definition.
Receiving from Queue#1 and sending to Queue#2
And the final part is an ordinary receiver. Official tutorials are very helpful and simple, so in my opinion RabbitMQ is a simple tool for sending and receiving messages. I use it on different a producer machine, five worker machines and a saver machine.