Contact Free trial Login

Configure Queues

A queue is a temporary storage area for a message. You can create queues, FIFO queues, and dead-letter queues in Anypoint Platform. You can also send and receive messages from a queue in Anypoint Studio.

Using Anypoint MQ, you can create two types of queues:

  • Standard queue

    These queues don’t guarantee a specific message order. Standard queues are the best fit for applications in which messages must be delivered quickly.

    Anypoint MQ supports up to 120,000 in-flight messages per standard queue.

  • FIFO (first in, first out) queue

    These queues ensure that your messages arrive in order. FIFO queues are the best fit for applications requiring strict message ordering and exactly-once delivery, but in which message delivery speed is of less importance. See FIFO Queues.

    Anypoint MQ limits FIFO queues to 10 in-flight messages per FIFO queue.

You can assign either standard or FIFO queue type as a dead-letter queue (DLQ). See Dead Letter Queues.

Prerequisites

You must create an environment, user access, and roles for accessing Anypoint MQ before configuring queues. See Configure Environment, User, and Role Access.

Create a Queue

To create a standard queue or FIFO queue:

  1. Log in to Anypoint Platform.

  2. Click MQ in the left navigation bar or the main Anypoint Platform screen.

  3. Click Destinations.

  4. Click the blue plus-circle icon.

    mq blue create
  5. Select Queue or FIFO Queue.

    For Exchange, see Configure Message Exchanges.

  6. Complete the fields in Create Queue or Create FiFO Queue.

    mq create queues
    • ID specifies the queue name.

      Queue names can contain up to 127 alphanumeric characters (a-z, A-Z, 0-9), periods (.), and hyphens (-). They cannot contain spaces or other characters.

    • Message TTL (Time to live) specifies how long unprocessed messages persist before being deleted.

      The maximum TTL for a message is two weeks.

    • Message Lock Default TTL specifies how long a message waits before being put back into the queue in the event of server failure when the message is not acknowledged.

      The lock makes the message unavailable to other apps while locked, but does not block other messages from being read.

      The maximum Lock TTL is 12 hours.

    • Assign Default Delivery Delay specifies how long to delay delivery for messages sent to the queue.

      You can specify to delay message delivery in milliseconds, seconds, minutes, hours, or days. When you send a message, you can override the default delivery delay. See Delay queues.

    • Encryption (optional) encrypts all messages in the queue. See Encrypted queues.

    • Assign a Dead Letter Queue (optional) assigns the DLQ.

      The DLQ is a previously created queue to which to send undeliverable messages. See Dead Letter Queues.

  7. Click Create Queue.

  8. In the Destinations screen, click the queue type for the new queue to display its details in the right pane.

    The details for a queue are:

    mq queue details

Send a Message to a Queue

Message content can be text, JSON, or CSV (comma-separated values). The maximum size of a message is 10 MB.

To send a text message to a queue:

  1. Log in to Anypoint Platform.

  2. Click MQ in the left navigation bar or the main Anypoint Platform screen.

  3. Click Destinations in the left pane.

  4. Click the queue ID or details label to access the Messaging feature:

    mq queue details
  5. In the settings page, click Message Sender in the left pane.

  6. Leave the Type field set to Text.

  7. In the Payload field, enter text, such as Hello Mules.

    For messages in a standard queue, if you specified Assign Default Delivery Delay, you see the default delivery delay. You can override that value for this message or set a delivery delay for a message in a queue without delivery delay.

    Delayed delivery is not supported for individual messages in a FIFO queue.

  8. Click Send.

View the Number of Messages in a Queue

You can verify that a message arrived in the queue by viewing the number of messages in the queue from the Destinations screen.

To see the number the messages in the queue:

  1. Click Destinations in the left pane.

  2. Click the queue type for the queue to display its details in the right pane.

    The detail pane shows the number of messages in the queue:

    mq msgs in queue2

Get a Message from a Queue

You can verify that a message arrived by retrieving it from the queue.

