One Sender One Receiver

In this step we will start a sender (producer) sending messages to a queue. In this lab you will learn how queues work, storing messages until a consumer is available to process them.

Run the following command in the top left terminal to start the sender. The sender name is added to the message to identify who is sending the message:

java -jar ./bin/amazon-mq-client.jar -url $url -mode sender -type queue -destination workshop.queueA -name Sender-1

You should see a log output like the following:

[ActiveMQ Task-1] INFO org.apache.activemq.transport.failover.FailoverTransport - Successfully connected to ssl://b-4e4bfd69-7b83-4a27-9faf-4684cfa80443-1.mq.eu-central-1.amazonaws.com:61617
14.04.2018 11:33:03.609 - Sender: sent '[queue://workshop.queueA] [Sender-1] Message number 1'
14.04.2018 11:33:04.645 - Sender: sent '[queue://workshop.queueA] [Sender-1] Message number 2'
14.04.2018 11:33:05.680 - Sender: sent '[queue://workshop.queueA] [Sender-1] Message number 3'
...

Notice that the messages are already being sent to the queue, before the receiver is started.

Now, lets start a receiver (consumer). Select the bottom left terminal. Run the following command, to start the first receiver:

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

You should see a log output like the following:

[ActiveMQ Task-1] INFO org.apache.activemq.transport.failover.FailoverTransport - Successfully connected to ssl://b-4e4bfd69-7b83-4a27-9faf-4684cfa80443-1.mq.eu-central-1.amazonaws.com:61617
14.04.2018 11:47:41.616 - Receiver: received '[queue://workshop.queueA] [Sender-1] Message number 1'
14.04.2018 11:47:41.620 - Receiver: received '[queue://workshop.queueA] [Sender-1] Message number 2'
...
14.04.2018 11:47:41.622 - Receiver: received '[queue://workshop.queueA] [Sender-2] Message number 1'
14.04.2018 11:47:41.623 - Receiver: received '[queue://workshop.queueA] [Sender-2] Message number 2'
...

When you start the receiver, you will notice that the receiver is now getting every message that was sent to the queue. The queue held the messages until the receiver connected. Once the receiver is connected, the message are all delivered to the single receiver.