Anypoint MQ- On Anypoint Platform

Author: Kishori Patil

Content:

  • The Anypoint MQ provides publish-subscribe messaging to Mule apps using the Anypoint MQ cloud service.

Setup:

Login to your Anypoint account and select Anypoint MQ.

There are 3 options available:
1. Queue:

  • It’s created when there is no need to process the messages in the order in which they are stored in the MQ.

2. Exchange :

  • It’s created when there is a need to send one message to one or more applications.

3. FIFO Queue :

  • It’s created when there is a restriction to process the messages in the same order in which they are stored in the MQ.

To create a normal queue, select queue from 3 options. It will open below the window. You just have to enter the name for the queue. If you want, you can change the message TTL. By default it’s 7 days. It shows how long unprocessed messages will stay in the queue after TTL time that message will be deleted.

Create one more queue which will act as DLQ for the above MQ.

For assigning DLQ for ang queue, goto that main queue config (in this case click on mq-demo). Then enable the “Assign Dead Letter Queue” and select queue name which we want to add as DLQ for this Queue(selected mq-demo-DLQ). Using “delivery attempts before reroute” option you can also decide how many times you want to attempt the delivery of a message before sending it to DLQ (in this case, it’s one time, if message is failed then it’s sent to DLQ)
How this DLQ is used is added in the next part of the blog. Here we will just create the DLQ.

To create a FIFO Queue select fifo queue option and similar to the normal queue fifo queue is created. In this queue messages will be processed in the order they are stored in the queue.

Create one more normal queue mq-demo1 with the default configuration.

To send a message in that queue you can use the Message sender option. Add a message in the payload section. You can also select the type of payload from drop down which are text, CSV, JSON you can also delay the delivery of message by adding the required value in the Delivery delay section.

Once the message is sent it will be stored in the mq-demo queue. You can go to the message browser to see all messages stored in that queue. Click on get messages to see those messages.

To create an Exchange, click on exchange. It will open the following configuration for the new exchange.

  • Add a name to that exchange as ID.

If you go to the config of Exchange Mq-demo-exchange, you can see 2 options bind and unbind. Queues that are already bound to this exchange have the option to unbind. so that you can unbind any queue at any time. With bind, you can also bind any queue to this exchange.

Similar to normal queue exchange also has a message sender option from where you can send messages. These messages will be sent to all the queues which are bound to this exchange.

To see that message click on view message. In the below screenshot as you can see the same message is sent to both the queues which are bound to this exchange. Those are mq-demo and mq-demo1.

To see how can we used these MQ with Mule 4 Applications using Anypoint MQ Connector and functioning of DLQ you can use the following link : Anypoint MQ Connector

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store