To get a message from a queue:

  1. Log in to Anypoint Platform.

  2. Click MQ in the left navigation bar or the main Anypoint Platform screen.

  3. Click Destinations in the left pane.

  4. Click the queue ID or details label to access the Messaging feature:

    mq queue details
  5. In the settings page, click Message Browser in the left pane.

  6. Click Get Messages.

  7. If you are retrieving messages from a FIFO queue, click the checkbox to acknowledge that viewing messages through the browser might cause other consumers of the queue to receive messages out of order.

    mqfifo message browser
  8. Click the message ID value to view the message payload in the right pane.

    mq click id2
  9. If you want to return the message to the queue (for example, if other applications want to read the message), click the Return Messages icon:

    mq click retmsgs2

    If you return to the Message Sender or Destinations screens, messages automatically return to the queue.

    Returning the messages to the queue is a not-acknowledgment operation (NACK). The message is not altered. However, the time to live (TTL) value you set when you created the queue determines how long the message is available before Anypoint MQ deletes it.

    Alternatively, you can delete the message by clicking the trash can icon in the details pane.

    mq message delete trash can icon2

Deleting a message is an acknowledgment operation (ACK). For information about how Anypoint MQ processes ACK messages, see Acknowledge Messages.

Send a JSON Message to a Queue

To send a JSON message to a queue:

  1. Log in to Anypoint Platform.

  2. Click MQ in the left navigation bar or the main Anypoint Platform screen.

  3. Click Destinations in the left pane.

  4. Click the queue ID or details label to access the Messaging feature.

  5. In the settings page, click Message Sender in the left pane.

  6. Set the Type to JSON.

  7. In the Payload field, enter this text:

    {
    "animal that walks":"dog",
    "animal that swims":"fish",
    "animal that flies":"parrot"
    }
  8. Click Send.

  9. Click Message Browser, and then click Get Messages.

  10. Click the message ID to view the message:

    mq json get msg2

Send a CSV Message to a Queue

To send a CSV message to a queue:

  1. Log in to Anypoint Platform.

  2. Click MQ in the left navigation bar or the main Anypoint Platform screen.

  3. Click Destinations in the left pane.

  4. Click the queue ID or details label to access the Messaging feature.

  5. In the settings page, click Message Sender in the left pane.

  6. Set the Type to CSV.

  7. In the Payload field, enter this text:

    "dog",
    "fish",
    "parrot"
  8. Click Send.

  9. Click Message Browser, and then click Get Messages.

  10. Click the message ID to view the message:

    mq csv get msg2

Purge Messages from a Queue

You can purge all the messages in the queue by clicking the Purge Messages icon in the details pane:

mqfifo purge msgs icon

An alert message appears. Click the checkbox and then Delete Messages to verify that you want to purge all messages in the queue:

mqfifo purge messages

Delete a Queue

If a queue is no longer needed, you can delete it. Any in-flight messages in the deleted queue are lost. You can’t recover a deleted queue.

To delete a queue:

  1. Click Destinations.

  2. In the Destinations screen, click the queue type for the queue to display its details in the right pane.

  3. Click the trash can icon in the upper right.

    mq click type q2
  4. In the Delete Queue screen, click the checkbox:

    mq delete queue
  5. Click Delete Queue.

    The time it takes to delete or purge a queue is approximately one minute. During this time, the status of the affected queue can’t be updated.

FIFO Queues

For applications where the order of messages must be strictly preserved and enforced, Anypoint MQ provides first in, first out (FIFO) processing to enable message ordering. With FIFO queues, Anypoint MQ ensures that the order in which messages are placed in a queue is the same order messages are retrieved.

FIFO queues have the following benefits and restrictions:

  • Are limited to 300 TPS (transactions per second)

    However, if you batch 10 messages per each read and write operation (maximum) using the API, FIFO queues can support up to 3,000 TPS.

  • Support delivery delay on all messages in the FIFO queue

    If you change the delivery delay for a FIFO queue, the setting change is retroactive to all messages in the queue. Delayed delivery is not supported for individual messages in a FIFO queue.

  • Provide encryption

    Encrypting a FIFO queue does not affect the order or the contents of messages consumed.

  • Can be used as a DLQ

    When assigning a DLQ to a FIFO queue, the DLQ must also be a FIFO queue.

  • Cannot be bound to a message exchange

