---
schema_version: "1"
id: 6b6270eadf6cd53543632a177b924ec1c88298bc1991a3ad7d1beb86032a2b26
title: Anypoint MQ Consume Operation
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/anypoint-mq-connector/2.x/anypoint-mq-consume.md
canonical_url: https://docs.mulesoft.com/anypoint-mq-connector/2.x/anypoint-mq-consume
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 4d6615fdee86c23d34793da02fa288d3c9c52defddacb07b2fbc12e532aabe9b
description: MuleSoft Documentation Site
release: 2.x
latest: false
---
---
product: Anypoint MQ Connector
version: 2.x
---

# Anypoint MQ Consume Operation

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

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:

```xml
<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](https://docs.mulesoft.com/anypoint-mq-connector/2.x/anypoint-mq-ack).

## 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](https://docs.mulesoft.com/anypoint-mq-connector/2.x/anypoint-mq-connector-reference#consume) for details about the attributes structure.

## See Also

- Consume operation in the
  [Anypoint MQ Connector Reference - 2.x](https://docs.mulesoft.com/anypoint-mq-connector/2.x/anypoint-mq-connector-reference#consume)

- [Anypoint MQ ACK and NACK Operations](https://docs.mulesoft.com/anypoint-mq-connector/2.x/anypoint-mq-ack)
