One Sender Two Receivers

Now let’s start a second receiver and see how it impacts how messages are received.

Select the bottom right terminal and start a second receiver. You now have 2 clients listening on the same queue:

java -jar ./bin/amazon-mq-client.jar -url $url -mode receiver -type queue -destination workshop.queueA

Notice that each message only goes to one receiver, not both. This demonstrates how receivers can be scaled to handle additional load in a queue. You can add more receivers based on queue depth, to receive messages faster.

To see how this works even more clearly, stop the sender by typing CTRL + C in the top left window.

Let the receivers clear out the messages in the queue, and then start the sender again, by re-running the sender command from above. Now you will clearly see each message received by a different receiver. When a message is received and acknowledged by one receiver, it is no longer on the queue, and the next receiver to connect gets the next message on the queue.