Contact Free trial Login

Anypoint MQ Consume Operation - Mule 4

The Consume operation in the Anypoint MQ connector provides the ability to consume a message at any time of the flow, from any destination.

Consume A Message

The syntax to consume a message from a queue is:

<anypoint-mq:consume config-ref="MQ_config" destination="#[vars.destination]"/>

The operation above consumes the first available message in the queue identified by the destination, and then converts it to a MuleMessage resulting in the following structure:

  • The message’s content as payload.

  • The message’s metadata in the message attributes.

By default, the ACK mode is MANUAL, so the message isn’t acknowledged. If you want the message to be acknowledged as soon as it is consumed, set the mode to IMMEDIATE. For more information, see Anypoint MQ ACK and NACK Operations.

Wait for a Message

By default, the maximum wait time is configured in 10 seconds, producing a null result if no message is available in that period. If configuring a timeout that fits better for your use case, customize the pollingTime parameter.

Incoming Message Metadata

As stated before, each message received consists of two parts:

  • Payload - Contains the content of a message.

  • Attributes - Contains the metadata for a message.

This metadata maps all the information available in a Anypoint MQ message, including:

  • Message ID

  • Headers

  • Properties

See Consume for details about the attributes structure.

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.