To create a FIFO queue, see Create a Queue. To determine if a queue is FIFO or standard (non-FIFO), view its details.

See the Anypoint MQ FAQ for the regions in which Anypoint MQ and FIFO queues are available.

For information about creating FIFO queues with the Admin API, see Create a FIFO Queue in the Admin API Portal.

FIFO Exactly-Once Delivery

For applications in which messages must be processed exactly once, such as those used in transactional use cases, FIFO queues ensure exactly-once message delivery.

FIFO queues provide message deduplication. If multiple messages are sent to a FIFO queue containing the same message ID, the first message to arrive is kept as the valid message. Subsequent messages within the deduplication interval of five minutes are considered duplicates and are discarded. For example, after the queue sees that a message with ID 12345 arrives in the queue, for the next five minutes, the FIFO queue discards any messages with the ID 12345.

When building applications in Anypoint Studio that require exactly-once delivery, you can either:

  • Set the message ID in the publisher settings in the Anypoint MQ connector.

  • Let Anypoint MQ autogenerate a unique message ID for each message sent to a queue (default).

Dead Letter Queues

Anypoint MQ enables you to ensure that messages that aren’t delivered are sent to a queue known as the dead-letter queue (DLQ). You can then analyze the messages sent to the DLQ to determine why those messages were not delivered.

A DLQ is essentially the same as any other queue except that it receives only undelivered messages. You can specify the time to live (TTL) value, encryption, and delivery delay when you create the queue.

You must have at least two queues for one of them to be assigned as a DLQ. Both queues must be:

  • The same type (standard or FIFO)

  • In the same geographical region

  • In the same environment and owned by the same Anypoint Platform account.

Encryption

Undeliverable messages that are sent to the DLQ use the encryption set for the source queue, regardless of the DLQ encryption setting. Messages that are sent directly to the DLQ by a client use the encryption setting for the DLQ. If your organization’s policy is that all messages are encrypted, then you must set encryption for all queues.

Billing and Maximum Deliveries

If a message sent to the DLQ is a dead letter from another queue, the message is not charged against the billable message units. However, if a client sends a message directly to a DLQ, that message is charged.

If a queue has a dead-letter queue assigned:

  • Viewing the messages in the source queue using the Anypoint MQ Message Browser counts against the number of maximum deliveries.

  • Viewing a message and returning it to the queue counts as a NACK operation and is considered an unsuccessful delivery attempt.

  • Deleting the message in the Message Browser prevents it from being counted against the maximum deliveries, but the message is lost.

How Messages Are Sent to a DLQ

This flowchart shows how messages are sent to a DLQ:

mq dlq flowchart

Assign a DLQ to a Queue

You can assign any queue as a DLQ for another queue as long as it’s the same type and in the same region and environment.

  • Messages sent to a FIFO DLQ must originate from a FIFO queue.

  • Messages sent to a standard DLQ must originate from a standard queue.

To assign a DLQ to a queue:

  1. Create a queue.

  2. Toggle Assign a Dead Letter Queue to On.

    The following additional fields appear:

mq create q dlq
  • Dead Letter Queue Name

    Choose a previously created queue name from the drop-down list.

  • Reroute after 10 attempts (Optional)

    Specify how many times Anypoint MQ attempts to deliver messages in the queue before rerouting the message to the dead-letter queue. If not specified, the default value is 10 tries. This value ranges from 1 to 1000 attempts.

Recover Messages from a DLQ

You can recover messages from the DLQ using the REST API to get the message from the queue and writing the message to a new queue. See Anypoint MQ Admin API.

Determine Whether a Queue is a DLQ

You can see whether a queue is a DLQ by viewing its details:

mq queue view dlq

You can also view details of each queue from the REST Administration API, using the Get Queue REST endpoint.

{
 "encrypted": false,
 "type": "queue",
 "queueId": "my-dlq-1",
 "deadLetterSources": [
   "my-queue-4",
   "my-dls-1"
 ],
 "defaultTtl": 2000000,
 "defaultLockTtl": 2000000
}

If DLQ is set, the returned entities contain the deadLetterSources field.

For more information, see Anypoint MQ Admin API.

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.