# mulesoft MQ - Full Documentation --- product: MQ --- # Accessing Anypoint MQ Audit Logs > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The Anypoint Platform audit logging service logs Anypoint MQ actions on queues, exchanges, and client applications. With the **Organization Administrator** or **Audit Log Viewer** role, you can access the audit logs relevant to your business group from the **Audit Log** page in Access Management or using the Audit Log REST API. For example, you might use the audit logs to determine: - All Anypoint MQ actions of a user - All Anypoint MQ actions on an object, such as a queue or exchange > [!NOTE] The audit logging service doesn’t record these actions as auditable: > > - Sending, receiving, or browsing messages > > - Failed Anypoint MQ operations ## Access Anypoint MQ Audit Logs To access Anypoint MQ audit logs: 1. In Anypoint Platform, go to **Access Management**. 2. From the **Access Management** navigation menu, select **Audit Logs**. 3. Select filters and click **Apply filters**: Products **Anypoint MQ** Types **Binding**, **Client**, **Exchange**, **Queue** Actions - Binding: **Create binding**, **Delete binding** - Client: **Create client**, **Delete client**, **Regenerate client** - Exchange: **Create exchange**, **Delete exchange**, **Modify exchange** - Queue: **Create queue**, **Delete queue**, **Modify queue**, **Purge queue** You can also search by environment, object name, or user. The **Audit logs** page displays the logs: ![Filters, Apply filters button, current filters, and Download payload button on the Audit logs page](/mulesoft/current/en-us/mq/_images/mq-access-mgmt-audit-logs.png)
1Select filters.
2Apply filters.
3View current filters.
4Download payload.
### Payloads A _payload_ is a JSON-formatted text file that lists the Anypoint MQ settings in place when the action occurs. For each action on the **Audit Log** page, click the **Download payload** icon (![](/mulesoft/current/en-us/mq/_images/icon-download-payload.png)) to download a payload file (`payload.txt`). This example shows a formatted version of the contents of `payload.txt` after creating a queue: ```json { "organizationId": "", "environmentId": " FieldDescription

organizationId

Organization ID for the current Anypoint Platform account

You can use the organization ID to access Anypoint MQ REST APIs.

environmentId

Environment ID for the current Anypoint Platform account

You can use the environment ID to access Anypoint MQ REST APIs.

objectName

Name of the queue, exchange, or client application

userName

Username for the Anypoint Platform account

objectId

Name of the queue, exchange, or client application

The objectID is the same value as objectName.

regionId

Region location where you process your Anypoint MQ connections

defaultTtlMillis

Default time to live (in milliseconds)

This value specifies how long unprocessed messages persist before being deleted.

defaultLockTtlMillis

Default lock time to live (in milliseconds) for the queue or exchange you create

This value specifies the duration that a message is unavailable to other applications before being put back into the queue.

encrypted

Whether the queue or message exchange is encrypted

If you configure Anypoint MQ queues for encryption at rest, the payloads are encrypted with the AES-256 GCM algorithm on the server side.

Anypoint MQ encrypts only the message body. Anypoint MQ does not encrypt the headers or properties of messages sent to exchanges and queues.

deadLetterQueueId

Name of the dead letter queue to which the current object is associated

maxDeliveries

How many times Anypoint MQ tries to deliver messages in the queue before rerouting the message to the dead letter queue

fifo

Whether the queue is a FIFO queue (true) or not (false)

This field is set to true at the time you create the FIFO queue. Subsequent changes to a FIFO queue set the fifo field to null.
## See Also - [Audit Logging](https://docs.mulesoft.com/access-management/audit-logging) - [FIFO Queues](https://docs.mulesoft.com/mq/mq-queues#fifoqueues) - [Anypoint MQ REST APIs](https://docs.mulesoft.com/mq/mq-apis) - [Audit Log Query API](https://dev-portal.mulesoft.com/apis/audit-log-query.html) --- product: MQ --- # Anypoint MQ Connectors > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for MQ (Anypoint MQ Connector) is available for Mule 4. - Mule 4: - [Anypoint MQ Connector 4.x](#four-for-mule-4) - [Anypoint MQ Connector 3.x](#three-for-mule-4) - [Anypoint MQ Connector 2.x](#two-for-mule-4) ## Anypoint MQ Connector 4.x - Mule 4 - [Anypoint MQ Connector 4.x for Mule 4](https://docs.mulesoft.com/anypoint-mq-connector/latest/) - [Upgrading and Migrating Anypoint MQ Connector](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-connector-upgrade-migrate) - [ACK and NACK Operations](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-ack) - [Subscribe Operation](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-listener) - [Consume Operation](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-consume) - [Publish Operation](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-publish) - [Anypoint MQ Connector 4.x Reference](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-connector-reference) - [Anypoint MQ Connector Release Notes - Mule 4](https://docs.mulesoft.com/release-notes/connector/anypoint-mq-connector-release-notes-mule-4) - [Anypoint MQ Connector 4.x - Mule 4 on Anypoint Exchange](https://www.mulesoft.com/exchange/com.mulesoft.connectors/anypoint-mq-connector/) ## Anypoint MQ Connector 3.x - Mule 4 > [!NOTE] Only the US Cloud and EU Cloud instances of Anypoint Platform support this connector > version. - [Anypoint MQ Connector 3.x for Mule 4](https://docs.mulesoft.com/anypoint-mq-connector/3.x/) - [ACK and NACK Operations](https://docs.mulesoft.com/anypoint-mq-connector/3.x/anypoint-mq-ack) - [Subscribe Operation](https://docs.mulesoft.com/anypoint-mq-connector/3.x/anypoint-mq-listener) - [Consume Operation](https://docs.mulesoft.com/anypoint-mq-connector/3.x/anypoint-mq-consume) - [Publish Operation](https://docs.mulesoft.com/anypoint-mq-connector/3.x/anypoint-mq-publish) - [Anypoint MQ Connector 3.x Reference](https://docs.mulesoft.com/anypoint-mq-connector/3.x/anypoint-mq-connector-reference) - [Anypoint MQ Connector Release Notes - Mule 4](https://docs.mulesoft.com/release-notes/connector/anypoint-mq-connector-release-notes-mule-4) - [Anypoint MQ Connector 3.x - Mule 4 on Anypoint Exchange](https://www.mulesoft.com/exchange/com.mulesoft.connectors/anypoint-mq-connector/) ## Anypoint MQ Connector 2.x - Mule 4 > [!NOTE] Only the US Cloud and EU Cloud instances of Anypoint Platform support this connector > version. - [Anypoint MQ Connector 2.x for Mule 4](https://docs.mulesoft.com/anypoint-mq-connector/2.x/) - [ACK and NACK Operations](https://docs.mulesoft.com/anypoint-mq-connector/2.x/anypoint-mq-ack) - [Subscribe Operation](https://docs.mulesoft.com/anypoint-mq-connector/2.x/anypoint-mq-listener) - [Consume Operation](https://docs.mulesoft.com/anypoint-mq-connector/2.x/anypoint-mq-consume) - [Publish Operation](https://docs.mulesoft.com/anypoint-mq-connector/2.x/anypoint-mq-publish) - [Anypoint MQ Connector 2.x Reference](https://docs.mulesoft.com/anypoint-mq-connector/2.x/anypoint-mq-connector-reference) - [Anypoint MQ Connector Release Notes - Mule 4](https://docs.mulesoft.com/release-notes/connector/anypoint-mq-connector-release-notes-mule-4) - [Anypoint MQ Connector - Mule 4 on Anypoint Exchange](https://www.mulesoft.com/exchange/com.mulesoft.connectors/anypoint-mq-connector/) ## Anypoint MQ APIs - [Anypoint MQ Admin API](https://dev-portal.mulesoft.com/apis/anypoint-mq-admin.html) - [Anypoint MQ Broker API](https://dev-portal.mulesoft.com/apis/anypoint-mq-broker.html) - [Anypoint MQ Stats API](https://dev-portal.mulesoft.com/apis/anypoint-mq-stats.html) ## See Also - [Anypoint MQ FAQ](https://docs.mulesoft.com/mq/mq-faq) --- product: MQ --- # Anypoint MQ Glossary > For the full documentation index, see: https://docs.mulesoft.com/llms.txt ACK/NACK Operations that specify: - ACK operation - An app receives a message, and Anypoint MQ deletes the message. - NACK operation - An app does not receive a message, and Anypoint MQ doesn’t delete the message. For information, see [ACK and NACK Operations](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-ack). Binding A method for specifying a set of standard or FIFO queues that form a message exchange, enabling apps to send messages to multiple queues. When you specify which message queues are bound to a message exchange, Anypoint MQ creates and manages the bindings for you. For information, see [Sending Messages to Multiple Queues Using Message Exchanges](https://docs.mulesoft.com/mq/mq-exchanges). Dead Letter Queue (DLQ) A queue that stores undeliverable messages from other queues. For information, see [Dead Letter Queues](https://docs.mulesoft.com/mq/mq-queues#dead-letter-queues). Default Acknowledgement Timeout The period that a message remains unacknowledged before being returned to the queue, for example, if a server fails or if flow processing takes too long and times out. Delay Queue A queue that postpones delivery of new messages for a specified period. Consumers can’t see messages sent to a delay queue for the delay duration. The minimum delay for a queue is 0 seconds. The maximum is 15 minutes. If you change the queue delay for a: - Standard queue, the setting change doesn’t affect messages in the queue. - FIFO queue, the setting change is retroactive to all messages in the queue. You can override the default queue delay for a particular message in a standard queue only. Delayed Message Delivery A setting that specifies how long to postpone delivery of a particular message to a standard queue. Consumers can’t see messages sent with delivery delay for the delay duration. The minimum delivery delay for a message is 0 seconds. The maximum is 15 minutes. FIFO queues don’t support delayed delivery for individual messages. Destination A message exchange or queue. Applications register to a destination and publish messages to that destination. Applications subscribe to a destination to receive a message. Anypoint MQ lets you configure destinations by creating or maintaining queues or message exchanges. You configure destinations in Anypoint Studio using Anypoint MQ Connector. Durable Message A message that persists until its target client receives it. Duration The period during which messages can persist in flight (for up to two weeks), after Anypoint MQ deletes them. Encrypted Queue A queue that is encrypted, enabling companies to comply with their data at rest policies. Use encrypted queues for enhanced security. If you configure Anypoint MQ queues for encryption at rest, the payloads are encrypted with the AES-256 GCM algorithm on the server side. Anypoint MQ encrypts only the message body. Anypoint MQ does not encrypt the `headers` or `properties` of messages sent to exchanges and queues. Failover A feature that, when enabled for standard queues, assigns a fallback queue in a fallback region. If an application can’t reach the Anypoint MQ server in the primary region, the connector automatically diverts message processing to the fallback region. For information, see [Configuring Cross-Region Failover for Standard Queues](https://docs.mulesoft.com/mq/mq-failover). Fallback Queue A queue that Anypoint MQ automatically creates in a fallback region when failover is enabled for a standard queue. The Anypoint MQ server manages fallback queues and regions; end users can’t configure them. For information, see [Configuring Cross-Region Failover for Standard Queues](https://docs.mulesoft.com/mq/mq-failover). Fallback Region A region that Anypoint MQ automatically assigns to a fallback queue when failover is enabled for a standard queue. The Anypoint MQ server manages fallback queues and regions; end users can’t configure them. For information, see [Configuring Cross-Region Failover for Standard Queues](https://docs.mulesoft.com/mq/mq-failover). FIFO Exchange A [message exchange](#message-exchange) that binds multiple [FIFO queues](#fifo-queues), enabling you to send messages to multiple FIFO queues. FIFO Queue A queue that processes messages first-in, first-out (FIFO), ensuring message ordering for applications in which the order of messages must be strictly preserved and enforced. For information, see [FIFO Queues](https://docs.mulesoft.com/mq/mq-queues#fifo-queues). In-Flight Messages that are any of these states: - Received by a queue, but not deleted - Awaiting acknowledgment (ACK) or not acknowledgment (NACK) - Not returned to the queue due to an expired **Default Acknowledgement Timeout** (time-to-live) setting In-flight messages are not visible to other consumers. Anypoint MQ supports up to 120,000 in-flight messages per queue for standard (non-FIFO) queues. FIFO queues can have up to 10 in-flight messages in each message group. In Queue Messages that have been sent. Anypoint MQ supports unlimited messages in queue for both standard and FIFO queues. Lock ID An identifier that allows only a single app to read a queue. Anypoint MQ provides the lock when an app acknowledges a message from a queue. Message Serializable [Mule Message](https://docs.mulesoft.com/mule-runtime/latest/about-mule-message) content that applications send and receive so that they can communicate with each other. Message Exchange A pub/sub message source with multiple outputs. Applications register to subscribe to messages that the message exchange publishes. For information, see [Sending Messages to Multiple Queues Using Message Exchanges](https://docs.mulesoft.com/mq/mq-exchanges). Message Groups An assignment of specific messages to a group, enabling multiple consumers to process messages from a single FIFO queue. For information, see [FIFO Queues and Message Groups](https://docs.mulesoft.com/mq/mq-queues#fifo-queues-msg-groups). Message-Routing Rules Rules that you configure on a message exchange binding to route a subset of the messages published to an exchange to a specific queue. On-premises Mule runtime that runs on a computer in your organization. Payload The message content, which can be text, JSON, or CSV (comma-separated values). Point-to-Point A pattern that allows an app to send a message that only a single app can receive. Pub/Sub (Publish/Subscribe) A pattern that distributes messages to multiple consumers. Publisher An app that sends messages to Anypoint MQ. Queue A point-to-point message storage area that holds a message that a client receives. For information, see [Configuring and Using Queues](https://docs.mulesoft.com/mq/mq-queues). Subscriber An app that receives messages from Anypoint MQ. TTL (time-to-live) How long the message stays in a queue before Anypoint MQ expires and removes it from the queue. Each queue has a message time-to-live (TTL). If you change the message TTL for a queue, the new TTL value applies to any messages in the queue and all new messages added to the queue. ## See Also - [Anypoint MQ Overview](https://docs.mulesoft.com/mq/) - [FAQ: Anypoint MQ](https://docs.mulesoft.com/mq/mq-faq) --- product: MQ --- # Anypoint MQ Overview > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint MQ is a multi-tenant, cloud-based message queuing service for exchanging data asynchronously between your applications. The Anypoint MQ messaging broker enables applications to communicate by publishing a Mule message to a queue so that another app can consume the message. Anypoint MQ is fully integrated with Anypoint Platform, offering access control, client management, and connectors. Integration with Access Management enables you to specify environments and business groups for role-based access control and support for connected apps. Anypoint MQ supports hybrid use cases and IoT (Internet of Things), in which you collect data from different devices. Anypoint MQ also provides a REST API for device applications. You can also use Anypoint MQ with other app frameworks such as node.js to communicate with queues. This spotlight video gives an overview of Anypoint MQ: ![](https://play.vidyard.com/9vARbkYLk5ZqYsrs6fgmvg.jpg) Anypoint MQ: - Provides fully hosted and managed [queues](https://docs.mulesoft.com/mq/mq-queues) and [message exchanges](https://docs.mulesoft.com/mq/mq-exchanges) in the cloud. - Supports large payloads, encryption, queuing, and publish/subscribe (pub/sub) paradigms. - Enables you to easily connect to non-Mule applications by using the REST API. - Provides Anypoint Studio access, which makes the process of leveraging your queues and message exchanges as simple as drag, drop, and configure. ## Before You Begin Using Anypoint MQ 1. Make sure you have a paid Anypoint Platform package or subscription with the Anypoint MQ integration add-on. Anypoint MQ isn’t available in the trial edition of Anypoint Platform. To add Anypoint MQ to your package or subscription, contact your account team. After purchasing Anypoint MQ, wait one hour for Anypoint MQ to become available in Anypoint Platform. For information about Anypoint Integration packages, see [MuleSoft Anypoint Platform Pricing](https://www.mulesoft.com/anypoint-pricing). 2. Set up your environment and permissions. For information, see [Set Up the Environment and Access Permissions](https://docs.mulesoft.com/mq/mq-access-management). 3. Review this overview for information about Anypoint MQ. ## Anypoint MQ Features Anypoint MQ includes these features: Queues and Message Exchanges Send messages to queues and pull messages from queues. Use a message exchange to send messages to multiple standard or FIFO queues simultaneously or route messages to specific queues by using intelligent message routing rules. For information, see: - [Queues and Message Exchanges](#queues-and-exchanges) - [Configuring and Using Queues](https://docs.mulesoft.com/mq/mq-queues) - [Sending Messages to Multiple Queues Using Message Exchanges](https://docs.mulesoft.com/mq/mq-exchanges) - [Route Messages by Configuring Rules on Message Exchanges](https://docs.mulesoft.com/mq/mq-routing-rules) Management Console Monitor queue statistics, purge queues, and see how many messages are in flight by using the management console. Anypoint MQ Connector Send and receive messages from any Mule app, whether it’s deployed in CloudHub or used in a hybrid scenario and deployed on-premises. For information, see [Anypoint MQ Connectors](https://docs.mulesoft.com/mq/mq-connectors). Usage Information View the current and past months' usage, including the total number of messages and API requests. Organization administrators and owners access this information from the **Access Management** page. For information, see [Viewing Anypoint MQ Usage Data](https://docs.mulesoft.com/mq/mq-usage). REST API Use the REST API to easily communicate with non-Mule applications. For information, see [Anypoint MQ REST APIs](https://docs.mulesoft.com/mq/mq-apis). Environments and Role-Based Access Control Use Anypoint Platform access management to specify different environments for your queues, who can access each environment, and what they can do within each environment. For information, see [Set Up the Environment and Access Permissions](https://docs.mulesoft.com/mq/mq-access-management). Client Management Use connected apps to authenticate with Anypoint Platform by using APIs. Register each consumer registered as a connected app with a name, ID, and secret. The connected app uses the ID and secret to authenticate and get access to queues and message exchanges within a single environment. You can’t use connected apps across multiple environments or business groups. For information, see [Configuring Connected Apps](https://docs.mulesoft.com/mq/mq-connected-apps). Large Payloads Send large payloads of up to 10 MB. If the payload contains any format except text (such as CSV, HTML, JSON, and XML), Anypoint MQ converts it to a string before sending, which increases the payload size. This conversion might result in the payload exceeding the maximum payload size of 10 MB and causing a `Payload too large` error. Disaster Recovery Ensure your messages are delivered even if services go down temporarily. Within each region, Anypoint MQ services deploy to multiple availability zones (AZs) to provide high availability (HA). If service in one availability zone goes down, the Anypoint MQ service operates normally in that region. If all availability zones go down in a region, the Anypoint MQ service is unavailable in that region until at least one of the availability zones comes back up. Messages that were already in the Anypoint MQ system before service was interrupted are retained. You can enable failover on standard queues, which creates a fallback queue in a fallback region. With failover enabled, if an app that uses Anypoint MQ Connector can’t contact the Anypoint MQ server in a region, the connector switches to the fallback queue to continue publishing and consuming messages. For information, see [Configuring Cross-Region Failover for Standard Queues](https://docs.mulesoft.com/mq/mq-failover). Usage Statistics View usage reports to manage peak usage and subscription parameters. Reports provide current and past usage, including consumed data, API requests, and the total number of messages received. For information, see [Viewing Anypoint MQ Usage Data](https://docs.mulesoft.com/mq/mq-usage). You can also use the Anypoint MQ Stats API to perform statistical analysis of queue performance. For information, see [Anypoint MQ Stats API](https://docs.mulesoft.com/mq/mq-apis#mq-stats-api). > [!NOTE] You can’t use Anypoint MQ with CloudHub Insight or Anypoint Monitoring. ## Queues and Message Exchanges _Message queues_ provide temporary storage that enables applications to communicate in a scalable and reliable way. Publishers can publish messages into queues, and subscribers can receive messages from queues. ![A publisher sends a message to a queue, and a subscriber reads messages from a queue](/mulesoft/current/en-us/mq/_images/mq-pub-q-sub.png) To distribute messages to multiple queues and consumers, bind multiple queues to a _message exchange_. By default, messages sent to an exchange appear in all of its bound queues simultaneously. When you configure message routing rules, a message appears only in queues whose binding has no rule or has a rule that the message matches. For details, including what happens when no rule matches, see [Route Messages by Configuring Rules on Message Exchanges](https://docs.mulesoft.com/mq/mq-routing-rules). ![A publisher sends messages to an Exchange, which then directs messages to queues, from which consumers retrieve them](/mulesoft/current/en-us/mq/_images/mq-pub-ex-sub.png) For example, if a publisher publishes changes in the weather and multiple apps must receive that data, use a message exchange to publish a single message to multiple queues for each app. A _binding_ is a relationship between the queue and message exchange that tells the message exchange where to send messages. By configuring _intelligent message-routing rules_ on a binding, you can route messages to specific queues that are bound to the message exchange. - You can bind a queue to multiple message exchanges. - You can bind a maximum of 450 queues to a message exchange. - You can bind a maximum of 25 queues to an exchange with message routing rules defined. If an exchange has more than 25 queue bindings, you can’t use intelligent message routing. In this example, an app running Salesforce customer relationship manager (CRM) uses Anypoint MQ to communicate with two applications that handle different databases: ![A CRM system communicates customer updates through a message exchange, which then relays the information to separate queues for a database and SAP](/mulesoft/current/en-us/mq/_images/mq-crm-to-dbs.png) The Salesforce app sends a pub/sub message to an Anypoint MQ message exchange (`customer-updates`). The two applications (`customer-consumer-1` and `customer-consumer-2`) receive the message from the message exchange and send it to their respective databases. ### Benefits of Queues Queues provide these benefits: - Horizontal scalability By putting a message in a queue, the work to process that message can be distributed over multiple subscribers. - Reliability Queues ensure that messages are always processed, even in the case of failure. Anypoint MQ provides reliability with queues by using a lock and acknowledge mechanism. These features ensure that a message is always processed, even in the case of failure. - Decoupling You can use a queue as a communication mechanism between different applications and devices, enabling them to have different development life cycles or maintenance windows without affecting other applications. - Aggregation Multiple message producers can publish to a single queue, which enables easy consumption by consumers. The message-consumption process is: 1. A consumer retrieves messages from a queue, which locks the messages and makes the messages invisible to all other consumers. 2. When retrieving, the consumer specifies a lock timeout. If the message is not processed within the specified window, Anypoint MQ makes the message visible to other consumers. If a failure occurs, such as a consumer node crash, another node can process the message. A locked message does not block other messages from being read. - If a consumer processes a message successfully, the client acknowledges the message, and Anypoint MQ removes the message from the queue. - If a consumer can’t process a message, the message proceeds with a negative acknowledgment and becomes visible in the queue again. For information, see [ACK and NACK Operations](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-ack). - Unlimited messages in a queue Anypoint MQ doesn’t limit the number of messages in a queue. The size of each message in a queue is limited to 10 MB. - Long polling Messages are read through long polling. The server holds a request open until new data is available, and then Anypoint MQ delivers a batch of messages with a single read. - Billing and charging Billing is based on the number of messages delivered to subscribers from queues, rather than the number of queues or message exchanges you create. ## Anypoint MQ Features by Control Plane
Anypoint MQ FeatureUS Cloud and EU CloudCanada Cloud, Japan Cloud, India Cloud, Australia Cloud, United Kingdom CloudMuleSoft Government Cloud

Yes

Yes

Yes

Yes

No

No

Yes

No

Yes

Yes

Yes

No

### Limitations by Control Plane All Anypoint MQ features are supported on [MuleSoft Government Cloud](https://gov.anypoint.mulesoft.com/login/), [Canada Cloud](https://ca1.platform.mulesoft.com), [Japan Cloud](https://jp1.platform.mulesoft.com), [India Cloud](https://in1.platform.mulesoft.com), [Australia Cloud](https://au1.platform.mulesoft.com), and [United Kingdom Cloud](https://gb1.platform.mulesoft.com) with the following exceptions:
LimitationMuleSoft Government CloudCanada Cloud, Japan Cloud, India Cloud, Australia Cloud, United Kingdom Cloud

Not supported. When creating a queue, Encryption defaults to selected.

Not supported. When creating a queue, Encryption defaults to enabled.

Supported

Not supported. Deploy apps to CloudHub 2.0 shared spaces or Anypoint Runtime Fabric.

Not supported. Use connected apps instead.

Not supported. Use connected apps instead.

Not supported. Requires Anypoint MQ Connector 4.x for Mule 4.

Not supported. Requires Anypoint MQ Connector 4.x for Mule 4.

Not supported

Not supported

For information about the regions where Anypoint MQ is available, see [Anypoint MQ Regions](https://docs.mulesoft.com/mq/mq-faq#mq-regions). For information about MuleSoft Government Cloud, see [Government Cloud Overview](https://docs.mulesoft.com/gov-cloud/). For information about Anypoint Platform on other control planes, see [Salesforce Hyperforce Overview](https://docs.mulesoft.com/hyperforce/). ## See Also - [Salesforce Hyperforce Overview](https://docs.mulesoft.com/hyperforce/) - [Anypoint MQ Glossary](https://docs.mulesoft.com/mq/mq-glossary) - [Anypoint MQ Connectors](https://docs.mulesoft.com/mq/mq-connectors) - [FAQ: Anypoint MQ](https://docs.mulesoft.com/mq/mq-faq) - [Anypoint MQ Release Notes](https://docs.mulesoft.com/mq/mq-release-notes) - [Anypoint MQ Audit Logging](https://docs.mulesoft.com/access-management/audit-logging#to-query-audit-logging-for-anypoint-mq) --- product: MQ --- # Anypoint MQ Release Notes > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following release notes are provided for Anypoint MQ: - [Anypoint MQ Release Notes](https://docs.mulesoft.com/release-notes/mq/mq-release-notes) - [Anypoint MQ Connector Release Notes for Mule 4](https://docs.mulesoft.com/release-notes/connector/anypoint-mq-connector-release-notes-mule-4) - [Known Issues](https://help.salesforce.com/s/issues) --- product: MQ --- # Anypoint MQ REST APIs > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The Anypoint MQ APIs enable you to use REST to send and receive messages, administer queues and message exchanges, and analyze results. Anypoint MQ provides these APIs: - [Anypoint MQ Admin API](#mq-admin-api) - [Anypoint MQ Broker API](#mq-broker-api) - [Anypoint MQ Stats API](#mq-stats-api) Anypoint MQ APIs are available in the [MuleSoft developer portal](https://dev-portal.mulesoft.com/index.html?filter=api). ## Workflow for an API This example shows the workflow for accessing the Anypoint MQ Broker API: ![Workflow of the Anypoint MQ Broker API](/mulesoft/current/en-us/mq/_images/mq-api-workflow.png) 1. An app sends a request to Anypoint MQ and sets how long to hold the lock on the message. 2. Anypoint MQ sends the message and the lock ID. 3. The app acknowledges the message and requests Anypoint MQ to delete the message, or the app negatively acknowledges the message and requests Anypoint MQ to make the message available to other apps. The app sends the message ID and lock ID to Anypoint MQ. For more information, see [ACK and NACK Operations](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-ack). 4. If no action is taken and the duration of a lock’s time to live expires, the message is negatively acknowledged and returns to the queue to be available for other apps. ## Before You Begin - Create an app that uses Anypoint MQ and [deploy it to CloudHub](https://docs.mulesoft.com/cloudhub/deploying-to-cloudhub). - [Get a bearer token](#get-bearer-token) for an Anypoint Platform user using the Access Management API. You need the bearer token to access all Anypoint MQ APIs. - [Get the ORG\_ID and ENV\_ID](#get-org-env-id). You need the organization ID and environment ID for operations with all Anypoint MQ APIs. - [Get the REGION\_ID](#get-region-id). You need the region ID for operations with the Anypoint MQ Admin API. - [Get the QUEUE\_ID](#get-queue-id). You need the queue ID for operations with the Anypoint MQ Admin API. ### Get the Bearer Token to Use With Anypoint MQ APIs To access the Anypoint MQ APIs, you must first get the bearer token from the Anypoint Platform user using the [Access Management API](https://dev-portal.mulesoft.com/apis/access-management.html). > [!NOTE] The default time to live (TTL) for the bearer token is 60 minutes. If MFA (multi-factor authentication) is enabled Use a connected app to get the bearer token: 1. [Create a connected app](https://docs.mulesoft.com/mq/mq-connected-apps). 2. Assign the connected app the Organization Administrator scope to access the organization and environment queries. 3. From the **Connected Apps** page, click **Copy Id** and **Copy Secret** for the app you just created. 4. Run this command and replace CLIENT\_ID and CLIENT\_SECRET with the values you copied from the connected app and AUTH\_SERVER\_HOST with the authorization server: ```bash curl --location 'https:///accounts/api/v2/oauth2/token' \ --header 'Content-Type: application/json' \ --data '{ "client_id": "", "client_secret": "", "grant_type": "client_credentials" }' ``` The output includes the bearer token: ```json { "access_token": "" "expires_in": 3600, "token_type": "bearer" } ``` 5. Use this bearer token to access any Anypoint MQ API that requires a bearer token. If MFA isn’t enabled Authenticate with the credentials of a user with the Organization Administrator permission: 1. Run this command, replacing AUTH\_SERVER\_HOST with the authorization server, for example `https://anypoint.mulesoft.com/` ```bash curl -H \ "Content-Type: application/json" \ -X POST -d '{"username":"","password":""}' \ "https:///accounts/login" ``` Make sure the user has the Organization Administrator permission to access the organization and environment queries. The output includes the token: ```json { "access_token": "", "token_type": "bearer", "redirectUrl": "/home/" } ``` 2. Use this bearer token to access any Anypoint MQ API that requires a bearer token. ### Get the Broker Bearer Token to Use With Anypoint MQ Broker API For the Anypoint MQ Broker API, you can also get the bearer token from a client app. MuleSoft recommends that you use connected apps rather than client apps to generate credentials. For information, see [Configuring Connected Apps](https://docs.mulesoft.com/mq/mq-connected-apps). > [!IMPORTANT] You can use the broker bearer token only with the Broker API. Don’t use this token > with the Stats and Admin APIs. Instead, follow the steps in > [Get the Bearer Token to Use With Anypoint MQ APIs](#get-bearer-token) to get the bearer token. All calls to get a token for a particular CLIENT\_ID return the same token. Multiple apps using the same CLIENT\_ID use the same token. The token is valid for 60 minutes. Accessing the token before its expiry extends the token validity by another 60 minutes. To get the CLIENT\_ID and CLIENT\_SECRET from a client app 1. [Create a client app](https://docs.mulesoft.com/mq/mq-client-apps). 2. From the **Client Apps** page, select the app you just created. 3. Click **Copy** to copy the client app ID and client secret values to your clipboard. To get the token required to authenticate with the Anypoint Platform API 1. Run this command and replace CLIENT\_ID and CLIENT\_SECRET with the values you copied from the client app and AUTH\_SERVER\_HOST with the authorization server: ```bash curl -X POST "https://AUTH_SERVER_HOST/accounts/oauth2/token" \ -H "Content-Type: application/json" \ -d '{ "client_id": "", "client_secret": "", "grant_type": "client_credentials" }' ``` The command returns output similar to: ```json { "access_token": "", "simple_client": { "envId": "", "orgId": "" }, "token_type": "bearer" } ``` ### Get the Organization ID and Environment ID To get the ORG\_ID, run this command, replacing AUTH\_SERVER\_HOST with the authorization server: ```bash curl -X GET https:///accounts/api/me \ -H "Authorization: Bearer " ``` The response includes output similar to: ```json "organization": { "name": "MyCompany", "id": "ORG_ID", }, ``` To get the ENV\_ID, run this command, replacing AUTH\_SERVER\_HOST with the authorization server: ```bash curl -X GET https:///accounts/api/organizations//environments \ -H "Authorization: Bearer " ``` The response includes output similar to: ```json "environments": [ { "id": "ENV_ID", "name": "Production", "organizationId": "ORG_ID", }, ] ``` ### Get the Region ID To get the region ID (REGION\_ID): ```bash curl "https://anypoint.mulesoft.com/mq/admin/api/v1/organizations//environments//regions" ``` The response includes output similar to: ```json { "id": "us-east-1", "name": "US East", "type": "aws" }, ``` ### Get the Queue ID To get the queue ID (QUEUE\_ID): ```bash curl -X GET \ https://anypoint.mulesoft.com/mq/admin/api/v1/organizations//environments//regions//destinations \ -H "Authorization: Bearer " ``` The response includes output such as: ```json { "encrypted" : true, "type" : "queue", "queueId" : "myDemoQueue", "maxDeliveries" : 10, "deadLetterQueueId" : "myDLQ", "fifo" : false, "isFallback" : false, "defaultTtl" : 604800000, "defaultLockTtl" : 120000, "defaultDeliveryDelay" : 0 }, ``` See also [Retrieve Queue Configuration](#retrieve-queue-configuration). ## Anypoint MQ Admin API The Anypoint MQ Admin API provides access to Anypoint MQ administrative functionality. You can use the [Anypoint MQ Admin API](https://dev-portal.mulesoft.com/apis/anypoint-mq-admin.html) to create and manage queues, message exchanges, and client apps. If you call the Anypoint MQ Admin API for distinct environments within one minute, the API throttles your requests to 50 transactions per minute (TPM). These examples use the Anypoint MQ Admin API to create queues and message routing rules from the command line using `curl`: - [Create a FIFO Queue](#fifo-queue-api) - [Create a FIFO Exchange](#fifo-exchange-api) - [Create or Change Message Routing Rules](#routing-rules-api) - [Enable or Disable Failover on an Existing Standard Queue](#enable-failover-api) - [Retrieve Queue Configuration](#retrieve-queue-configuration) ### Create a FIFO Queue You can create a FIFO queue using the Anypoint MQ Admin API by including `"fifo": true` in the body. > [!NOTE] The organization from which you use the Administration portal must have an Anypoint MQ > FIFO entitlement. See [Anypoint MQ FAQ](https://docs.mulesoft.com/mq/mq-faq) for the regions where Anypoint MQ is available. Use a `curl` command to create a FIFO queue: ```bash curl -X PUT "https://anypoint.mulesoft.com/mq/admin/api/v1/organizations//environments//regions//destinations/queues/" \ --header 'Content-Type: application/json' \ --header 'Authorization: bearer ' \ --data-raw '{ "defaultTtl" : 120000, "defaultLockTtl" : 10000, "encrypted" : false, "fifo" : true }' ``` The response includes output such as: ```json { "encrypted" : true, "type" : "queue", "queueId" : "myDemoQueue-api", "maxDeliveries" : 10, "deadLetterQueueId" : "myDLQ-api", "fifo" : false, "isFallback" : false, "defaultTtl" : 604800000, "defaultLockTtl" : 120000, "defaultDeliveryDelay" : 0 }, ``` ### Create a FIFO Exchange You can create a FIFO exchange using the Anypoint MQ Admin API by including `"fifo": true` in the body. > [!NOTE] The organization from which you use the Administration portal must have an Anypoint MQ > FIFO entitlement. See [Anypoint MQ FAQ](https://docs.mulesoft.com/mq/mq-faq) for the regions where Anypoint MQ is available. Use a `curl` command like this to create a FIFO exchange: ```bash curl -X PUT "https://anypoint.mulesoft.com/mq/admin/api/v1/organizations//environments//regions//destinations/exchanges/" \ --header 'Content-Type: application/json' \ --header 'Authorization: bearer ' \ --data-raw '{ "encrypted" : false, "fifo" : true }' ``` ```json { "encrypted" : false, "type" : "exchange", "fifo" : true, "exchangeId" : } ``` ### Create or Change Message Routing Rules > [!NOTE] FIFO exchanges don’t support routing rules. To use routing rules, configure a standard > exchange. To route a subset of the messages that are published to an exchange to a specific queue, use the Admin API to create message routing rules on the binding between the exchange and the queue. > [!NOTE] The new message routing rule can take up to 15 minutes to take effect. Bindings without configured message routing rules receive every message published to the exchange. If every binding has a configured routing rule and a message matches none of them, Anypoint MQ doesn’t deliver the message to any bound queue. > [!IMPORTANT] A successful publish operation confirms that Anypoint MQ accepted the message for the > exchange. It doesn’t confirm that a routing rule matched or that a bound queue received the > message. If no bound queue receives the message, redelivery and dead-letter queue (DLQ) settings > configured on queues don’t apply because the message never enters a queue. To create a message routing rule, use a `curl` command like this: ```bash curl -X PUT "https://anypoint.mulesoft.com/mq/admin/api/v1/organizations//environments//regions//bindings/exchanges/purchases/queues/premiumPurchases/rules/routing" \ --header 'Authorization: bearer ' \ --header 'Content-Type: application/json' \ --data-raw '{ "routingRules" : [{ "propertyName" : "itemCategory", "propertyType" : "STRING", "matcherType" : "EQ", "value" : "premium" }] }' ``` This message routing rule routes any message published to the `purchases` exchange that includes a property or header with the name `itemCategory` and the value `premium` to the `premiumPurchases` queue. To change an existing routing rule, submit another `PUT` request with the new message routing rule configuration. A `PUT` request replaces the existing message routing rule on the binding with the new rule. Any changes or additions to a message routing rule can take up to 15 minutes to take effect. For information about: - Supported payload for `/rules/routing`, see this endpoint in the [Anypoint MQ Admin API](https://dev-portal.mulesoft.com/apis/anypoint-mq-admin.html). - Publishing a message with routing properties, see [Send a Message with Routing Properties](#send-message-routing). - Message routing rule requirements, see [Requirements and Restrictions](https://docs.mulesoft.com/mq/mq-routing-rules#intelligent-routing-restrictions). ### Enable or Disable Failover on an Existing Standard Queue When you enable failover for a queue, Anypoint MQ automatically creates a fallback queue in a [fallback region](https://docs.mulesoft.com/mq/mq-failover#primary-fallback-regions). If a Mule app can’t reach an Anypoint MQ server in a region, it switches to the fallback queue to publish and consume messages. For information about situations that can cause a region to be considered unavailable, see [Region Unavailability](https://docs.mulesoft.com/mq/mq-failover#region-unavailability). > [!IMPORTANT] You must restart all applications consuming from or publishing to the queue after > enabling or disabling failover. Use this `curl` command to enable failover for an existing standard queue: ```bash curl -X PUT 'https://anypoint.mulesoft.com/mq/admin/api/v1/organizations//environments//regions//destinations/queues//fallback' \ -H 'Authorization: bearer ' \ -H 'Content-Type: application/json' \ -d '{ "fallbackEnabled" : true }' ``` Use this `curl` command to disable failover for an existing standard queue: ```bash curl -X PUT 'https://anypoint.mulesoft.com/mq/admin/api/v1/organizations//environments//regions//destinations/queues//fallback' \ -H 'Authorization: bearer ' \ -H 'Content-Type: application/json' \ -d '{ "fallbackEnabled" : false }' ``` ### Retrieve Queue Configuration When you retrieve information about all destinations or a single queue, the response includes the failover configuration. Use this `curl` command to get the list of destinations: ```bash curl -X GET 'https://anypoint.mulesoft.com/mq/admin/api/v1/organizations//environments//regions//destinations' \ -H 'Authorization: bearer ' ``` Use this `curl` command to get details about a specific queue: ```bash curl -X GET 'https://anypoint.mulesoft.com/mq/admin/api/v1/organizations//environments//regions//destinations/queues/' \ -H 'Authorization: bearer ' ``` The response from these commands includes output similar to this: Primary Queue ```json [ { "encrypted" : true, "type" : "queue", "queueId" : "00-test", "fifo" : false, ... "isFallback" : false, (1) "fallbackConfig" : { "enabled" : true, (2) "linkedQueueName" : "00-test_fb", (3) "linkedQueueRegion" : "us-west-2" (4) } }, ] ```
1This queue is a primary queue.
2Failover is enabled for this queue.
3The fallback queue for this queue is 00-test_fb. If the primary region goes down, apps publish and consume from this queue.
4The fallback region for this queue is us-west-2.
Fallback Queue ```json [ { "encrypted" : true, "type" : "queue", "queueId" : "test_fb", "fifo" : false, ... "isFallback" : true, (1) "fallbackConfig" : { "enabled" : true, (2) "linkedQueueName" : "test", (3) "linkedQueueRegion" : "ca-central-1" (4) } }, ] ```
1This queue is a fallback queue.
2Failover is enabled. If the primary region goes down, apps publish and consume from this queue.
3The primary queue that is linked to this fallback queue is test.
4The region for the primary queue that is linked to this fallback queue is ca-central-1.
Standard Queue Without Failover Configured The response includes `"isFallback" : false` and doesn’t include `fallbackConfig`. ```json [ { "encrypted" : true, "type" : "queue", "queueId" : "hello1", "fifo" : false, ... "isFallback" : false (1) }, ] ```
1This queue is a primary queue.
FIFO Queue The response doesn’t include `fallbackConfig` because FIFO queues don’t support failover. ```json { "encrypted" : true, "type" : "queue", "queueId" : "hello1", "fifo" : true, (1) ... "isFallback" : false }, ] ```
1This queue is a FIFO queue, which doesn’t support failover.
Exchange The response doesn’t include `fallbackConfig` because exchanges don’t support failover. ```json [ { "encrypted" : true, "type" : "exchange", (1) "exchangeId" : "hello1" } ] ```
1This queue is a message exchange, which doesn’t support failover.
## Anypoint MQ Broker API The [Anypoint MQ Broker API](https://dev-portal.mulesoft.com/apis/anypoint-mq-broker.html) enables clients to publish, consume, route, and acknowledge messages from queues and message exchanges. You can get the organization ID and environment ID in the `payload.txt` file that Anypoint Platform creates for any auditable action in MQ. See [Anypoint MQ Audit Logging](https://docs.mulesoft.com/access-management/audit-logging#to-query-audit-logging-for-anypoint-mq). These examples use the Anypoint MQ Broker API to publish and consume messages and to test Anypoint MQ from the command line using `curl`. - [Get the Broker Bearer Token to Use With Anypoint MQ Broker API](#get-broker-token) - [Send a Message](#send-messages-api) - [Send a Message with Routing Properties](#send-message-routing) - [Retrieve a Message](#retrieve-message-api) For the regions where Anypoint MQ and FIFO are available, see [Anypoint MQ Regions](https://docs.mulesoft.com/mq/mq-faq#mq-regions). ### Send a Message This `curl` command publishes a message: ```bash curl -X PUT "https://mq-us-east-1.anypoint.mulesoft.com/api/v1/organizations//environments//destinations/postmanExchange/messages/552" \ -H "Content-Type: application/json" \ -H "Authorization: bearer " \ -H "Cache-Control: no-cache" \ -d '{ "properties": { "userDefinedHeader": "User defined stuff", "anotherUserDefinedHeader": "Random stuff" }, "body": "This is a message payload" }' ``` ### Send a Message with Routing Properties Anypoint MQ evaluates the configured message routing rules against all `headers` and `properties` attributes in the published messages. This `curl` command publishes a message with the value of the `itemCategory` property as `premium`. The message routing rule on the `purchases` exchange binding (set up in [Create or Change Message Routing Rules](#routing-rules-api)) routes the message to the `premiumPurchases` queue. ```bash curl -X PUT "https://mq-us-east-1.anypoint.mulesoft.com/api/v1/organizations//environments//destinations/postmanExchange/messages/552" \ -H "Content-Type: application/json" \ -H "Authorization: bearer " \ -H "Cache-Control: no-cache" \ -d '{ \ "properties": { "itemCategory": "premium", }, "headers": { "itemSize": "large" }, "body": "This is a message payload" }' ``` For information about the message routing rule requirements, see [Requirements and Restrictions](https://docs.mulesoft.com/mq/mq-routing-rules#intelligent-routing-restrictions). ### Retrieve a Message This `curl` command gets a message: ```bash curl -X GET "https://mq-us-east-1.anypoint.mulesoft.com/api/v1/organizations//environments//destinations/postmanQueue/messages?pollingTime=10000&batchSize=1&lockTtl=10000" \ -H "Authorization: bearer " \ -H "Cache-Control: no-cache" ``` You can control whether to show the message payload in the response using the `payloadVisibility` query parameter. This parameter is useful when retrieving large payloads. The `payloadVisibility` parameter takes these options: - `full`: Shows the message payload in the response. This option is the default. - `none`: Hides the message payload in the response. - `conditional`: Hides the message payload if the payload size is larger than 1 MB. If the payload is hidden because `payloadVisibility` is set to `none` or `conditional`, the response includes `payloadHidden=true` in the message header. This `curl` command gets a message and payload, displaying the payload only if the payload size is smaller than 1 MB: ```json curl -X GET "https://mq-us-east-1.anypoint.mulesoft.com/api/v1/organizations//environments//destinations/postmanQueue/messages?pollingTime=10000&batchSize=1&lockTtl=10000&payloadVisibility=conditional" \ -H "Authorization: bearer " \ -H "Cache-Control: no-cache" ``` ## Anypoint MQ Stats API The Anypoint MQ Stats API enables you to get statistics and metrics for queues and message exchanges. You can use the [Anypoint MQ Stats API](https://dev-portal.mulesoft.com/apis/anypoint-mq-stats.html) to perform statistical analysis of queue performance. Use the Stats API to retrieve: - [Near real-time statistics for queues](#get-queue-stats) - Number of messages currently in a queue - [Historical statistics for queues](#historical-stats-queue) - [Historical statistics for message exchanges](#historical-stats-exchange) For usage metrics, see [Retrieve Usage Metrics with the Anypoint Usage API](https://docs.mulesoft.com/mq/mq-usage#anypoint-usage-api). > [!NOTE] The Anypoint MQ Stats API limits retrieving stats for the > [`/organizations/{ORGANIZATION_ID}`](https://dev-portal.mulesoft.com/apis/anypoint-mq-stats.html) > and > [`/organizations/{ORGANIZATION_ID}/environments/{ENVIRONMENT_ID}`](https://dev-portal.mulesoft.com/apis/anypoint-mq-stats.html) > endpoints to 10 transactions per minute (TPM). > > If the requests exceed this limit, the Anypoint MQ Stats API returns an HTTP 429 status code. > > For all other [Anypoint MQ Stats API](https://dev-portal.mulesoft.com/apis/anypoint-mq-stats.html) > endpoints, the limit is 200 transactions per minute. For more information, see the [Anypoint MQ Stats API](https://dev-portal.mulesoft.com/apis/anypoint-mq-stats.html) in the MuleSoft developer portal. > [!IMPORTANT] The query parameters must be URL-encoded to preserve their values. For example, you > must URL-encode a `startDate` of `2024-07-11T17:51:54.000Z` to `2024-07-11T17%3A51%3A54.000Z` > before sending it in the query. ### Metrics for Queues and Exchanges Use the Anypoint MQ Stats API to get these metrics for queues and exchanges: - [Get Current Statistics for Queues](#get-queue-stats) - [Get Historical Statistics for a Queue](#historical-stats-queue) - [Get Historical Statistics for Exchanges](#historical-stats-exchange) #### Get Current Statistics for Queues You can get a snapshot of the number of messages in the queue and how many are in-flight. See [Anypoint MQ Glossary](https://docs.mulesoft.com/mq/mq-glossary) for a definition of in-flight messages. The data updates in almost real-time. Stats API responses and message status changes include up to 60 seconds of inconsistency due to internal post-processing activities. Message status changes include from in-queue to in-flight, from in-flight to in-queue, and from in-flight to deleted. For this reason, don’t use the Stats API for syncing processing actions, such as checking if the queue is empty. The Stats API can fetch statistics for multiple queues and returns a comma-separated list. `/queues?destinationIds={queue1},{queue2}` **Sample Request and Response:** Use this `curl` command to get current statistics for a queue: ```bash curl -X GET "https://anypoint.mulesoft.com/mq/stats/api/v1/organizations//environments//regions/REGION_ID/queues?destinationIds=DESTINATION_ID" \ -H "Authorization: bearer " \ -H "Cache-Control: no-cache" ``` This command returns output similar to: ```json { "destination": "95bgpyxYsVyFE", "messages": 0, "inflightMessages": 0 } ``` #### Get Historical Statistics for a Queue Use this API to fetch historical statistics for a queue. Statistics don’t get updated in real-time, and there is an approximate latency of five to ten minutes before data is published. The retention period of historical data is 15 months. To limit the volume of data, Anypoint MQ stores historical data at reduced levels of granularity, based on the period:
Time Series (Period)Retention Period

Fewer than 60 seconds

3 hours

1 minute

15 days

5 minutes

63 days

1 hour

15 months

`/queues/{queueId}?startDate=…​&endDate=…​&period=…​` **Sample Request and Response:** Use this `curl` command to get historical statistics for a queue: ```bash curl -X GET "https://anypoint.mulesoft.com/mq/stats/api/v1/organizations//environments//regions/REGION_URL/queues/95bgpyxYsVyFE?startDate=Thursday%2C%208%20Nov%202024%2004%3A49%3A37%20GMT%26endDate%3DSun%2C%2011%20Nov%202024%2004%3A60%3A44%20GMT%26period%3D600" \ -H "Authorization: bearer " \ -H "Cache-Control: no-cache" ``` This command returns output similar to: ```json { "destination": "95bgpyxYsVyFE", "messages": [ { "date": "2024-11-08T04:59:37.000+0000", "value": 0 }, { "date": "2024-11-08T05:09:37.000+0000", "value": 0 } ] } ``` The duration is an integer and is the granularity of data points in seconds. #### Get Historical Statistics for Exchanges Retention policies are the same as in the previous [Get Historical Statistics for a Queue](#historical-stats-queue) section. `/exchanges/{exchangeId}?startDate=…​&endDate=…​&period=…​` **Sample Request and Response:** Use this `curl` command to get historical statistics for an exchange: ```bash curl -X GET "https://anypoint.mulesoft.com/mq/stats/api/v1/organizations//environments//regions/REGION_URL/exchanges/exchange-test?startDate=Wed%2C%2014%20Nov%202024%2021%3A53%3A08%20GMT&endDate=Wed%2C%2014%20Nov%202024%2022%3A53%3A08%20GMT&period%3D600" \ -H "Authorization: bearer " \ -H "Cache-Control: no-cache" ``` This command returns output similar to: ```json { "destination": "exchange-test", "messagesPublished": [ { "date": "2024-11-14T21:59:08.000+0000", "value": 0 } ] } ``` The period is an integer and is the granularity of data points in seconds. ### Example: Anypoint MQ Stats API > [!NOTE] To access the Anypoint MQ Stats API, you must first authenticate using the > [Access Management API](https://dev-portal.mulesoft.com/apis/access-management.html). These statistics are provided: - `messagesVisible` The number of messages that can be retrieved from a queue. - `messagesSent` The number of messages added to a queue. - `messagesReceived` The number of messages received in a queue. - `messagesAcked` The number of acknowledged messages, including any messages deleted using the **Anypoint Platform** > **MQ** user interface. Example request to list statistics for July 26 to July 28, 2024: ```bash curl -X GET "https://anypoint.mulesoft.com/mq/stats/api/v1/organizations//environments//regions/REGION_URL/queues/randomQueue/?startDate=Thu%2C%2026%20Jul%202024%2000%3A00%3A00%20GMT&endDate=Sat%2C%2028%20Jul%202024%2020%3A00%3A00%20GMT&period%3D600" \ -H "authorization: Bearer " \ -H "cache-control: no-cache" ``` This command returns output similar to: ```json { "destination": "myDestination", "messages": [ { "date": "2024-07-26T00:00:00.000+0000", "value": 2126 }, { "date": "2024-07-27T00:00:00.000+0000", "value": 2126 }, { "date": "2024-07-28T00:00:00.000+0000", "value": 587 } ], "inflightMessages": [ { "date": "2024-07-26T00:00:00.000+0000", "value": 0 }, { "date": "2024-07-27T00:00:00.000+0000", "value": 0 }, { "date": "2024-07-28T00:00:00.000+0000", "value": 0 } ], "messagesVisible": [ { "date": "2024-07-26T00:00:00.000+0000", "value": 2126 }, { "date": "2024-07-27T00:00:00.000+0000", "value": 2126 }, { "date": "2024-07-28T00:00:00.000+0000", "value": 587 } ], "messagesSent": [ { "date": "2024-07-26T00:00:00.000+0000", "value": 0 }, { "date": "2024-07-27T00:00:00.000+0000", "value": 0 }, { "date": "2024-07-28T00:00:00.000+0000", "value": 0 } ], "messagesReceived": [ { "date": "2024-07-26T00:00:00.000+0000", "value": 0 }, { "date": "2024-07-27T00:00:00.000+0000", "value": 0 }, { "date": "2024-07-28T00:00:00.000+0000", "value": 0 } ], "messagesAcked": [ { "date": "2024-07-26T00:00:00.000+0000", "value": 0 }, { "date": "2024-07-27T00:00:00.000+0000", "value": 0 }, { "date": "2024-07-28T00:00:00.000+0000", "value": 0 } ] } ``` ## Create Queues and Exchanges with Groovy To create queues and exchanges programatically, you can use a language such as groovy. This example consists of the `cloudhub.properties` file in which you list the queues and exchanges to create, and a script file that references the properties file. ### Date Format Anypoint MQ lets you specify start and end dates for the Stats API in standard ISO 8601 format. For example: `2018-10-23T13:00:00Z` ### Invoke a Command After modifying the properties file for access to your Anypoint Platform account, use this command to start the script file: `groovy .groovy` ### Configure a Properties File This example properties file defines the access credentials, organization ID, environment ID, region ID, and the names of the queues and exchanges to create: ```text username="" password="" organizationID="ORG_ID" environmentID { development="DEVELOPMENT_ENV_ID" qa="QA_ENV_ID" staging="STAGING_ENV_ID" production="PRODUCTION_ENV_ID" } regionID="REGION_URL" queues=[ "Queue1", "Queue2", "QueueN", ] exchanges=[ "Exchange1", "Exchange2", "ExchangeN" ] ``` For the regions where Anypoint MQ and FIFO queues are available, see [Anypoint MQ Regions](https://docs.mulesoft.com/mq/mq-faq#mq-regions). ### Create a Script File This example script creates the queues and exchanges listed in the properties file: ```groovy package guru.oso.mule @Grab(group = 'org.apache.httpcomponents', module = 'httpclient', version = '4.5.3') import groovy.json.JsonBuilder import groovy.json.JsonSlurper import org.apache.http.client.methods.HttpGet import org.apache.http.client.methods.HttpPost import org.apache.http.client.methods.HttpPut import org.apache.http.entity.StringEntity import org.apache.http.impl.client.HttpClientBuilder class AnypointMQAdminClient { static String HOST = "https://anypoint.mulesoft.com" static void main(String[] args) { def props if (args) { props = new ConfigSlurper().parse(new File(args[0]).toURI().toURL()) } else { props = new ConfigSlurper().parse(new File("cloudhub.properties").toURI().toURL()) } def ENV_ID = props.environmentID.production def token = authenticate(props.username, props.password) retrieveDestinations(props, token, ENV_ID) } static authenticate(String username, String password) { // build JSON def map = [:] map["username"] = username map["password"] = password def jsonBody = new JsonBuilder(map).toString() // build HTTP POST def url = HOST + '/accounts/login' def post = new HttpPost(url) post.addHeader("Content-Type", "application/json") post.setEntity(new StringEntity(jsonBody)) // execute def client = HttpClientBuilder.create().build() def response = client.execute(post) // read and print response def bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())) def jsonResponse = bufferedReader.getText() println "Response: \n" + jsonResponse // parse and return token def slurper = new JsonSlurper() def resultMap = slurper.parseText(jsonResponse) return resultMap["access_token"] } static retrieveDestinations(ConfigObject props, String token, String ENV_ID) { def ORG_ID = props.organizationID def REGION_URL = props.regionID // build HTTP GET def getDestinationsURL = HOST + '/mq/admin/api/v1/organizations/' + ORG_ID + '/environments/' + ENV_ID + '/regions/' + REGION_URL + '/destinations' def getDestinations = new HttpGet(getDestinationsURL) // set token getDestinations.setHeader("Authorization", "Bearer " + token) // execute def client = HttpClientBuilder.create().build() def response = client.execute(getDestinations) // parse and print results def bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())) def jsonResponse = bufferedReader.getText() println "Response: \n" + jsonResponse } static retrieveQueue(ConfigObject props, String token, String ENV_ID, String QUEUE_ID) { def ORG_ID = props.organizationID def REGION_URL = props.regionID // build HTTP GET def getQueueURL = HOST + '/mq/admin/api/v1/organizations/' + ORG_ID + '/environments/' + ENV_ID + '/regions/' + REGION_URL + '/destinations/queues/' + QUEUE_ID def getQueue = new HttpGet(getQueueURL) // set token getQueue.addHeader("Authorization", "Bearer " + token) // execute def client = HttpClientBuilder.create().build() def response = client.execute(getQueue) // parse and print results def bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())) def jsonResponse = bufferedReader.getText() println "Response: \n" + jsonResponse } static createQueues(ConfigObject props, String token, String ENV_ID) { def ORG_ID = props.organizationID def REGION_URL = props.regionID def queues = props.queues queues.each { QUEUE_ID -> def putQueueURL = HOST + '/mq/admin/api/v1/organizations/' + ORG_ID + '/environments/' + ENV_ID + '/regions/' + REGION_URL + '/destinations/queues/' + QUEUE_ID def putQueue = new HttpPut(putQueueURL) putQueue.addHeader("Content-Type", "application/json") putQueue.addHeader("Authorization", "Bearer " + token) def queueMap = [:] queueMap["defaultTtl"] = 604800000 queueMap["defaultLockTtl"] = 120000 queueMap["encrypted"] = false queueMap["fifo"] = false def putQueueJSONBody = new JsonBuilder(queueMap).toString() putQueue.setEntity(new StringEntity(putQueueJSONBody)) def client = HttpClientBuilder.create().build() def response = client.execute(putQueue) def bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())) def jsonResponse = bufferedReader.getText() println "Response: \n" + jsonResponse } } static createExchanges(ConfigObject props, String token, String ENV_ID) { def ORG_ID = props.organizationID def REGION_URL = props.regionID def exchanges = props.exchanges exchanges.each { exchangeID -> def putExchangeURL = HOST + '/mq/admin/api/v1/organizations/' + ORG_ID + '/environments/' + ENV_ID + '/regions/' + REGION_URL + '/destinations/exchanges/' + EXCHANGE_ID def putExchange = new HttpPut(putExchangeURL) putExchange.addHeader("Content-Type", "application/json") putExchange.addHeader("Authorization", "Bearer " + token) def exchangeMap = [:] exchangeMap["encrypted"] = false def putExchangeJSONBody = new JsonBuilder(exchangeMap).toString() putExchange.setEntity(new StringEntity(putExchangeJSONBody)) def client = HttpClientBuilder.create().build() def response = client.execute(putExchange) def bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())) def jsonResponse = bufferedReader.getText() println "Response: \n" + jsonResponse } } } ``` ## Test Anypoint MQ from Postman, Studio, and a Browser This example enables you to test Anypoint MQ from Postman, Anypoint Studio, and a browser: - [Postman](#postsetup) - [Anypoint Studio](#studiosetup) - [Browser](#browsersetup) ### Set Up Postman The [Postman](https://www.postman.com/) app provides a platform for accessing the Anypoint MQ APIs. After downloading and installing Postman, supply this information to create an environment: - ORG\_ID - ENV\_ID - Bearer (Authentication) Token - Host ID (from Anypoint Platform/Anypoint MQ) - Client ID (from Anypoint Platform/Anypoint MQ) - Client Secret (from Anypoint Platform/Anypoint MQ) - Queue name (you can set this queue name in Postman) After you authorize access to an Anypoint MQ API, you can then publish a message, consume the message, and get the lock ID from the returned information in the body. For example, this information is returned from the consume (GET) command: ```json { "properties": { "anotherUserDefinedHeader": "Random stuff", "userDefinedHeader": "User defined stuff" }, "headers": { "messageId": "514", "lockId": "", "created": "Tue, 23 Oct 2018 21:17:57 GMT", "deliveryCount": "2" }, ... } ``` After you have the lock ID, you can add it to your Postman environment to facilitate future requests. ### Set Up Studio for API Access Anypoint Studio enables you to create a Mule app that uses the Anypoint MQ connector. This section summarizes the steps. You can set up a Studio project with: - An HTTP connector: - Host `0.0.0.0` - Port `8081` - Path in the properties menu set to `/mq/{messageId}`. - Anypoint MQ connector with the client ID and client secret from **Anypoint Platform** > **MQ**, and the **Destination** set to the queue you created in Postman. - Logger with **Message** set to the `\#[payload]` value. 1. Right-click the project name in the **Package Explorer** window and click **Run As > Mule Application**. Ensure that the Console messages end with the `DEPLOYED` value. 2. In Postman, publish a new message. #### Use a Browser to Access After you set up an HTTP Listener in Studio, browse to the address `0.0.0.0:8081`. The browser displays the message sent by Postman, which the Anypoint MQ connector received, and the HTTP connector sent to the browser. ## Download Anypoint MQ APIs from Exchange To download the Anypoint MQ APIs from Exchange, click **Download** and select the format to download: RAML, OAS, or as a connector file for Mule 4. ![Download option for Anypoint MQ Admin API in Exchange](/mulesoft/current/en-us/mq/_images/mq-exchange-download.png) ## See Also - [Anypoint MQ FAQ](https://docs.mulesoft.com/mq/mq-faq) - [Anypoint MQ Admin API](https://dev-portal.mulesoft.com/apis/anypoint-mq-admin.html) - [Anypoint MQ Broker API](https://dev-portal.mulesoft.com/apis/anypoint-mq-broker.html) - [Anypoint MQ Stats API](https://dev-portal.mulesoft.com/apis/anypoint-mq-stats.html) - [Route Messages by Configuring Rules on Message Exchanges](https://docs.mulesoft.com/mq/mq-routing-rules) --- product: MQ --- # Configuring and Using Queues > For the full documentation index, see: https://docs.mulesoft.com/llms.txt 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. Standard queues provide "at least once" message-delivery reliability. Due to the highly distributed architecture, Anypoint MQ occasionally delivers messages more than once. You can enable failover for standard queues. For information, see [Configuring Cross-Region Failover for Standard Queues](https://docs.mulesoft.com/mq/mq-failover). - 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](#fifoqueues). Anypoint MQ supports 10 in-flight messages per message group in a FIFO queue. Anypoint MQ doesn’t limit the number of message groups in a FIFO queue. FIFO queues provide "exactly once" message-delivery reliability. Anypoint MQ delivers each message to only one consumer. You can assign either standard or FIFO queue type as a dead-letter queue (DLQ). See [Dead Letter Queues](#dead-letter-queues). Standard queues can be bound to a [_message exchange_](https://docs.mulesoft.com/mq/mq-exchanges), enabling you to send messages to multiple queues. You can filter queues by type in the **Destinations** page: ![Destinations page showing filter options for message queue destinations](/mulesoft/current/en-us/mq/_images/mq-filters.png) ## Before You Begin Before using Anypoint MQ, you must create an environment and give users Anypoint MQ access permissions. See [Set Up the Environment and Access Permissions](https://docs.mulesoft.com/mq/mq-access-management). ## Create a Queue To create a standard queue or FIFO queue: 1. Sign in to Anypoint Platform and click **MQ** in the navigation menu. 2. Click **Destinations**. 3. Click the **Add** icon to display the menu: ![Destinations page showing the Add icon to add a queue](/mulesoft/current/en-us/mq/_images/mq-blue-create.png) 4. Select **Queue** or **FIFO Queue**. For **Exchange**, see [Sending Messages to Multiple Queues Using Message Exchanges](https://docs.mulesoft.com/mq/mq-exchanges). 5. Complete the fields in **Create Queue** or **Create FIFO Queue**: ![Create Queue dialog showing the default queue settings](/mulesoft/current/en-us/mq/_images/mq-create-queues.png) - **ID** specifies the queue name. Queue names can contain up to 127 alphanumeric (a-z, A-Z, 0-9) and punctuation (. -) characters. They can’t 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. If you change the message TTL for a queue, the new TTL value applies to any messages in the queue and all new messages added to the queue. - **Default Acknowledgment Timeout** 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 acknowledgement timeout is 12 hours. > [!IMPORTANT] For FIFO queues, set the timeout to a smaller value to prevent unacknowledged > messages from blocking delivery of other messages in the queue. - **Assign Default Delivery Delay** specifies how long to delay delivery for messages sent to the queue. The minimum delivery delay for a message is 0 seconds. The maximum is 15 minutes. When you send a message, you can override the default delivery delay. See [Delay Queue](https://docs.mulesoft.com/mq/mq-glossary#delay-queue). - **Encryption** encrypts all messages in the queue. See [Encrypted Queue](https://docs.mulesoft.com/mq/mq-glossary#encrypt-queue). Use encrypted queues for enhanced security. - **Assign a Dead Letter Queue** assigns the DLQ. The DLQ is a previously created queue to which to send undeliverable messages. See [Dead Letter Queues](#dead-letter-queues). - **Enable Cross-Region Failover** creates a [fallback queue](#fallback-queues) in the fallback region. See [Configuring Cross-Region Failover for Standard Queues](https://docs.mulesoft.com/mq/mq-failover). 6. Click **Create Queue**. Anypoint MQ creates the queue in the **Destinations** page and displays the queue information in the details pane: ![Destinations page showing the queue type, ID, and details label for the new queue](/mulesoft/current/en-us/mq/_images/mq-queue-details.png)
1Queue type displays the queue details pane.
2Queue ID displays the Queue Settings page.
3Queue details label displays the Queue Settings page.
## Send a Message to a Queue Message content can be text, CSV (comma-separated values), or JSON. The maximum size of a message is 10 MB. If the payload contains any format except text (such as CSV, HTML, JSON, and XML), Anypoint MQ converts it to a string before sending, which increases the payload size. This conversion might result in the payload exceeding the maximum payload size of 10 MB and causing a `Payload too large` error. To send a text message to a queue: 1. Select **Anypoint Platform** > **MQ** > **Destinations**. 2. Click the queue ID. 3. Click the **Message Sender** navigation menu: ![Message Sender option in the navigation menu](/mulesoft/current/en-us/mq/_images/mq-message-sender-page.png) - **Type** is **Text**, **CSV**, or **JSON**. See also [Send a CSV Message to a Queue](#send-a-csv-message-to-a-queue) and [Send a JSON Message to a Queue](#send-a-json-message-to-a-queue). - **Payload** contains the message payload text, such as `Hello Mules!`. - **Delivery Delay** (standard queue only) indicates the time to delay the message delivery (optional). If you specified **Assign Default Delivery Delay** on the standard queue, 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. See [Delayed delivery for messages](https://docs.mulesoft.com/mq/mq-glossary#delay-messages). - **Message Group ID** (FIFO queue only) specifies the group to which the message belongs. To preserve message order for an app, you might want to create a message group for each application to send messages: ![Message Sender page showing the Message Group ID field for FIFO queues](/mulesoft/current/en-us/mq/_images/mq-fifo-msg-groups.png) Message group IDs can contain up to 128 alphanumeric (a-z, A-Z, 0-9) and punctuation (! " # $ % & ' ( ) \* + , - . / : ; < = > ? @ \[ \] \\ ^ \_ \` { } \\| ~) characters. See [FIFO Queues and Message Groups](#fifo-queues-msg-groups). - **Add User Properties** configures user properties to send with the message. Toggle **Add User Properties**, specify the property name-value pairs to send, and click **Add Property**: ![Message Sender page showing the Add User Properties toggle selected](/mulesoft/current/en-us/mq/_images/mq-tutorial-message-sender-user-props.png) The **Message Sender** page shows added string properties in blue and number properties in gray. 4. 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 page. To see the number the messages in the queue: 1. Select **Anypoint Platform** > **MQ** > **Destinations**. 2. Click the queue type to display its details, including the number of messages in the queue: ![Details pane showing three messages in the queue](/mulesoft/current/en-us/mq/_images/mq-tutorial-msgs-in-queue.png) ## 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. Select **Anypoint Platform** > **MQ** > **Destinations**. 2. Click the queue ID. 3. Click the **Message Browser** navigation menu: ![Message Browser option in the navigation menu](/mulesoft/current/en-us/mq/_images/mq-tutorial-get-messages.png) 4. Specify the number of messages (1-500) to retrieve and the time to poll (1-3600 seconds). The specified number is the minimum number of messages to retrieve. For a FIFO queue, the Message Browser UI limits the number of messages you can retrieve to 10. 5. If you are retrieving messages from a FIFO queue, select the checkbox to acknowledge that viewing messages through the browser might cause other consumers of the queue to be blocked from accessing messages in the queue: ![Accept checkbox for retrieving messages from a FIFO queue](/mulesoft/current/en-us/mq/_images/mq-fifo-msg-browser.png) 6. Click **Get Messages**. 7. Click the message row to view the message payload in the details pane: ![Message Browser showing the selected message and the details pane showing the payload, and Return Messages, Delete, Full Screen, and Close icons](/mulesoft/current/en-us/mq/_images/mq-msg-browser-payload-details.png)
1Selected message.
2Message payload in the details pane.
3Return Messages icon returns all messages to the queue (for example, to enable other applications to read the messages).

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

If you leave the Message Browser page, messages automatically return to the queue.

4Delete icon.

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

5Full Screen icon displays the message payload in a separate window.
6Close icon closes the details pane.
\+ If the Message Browser displays `Message can’t be deleted` when you delete a message, the message time-to-live (TTL) has expired. - > [!NOTE] Payloads larger than one MB don’t appear in the Message Browser. You can retrieve them > with the Anypoint Broker API. See [Retrieve a Message](https://docs.mulesoft.com/mq/mq-apis#retrieve-message-api). \+ If user properties are configured in the **Message Sender** page or as part of the Publish operation in Anypoint MQ Connector, they appear in the details pane for the message: \+ image::mq-msg-browser-user-props.png\["Message Browser details pane showing user properties"\] ## Send a CSV Message to a Queue To send a CSV message to a queue: 1. Select **Anypoint Platform** > **MQ** > **Destinations**. 2. Click the queue ID. 3. Click the **Message Sender** navigation menu: ![Message Sender page showing a payload in CSV format](/mulesoft/current/en-us/mq/_images/mq-message-sender-csv.png) 4. Set the **Type** to **CSV**. 5. In the **Payload** field, enter this text: "dog", "fish", "parrot" For **Delivery Delay** (standard queue only) and **Message Group ID** (FIFO queue only), see [Send a Message to a Queue](#send-message-to-queue). 6. Click **Send**. 7. Click **Message Browser**, and then click **Get Messages**. 8. Click the message row to view the message payload in the details pane: ![Details pane showing the CSV message payload, Full Screen icon, and Close icon](/mulesoft/current/en-us/mq/_images/mq-msg-browser-payload-details-csv.png) > [!NOTE] Payloads larger than one MB don’t appear in the Message Browser. You can retrieve them > with the Anypoint Broker API. See [Retrieve a Message](https://docs.mulesoft.com/mq/mq-apis#retrieve-message-api). ## Send a JSON Message to a Queue To send a JSON message to a queue: 1. Select **Anypoint Platform** > **MQ** > **Destinations**. 2. Click the queue ID. 3. Click the **Message Sender** navigation menu: ![Message Sender page showing a payload in JSON format](/mulesoft/current/en-us/mq/_images/mq-message-sender-json.png) 4. Set the **Type** to **JSON**. 5. In the **Payload** field, enter this text: ```json { "animal that walks": "dog", "animal that swims": "fish", "animal that flies": "parrot" } ``` For **Delivery Delay** (standard queue only) and **Message Group ID** (FIFO queue only), see [Send a Message to a Queue](#send-message-to-queue). 6. Click **Send**. 7. Click **Message Browser**, and then click **Get Messages**. 8. Click the message row to view the message payload in the details pane: ![Details pane showing the JSON payload, Full Screen icon, and close details pane icon](/mulesoft/current/en-us/mq/_images/mq-msg-browser-payload-details-json.png) > [!NOTE] Payloads larger than one MB don’t appear in the Message Browser. You can retrieve them > with the Anypoint Broker API. See [Retrieve a Message](https://docs.mulesoft.com/mq/mq-apis#retrieve-message-api). ## Purge Messages from a Queue To purge all the messages in the queue: 1. Select **Anypoint Platform** > **MQ** > **Destinations**. 2. Click the queue type to display its details. 3. Click the **Purge Messages** icon in the details pane: ![Details pane showing the Purge Messages icon](/mulesoft/current/en-us/mq/_images/mq-purge-msgs-icon.png) 4. In the **Purge Messages** confirmation box, select the checkbox and click **Delete Messages** to verify that you want to purge all messages in the queue. ## Change Settings for a Queue Changing any setting for an existing queue affects only new messages. The new value doesn’t apply to messages that are already in the queue. 1. Select **Anypoint Platform** > **MQ** > **Destinations**. 2. Click the queue ID to display the **Queue Settings** page: ![Queue Settings page showing the default settings for a queue](/mulesoft/current/en-us/mq/_images/mq-queue-settings.png) 3. Change the queue settings and click **Save Changes**. ## 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. You can’t delete fallback queues. To delete a queue: 1. Select **Anypoint Platform** > **MQ** > **Destinations**. 2. Click the queue type to display its details. 3. Click the **Delete** icon in the details pane: ![Details pane for a queue showing the Delete icon](/mulesoft/current/en-us/mq/_images/mq-delete-queue-icon.png) 4. In the **Delete Queue** confirmation box, select the checkbox and click **Delete Queue** to verify that you want to delete the 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. Benefits FIFO queues: - Support delivery delay on all messages in the FIFO queue. If you change the delivery delay setting for a FIFO queue, Anypoint MQ applies the change retroactively to all messages in the queue. Anypoint MQ doesn’t support delayed delivery for individual messages in a FIFO queue. - Support multiple [message groups](#fifo-queues-msg-groups). - Provide encryption. Encrypting a FIFO queue does not affect the order or the contents of messages consumed. - Can be assigned a dead-letter queue (DLQ). However, Anypoint MQ can’t guarantee strict message ordering in this case. For information about using a DLQ with a FIFO queue, see [Dead-Letter Queues and FIFO Queues](#fifo-and-dlq). Limitations - FIFO queues are limited to 300 TPS (transactions per second). However, if you batch ten messages per read and write operation (maximum) using the API, FIFO queues can support up to 3,000 messages per second. Failed requests count against TPS. - You can’t bind FIFO queues to a message exchange. - In some configurations when using the IMMEDIATE acknowledgment mode in the Subscriber operation, FIFO queues don’t process messages in order. - Before using `prefetch` mode with FIFO queues, see [FIFO Queues and Prefetch Mode](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-listener#fifo-and-prefetch). To create a FIFO queue, see [Create a Queue](#create-queue). To determine if a queue is FIFO or standard (non-FIFO), view its details. For the regions in which Anypoint MQ and FIFO queues are available, see [Anypoint MQ Regions](https://docs.mulesoft.com/mq/mq-faq#mq-regions). For information about creating FIFO queues with the Admin API, see [Create a FIFO Queue Using the Admin API](https://docs.mulesoft.com/mq/mq-apis#fifo-queue-api). ### FIFO Queues and Message Groups Message groups enable multiple consumers to access messages in a FIFO queue. Only one consumer at a time can access messages in a message group. When a consumer is accessing a message group, other message groups in the FIFO queue are available to other consumers, reducing the chance that the FIFO queue is blocked. Anypoint MQ doesn’t limit the number of message groups in a FIFO queue. The FIFO queue processes messages in the message group one by one, in the order they were added. If the queue includes multiple message group IDs, it returns as many messages with the same message group ID as possible. > [!NOTE] FIFO queues do not support retrieving messages by message group ID. If a message doesn’t have an associated message group ID, the message is assigned to a default message group. If you require a single group of ordered messages, provide the same message group ID for messages sent to the FIFO queue. Anypoint MQ preserves message order within the message group, but not across different message groups. In addition, Anypoint MQ doesn’t guarantee that messages are processed at the same speed across groups. If multiple applications send messages associated with the same message group ID to a FIFO queue, Anypoint MQ stores the messages in the order they arrive. To preserve message order for an app, make sure that each app uses a specific message group ID to send messages. #### Process Messages in Message Groups in Order If a message in a message group is not acknowledged, it returns to the queue and Anypoint MQ continues processing the next message in the group. This behavior might not be desirable if a message in the group depends on a previous message. To ensure that the FIFO queue processes the messages in order: 1. Set the value of `maxConcurrency` on the flow to `1`, which forces the flow to process requests individually. 2. Set `subscriber-type` to `polling`, which controls message consumption. 3. Set the value of `fetchSize` to `1`, which ensures that only one message is buffered. ```xml ... ... ``` #### Use Message Groups to Process Messages in Parallel Anypoint MQ automatically processes messages from different message groups in parallel, maintaining the relative order of messages in the message groups. To process messages in message groups in parallel, and preserve the order of messages within the groups, configure multiple Subscriber flows in the app, each with the value of `maxConcurrency` set to `1`. #### Assign a Message Group ID to a Message To assign a message group ID to a message: 1. [Send a message to a queue](#send-message-to-queue). 2. In the **Message Sender** page, specify the message group to which the message belongs: ![Message Sender page showing the Message Group ID field for FIFO queues](/mulesoft/current/en-us/mq/_images/mq-fifo-msg-groups.png) #### Determine the Message Group a Message Belongs to To see which message group a message belongs to: 1. [Get a message from the queue](#get-a-message-from-a-queue). 2. In the **Message Browser** page, check the details pane for the message: ![Message Browser details pane showing the Message Group ID value](/mulesoft/current/en-us/mq/_images/mq-fifo-msg-group-id.png) ### 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](https://docs.mulesoft.com/mq/mq-faq#mq-regions) - In the same environment and owned by the same Anypoint Platform account. ### Dead-Letter Queues and FIFO Queues You can assign a DLQ to a FIFO queue as long as the DLQ is also a FIFO queue. However, if you use a DLQ with a FIFO queue, Anypoint MQ can’t guarantee that messages in a message group are processed in order. When a message is sent to a DLQ, it is no longer in the FIFO queue. Anypoint MQ processes subsequent messages and doesn’t preserve the message order. Therefore, if an application requires the order of messages to be strictly preserved and enforced, don’t assign a DLQ to a FIFO queue. ### Dead-Letter Queues and Fallback Queues Before you can enable failover on a standard queue that has a DLQ assigned, the DLQ must have failover enabled or previously had failover enabled. When you enable failover for a queue, Anypoint MQ creates the fallback queue, which persists even when failover is disabled. For more information, see [Configuring Cross-Region Failover for Standard Queues](https://docs.mulesoft.com/mq/mq-failover). ### 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 API requests. 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: ![Flowchart showing how messages are sent to a DLQ](/mulesoft/current/en-us/mq/_images/mq-dlq-flowchart.png) ### 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. See [FIFO Queues](#fifoqueues). To assign a DLQ to a queue: 1. [Create a queue](#create-queue). 2. Toggle **Assign a Dead Letter Queue** to **On**. These additional fields appear: ![DLQ fields in the Create Queue page](/mulesoft/current/en-us/mq/_images/mq-create-q-dlq.png) - **Dead Letter Queue Name** Choose a previously created queue name from the drop-down list. - **Delivery attempts before reroute** Optionally specify how many times Anypoint MQ attempts to deliver messages in the queue before rerouting the message to the configured DLQ. If not specified, the default value is 10 tries. This value ranges from 1 to 1000 attempts. > [!NOTE] This property is not related to **Max Redelivery Count** in the **Redelivery** tab > in Anypoint MQ Connector. `maxRedeliveryCount` specifies the maximum number of unsuccessful > attempts to redeliver a message to the flow before raising a `MULE:REDELIVERY_EXHAUSTED` > exception and preventing the flow from processing the received data. You can configure your > app to handle the exception by moving the message to a DLQ. > > For information about `maxRedeliveryCount`, see > [Configure a Redelivery Policy](https://docs.mulesoft.com/mule-runtime/latest/redelivery-policy). ### Recover Messages from a DLQ You can recover messages from the DLQ using the REST API to get the message from the queue and write the message to a new queue. See [Anypoint MQ Admin API](https://docs.mulesoft.com/mq/mq-apis#mq-admin-api). ### Determine Whether a Queue is a DLQ You can see whether a queue is a DLQ by viewing its details: ![Queue details pane showing DLQ status](/mulesoft/current/en-us/mq/_images/mq-queue-view-dlq.png) You can also view details of each queue from the REST Administration API, using the Get Queue REST endpoint. ```json { "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](https://docs.mulesoft.com/mq/mq-apis#mq-admin-api). ## Fallback Queues When you enable cross-region failover for a standard queue, Anypoint MQ automatically creates a fallback queue and assigns a non-configurable failover region to the queue. The name of the fallback queue is the primary queue name with the `_fb` suffix. For example, if the primary queue name is `myDemoQueue`, the fallback queue name is `myDemoQueue_fb`. If the primary queue has an assigned dead-letter queue (DLQ), you must enable failover for the DLQ before enabling failover for the primary queue. For information about cross-region failover and fallback queues, see [Configuring Cross-Region Failover for Standard Queues](https://docs.mulesoft.com/mq/mq-failover). ## See Also - [Anypoint MQ FAQ](https://docs.mulesoft.com/mq/mq-faq) - [Sending Messages to Multiple Queues Using Message Exchanges](https://docs.mulesoft.com/mq/mq-exchanges) - [Anypoint MQ Connectors](https://docs.mulesoft.com/mq/mq-connectors) --- product: MQ --- # Configuring Anypoint MQ > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Configure Anypoint MQ queues, exchanges, and connected apps to send and retrieve messages. - [Set Up the Environment and Access Permissions](https://docs.mulesoft.com/mq/mq-access-management) Use Access Management to create an environment and manage the roles of users who administer Anypoint MQ features in Anypoint Platform for your organization. - [Configuring and Using Queues](https://docs.mulesoft.com/mq/mq-queues) Create queues, FIFO queues, and dead-letter queues in Anypoint Platform. Send, receive, and purge messages from queues. - [Sending Messages to Multiple Queues Using Message Exchanges](https://docs.mulesoft.com/mq/mq-exchanges) Send messages to multiple standard or FIFO [queues](https://docs.mulesoft.com/mq/mq-queues) simultaneously by binding those queues to a message exchange. Route messages to specific queues that are bound to the message exchange by creating _intelligent message-routing rules_ on the bindings. - [Configuring Cross-Region Failover for Standard Queues](https://docs.mulesoft.com/mq/mq-failover) Enable cross-region failover so that if a Mule app can’t reach an Anypoint MQ server in a region, it switches to the fallback queue configured in the fallback region. - [Configuring Connected Apps](https://docs.mulesoft.com/mq/mq-connected-apps) Integrate external applications with Anypoint Platform by using Connected Apps to provide access to those applications without sharing your user credentials. - [Configuring Client Apps](https://docs.mulesoft.com/mq/mq-client-apps) Generate credentials to use for publishing and consuming from a queue when using Anypoint Connector for MQ (Anypoint MQ Connector) version 3.x or earlier. MuleSoft recommends that you use connected apps rather than client apps to generate credentials. For information, see [Configuring Connected Apps](https://docs.mulesoft.com/mq/mq-connected-apps). --- product: MQ --- # Configuring Client Apps > For the full documentation index, see: https://docs.mulesoft.com/llms.txt When using Anypoint Connector for MQ (Anypoint MQ Connector) version 3.x or earlier, you create a client app to generate credentials to use to publish and consume from a queue. MuleSoft recommends that you use connected apps rather than client apps to generate credentials. For information, see [Configuring Connected Apps](https://docs.mulesoft.com/mq/mq-connected-apps). When you create a client app, Anypoint MQ lists the client ID and client secret for the app. You use the client ID and client secret values when configuring Anypoint MQ Connector in a Mule app in Anypoint Studio. Don’t share the ID and secret pair with multiple apps. An app does not need to exist for you to register it with Anypoint MQ Connector. ## Create a Client App To create a client app: 1. Sign in to Anypoint Platform and click **MQ** in the navigation menu. 2. Click **Client Apps** in the navigation pane: ![Client Apps option and Add icon](/mulesoft/current/en-us/mq/_images/mq-tutorial-create-client-apps.png)
1Client Apps displays and creates client apps.
2Add icon adds a client app.
3. Click the **Add** icon (![](/mulesoft/current/en-us/mq/_images/icon-blue-plus.png)). 4. In the **Create Client App** window, enter the name of the client app, such as `DemoClientApp` and click **Save Changes**. 5. Click the client app name to view the client app ID and client secret values in the details pane: ![Client app name, and the Copy and Show buttons for the selected client app](/mulesoft/current/en-us/mq/_images/mq-tutorial-client-apps-detail.png)
1Client app name displays client app details.
2Copy buttons copy the client app ID or client secret value.
3Show displays the client secret value, which is obfuscated by default.
6. Click **Copy** to copy the client app ID or client secret value to your clipboard. 7. When you configure Anypoint MQ Connector in your Mule app, paste the client app ID and client secret values to the **Anypoint MQ Config** window in Studio: ![Anypoint MQ Config window showing the URL, Client App ID, and Client Secret fields](/mulesoft/current/en-us/mq/_images/mq-tutorial-studio7-mq-config.png) For more information, see [Tutorial: Create a Queue and Send Messages to It](https://docs.mulesoft.com/mq/mq-tutorial). ## Regenerate a Client Secret You might need to regenerate the client secret for a client app ID if your organization’s security policy requires that you change client secrets on a schedule. Another reason you might need to regenerate the client secret is to revoke access to a client ID by a specific consumer or publisher. In this case, you can regenerate the client secret in Anypoint MQ and reconfigure the secret in only those apps for which you want to allow access. To regenerate the client secret: 1. Sign in to Anypoint Platform and click **MQ** in the navigation menu. 2. Click **Client Apps** in the navigation pane. 3. Click the client app name to display the details pane. 4. Click **Regenerate Secret**: ![Regenerate Secret icon in the details pane](/mulesoft/current/en-us/mq/_images/mq-client-apps-regenerate.png) ## Delete a Client App To delete a client app: 1. Sign in to Anypoint Platform and click **MQ** in the navigation menu. 2. Click **Client Apps** in the navigation pane. 3. Click the client app name to display the details pane. 4. Click **Delete**: ![Delete icon in the details pane](/mulesoft/current/en-us/mq/_images/mq-client-apps-delete.png) ## See Also - [Anypoint MQ Connector Reference](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-connector-reference) - [Anypoint MQ FAQ](https://docs.mulesoft.com/mq/mq-faq) - [Configuring Connected Apps](https://docs.mulesoft.com/mq/mq-connected-apps) - [Anypoint MQ on Hyperforce](https://docs.mulesoft.com/mq/#mq-on-hyperforce) --- product: MQ --- # Configuring Connected Apps > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The Connected Apps feature enables you to integrate external applications with Anypoint Platform by providing access to those applications without sharing your user credentials. When you create a connected app, Access Management lists the client ID and client secret for the app. You use the client ID and client secret values when configuring Anypoint Connector for MQ (Anypoint MQ Connector) in a Mule app in Anypoint Studio. To use connected apps with Anypoint MQ, you must use Anypoint MQ Connector 4.x for Mule 4. For information about upgrading, see [Upgrading and Migrating Anypoint MQ Connector](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-connector-upgrade-migrate). If you are using Anypoint MQ Connector version 3.x or earlier, configure a client app instead. For information, see [Configuring Client Apps](https://docs.mulesoft.com/mq/mq-client-apps). For more information about connected apps, see [Connected Apps in Anypoint Platform](https://docs.mulesoft.com/access-management/connected-apps-overview) and [Anypoint Platform Connected Apps for Developers](https://docs.mulesoft.com/access-management/connected-apps-developers). ## Configure a Connected App in Access Management To create a connected app with Anypoint MQ scopes: 1. In Anypoint Platform, go to **Access Management**. 2. Click **Connected Apps** in the navigation pane. 3. Click **Create app**. ![Connected Apps navigation option and Create app button in Access Management](/mulesoft/current/en-us/mq/_images/mq-tutorial-create-connected-apps.png)
1Connected Apps menu option displays and creates connected apps.
2Create app button creates a connected app.
4. Specify a name, such as `DemoApp1` for the app. 5. Select **App acts on its own behalf (client credentials)**. 6. Click **Add Scopes**. Scopes are roles with associated permissions, which determine which actions the app can perform within an organization and environment. See [Anypoint MQ Scopes](#mq-scopes). ![Add Scopes window showing the scopes to add to Anypoint MQ connected apps](/mulesoft/current/en-us/mq/_images/mq-conn-apps-scopes.png) 7. In **Add Scopes** window: 1. Enter "MQ" in the **Filter scopes** field. 2. Select the Anypoint MQ scopes to apply and click **Next**. 3. Select business groups to apply the scopes to and click **Next**. 4. Select the environments to apply the scopes to and click **Next**. 5. Click **Add Scopes** or **Cancel** to cancel your changes. 8. Click **Save** or **Cancel** to cancel your changes. 9. When you configure the connector, click **Copy Id** and **Copy Secret** to copy the ID and secret for the app you just created: ![Connected Apps window](/mulesoft/current/en-us/mq/_images/mq-conn-apps-window.png) Use the client ID and client secret to get the access token required to authenticate with the Anypoint MQ API. 10. When you configure Anypoint MQ Connector in your Mule app, paste the client ID and client secret values in the **Anypoint MQ Config** window in Studio: ![Anypoint MQ Config window showing the URL, Client App ID, and Client Secret fields](/mulesoft/current/en-us/mq/_images/mq-tutorial-studio7-mq-config.png) Don’t share the ID and secret pair with multiple apps. For more information, see [Create and Connect a Mule 4 App to Anypoint MQ in Anypoint Studio 7](https://docs.mulesoft.com/mq/mq-tutorial#configure-mule-4-studio) in the Anypoint MQ tutorial. For information about getting the access token for connected apps, see the [Access Management API](https://dev-portal.mulesoft.com/apis/access-management.html). The `/authorize` endpoints in the Anypoint MQ Admin API and Anypoint MQ Broker API do not support connected apps. You can’t use tokens obtained from those endpoints to access a connected app. ## Configure a Connected App Using the API For information about configuring a connected app with the API, see [How to create connected apps using the API](https://help.salesforce.com/s/articleView?id=001115949&type=1). ## Anypoint MQ Scopes Anypoint MQ scopes apply to all destinations in the given organization and environment. The Anypoint MQ scopes are:
Scope in UIScope in APIDescription

Administer destinations

administer:destinations

  • View all destinations and each destination’s settings (ID, Type, Message TTL, and Message Lock Default TTL).

  • View In Queue message stats.

  • View In Flight message stats.

    • Create new queues, message exchanges, and bindings.

    • Edit existing queues, message exchanges, and bindings.

    • Purge messages from queues.

Clear destinations

clear:destinations

  • View all destinations and each destination’s settings (ID, Type, Message TTL, and Message Lock Default TTL).

  • View In Queue message stats.

  • View In Flight message stats.

Destination subscriber for given environment

subscribe:destinations

  • Consume messages from a destination.

  • Delete messages from a destination.

Destination publisher for given environment

publish:destinations

  • Send messages to a destination.

  • Update message TTL on a destination.

Manage clients

manage:clients

  • View all client apps, including client app IDs and client secrets for each client app.

  • Create client apps.

Read MQ stats

read:stats

View organization and environment statistics.

View clients

view:clients

View all client apps, including client app IDs and client secrets for each client app.

View destinations

view:destinations

  • View all destinations and each destination’s settings (ID, Type, Message TTL, and Message Lock Default TTL).

  • View In Queue message stats.

  • View In Flight message stats.

--- product: MQ --- # Configuring Cross-Region Failover for Standard Queues > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for Anypoint MQ (Anypoint MQ Connector) for Mule 4 version 4.0.7 provides failover capability for standard queues. When you enable failover for a queue, Anypoint MQ automatically creates a fallback queue in a [fallback region](#primary-fallback-regions). If a Mule app can’t reach an Anypoint MQ server in a region, it switches to the fallback queue to publish and consume messages. For information about situations that can cause a region to be considered unavailable, see [Region Unavailability](#region-unavailability). > [!IMPORTANT] This feature provides _resiliency_ by switching to a fallback queue in a fallback > region when the primary region is down. It doesn’t provide _data redundancy_ by replicating > messages across the primary and fallback queues. When the connector detects that the primary region is down, it: - Switches to the fallback queue to publish and consume new messages. - Periodically checks if the primary region is back up. When the connector detects that it can communicate with the primary region, it switches processing back to the primary queue. The consumer continues to read from the fallback queue until all messages in that queue are processed. The fallback queue inherits the settings of the primary queue, such as message TTL (time-to-live) and default acknowledgment timeout. The Anypoint MQ server manages fallback queues and regions; end users can’t configure them. You can disable failover, but you can’t delete the fallback queue. When you disable failover for a queue, apps can still consume any messages that remain in the fallback queue but can’t publish new messages to it. ## Failover Limitations and Considerations - Failover Support - This feature is not enabled by default. For information about enabling this feature in your app, see [Enable Failover in Your App](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-failover#enable-failover-feature). - Failover support requires Anypoint MQ Connector 4.0.7 or later. - Failover is supported for standard queues only. - Failover isn’t supported for message exchanges or FIFO queues. - Fallback Regions - Because MuleSoft Government Cloud includes only one region, it does not support failover. - Anypoint MQ is available in only one region in some countries. If failover is enabled for queues in those regions and the primary region goes down, data resides in a region outside the country until the primary region is available. For the list of fallback regions, see [Primary-Fallback Regions](#primary-fallback-regions). - Authentication If access management is unavailable when the connector switches to the fallback region, the connector might not be able to switch to the fallback region if it can’t validate the access token. - Anypoint MQ UI The **Message Sender** and **Message Browser** in the Anypoint MQ UI don’t support the failover feature. When you [send a message](https://docs.mulesoft.com/mq/mq-queues#send-message-to-queue) using the **Message Sender**, the message is published to the specified queue and appears in the **Message Browser**. However, if the primary region is down, the message is not forwarded to the fallback queue, so it doesn’t appear in the **Message Browser** for the fallback queue. - Performance and Billing The Consumer and Subscriber operations in Anypoint MQ Connector periodically check the fallback queue for new messages. Each request counts against your monthly [API request](https://docs.mulesoft.com/mq/mq-usage#api-requests) quota. These checks can also cause latency. Publishing to or consuming from the fallback queue might be slower than with the primary queue due to the checks and the expected network latency of processing from a queue in a different region. You can configure how frequently the connector checks the fallback queue. See [Configure the Frequency of Fallback Queue Checks](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-failover#configure-check-frequency). ## Before You Begin To use failover, you must first: - Upgrade Anypoint MQ Connector to 4.0.7 or later. For information, see [Upgrading and Migrating Anypoint MQ Connector](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-connector-upgrade-migrate). - Enable the failover feature in your app. For information, see [Enable Failover in Your App](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-failover#enable-failover-feature). ## Enable Failover for a New or Existing Queue Enabling cross-region failover creates a fallback queue in a [fallback region](#primary-fallback-regions). > [!NOTE] If either the primary or fallback region is unavailable, enabling failover via the > Anypoint MQ UI or REST API might not work. If the primary queue has an assigned dead-letter queue (DLQ), you must enable failover for the DLQ before enabling failover for the primary queue. To enable failover for a new or existing queue: 1. Sign in to Anypoint Platform and click **MQ** in the navigation menu. 2. Click **Destinations**. 3. Create a queue or modify an existing queue: - Create a queue - Modify an existing queue 1. Click the **Add** icon to display the menu: ![Destinations page showing the Add icon for adding a queue](/mulesoft/current/en-us/mq/_images/mq-blue-create.png) 2. Select **Queue**. Anypoint MQ supports failover for standard queues only. 3. Complete the fields in **Create Queue**. For information about queue settings, see [Create a Queue](https://docs.mulesoft.com/mq/mq-queues#create-a-queue). 4. Select **Enable Cross-Region Failover**: ![Create Queue dialog box showing the failover option selected](/mulesoft/current/en-us/mq/_images/mq-create-queues-failover.png) 5. Click **Create Queue**. Anypoint MQ creates the queue and also creates a fallback queue in the fallback region. The name of the fallback queue is the primary queue name with the `_fb` suffix. For example, if the primary queue name is `myDemoQueue`, the fallback queue name is `myDemoQueue_fb`. The Anypoint MQ server manages fallback queues and regions; end users can’t configure them. 6. Click the queue name. Anypoint MQ supports failover for standard queues only. 7. In the **Queue Settings** page, select **Enable Cross-Region Failover**: ![Queue Settings page showing the failover option selected](/mulesoft/current/en-us/mq/_images/mq-queue-settings-failover.png) 8. Click **Save Changes**. Anypoint MQ updates the queue settings and creates a fallback queue in the fallback region. The name of the fallback queue is the primary queue name with the `_fb` suffix. For example, if the primary queue name is `myDemoQueue`, the fallback queue name is `myDemoQueue_fb`. The Anypoint MQ server manages fallback queues and regions; end users can’t configure them. If you previously enabled failover for the queue, the fallback queue already exists and is reinstated. 9. Restart all applications consuming from or publishing to the queue. ## View Fallback Queue Details To view failover configuration for the primary and fallback queues, display the queue details: 1. Sign in to Anypoint Platform and click **MQ** in the navigation menu. 2. Click **Destinations**. 3. Click the queue type to display its details, including the failover configuration. - The queue details pane for the primary queue includes the fallback queue: ![Details pane for the primary queue showing the fallback queue and region](/mulesoft/current/en-us/mq/_images/mq-queue-details-primary-queue.png)
1Queue type displays the queue details pane for the primary queue.
2The name of the fallback queue is the primary queue name with the _fb suffix.
- The queue details pane for the fallback queue includes the primary queue: ![Details pane for the fallback queue showing the primary queue and region](/mulesoft/current/en-us/mq/_images/mq-queue-details-fallback-queue.png)
1Queue type displays the queue details pane for the fallback queue.

The fallback queue can’t be deleted.

2The name of the primary queue is the fallback queue name without the _fb suffix.
## Disable Failover for a Queue When you disable failover for a queue, apps can still consume any messages that remain in the queue but can’t send new messages to the queue. > [!IMPORTANT] When you disable failover for a queue, you must restart all applications that consume > from or send to the queue. When you re-enable failover, Anypoint MQ reinstates the same fallback queue. To process any messages that remain in the fallback queue after disabling failover, see [Process Messages Directly from the Fallback Queue](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-failover#consume-directly-fallback). To disable failover for a queue: 1. Sign in to Anypoint Platform and click **MQ** in the navigation menu. 2. Click **Destinations**. 3. Click the queue name. 4. In the **Queue Settings** page, deselect **Enable Cross-Region Failover** Anypoint MQ disables failover for the queue: ![Queue Settings page showing the failover option deselected](/mulesoft/current/en-us/mq/_images/mq-queue-settings-failover-disabled.png) 5. Click **Save Changes**. The primary queue details shows that failover is disabled: ![Details pane for the primary queue showing the fallback queue and failover status](/mulesoft/current/en-us/mq/_images/mq-queue-details-primary-queue-fallback-disabled.png) 6. Restart all applications consuming from or publishing to the queue. ## Primary-Fallback Regions
LocationPrimary Region NamePrimary RegionFallback Region NameFallback Region

US Control Plane

North America

US East (N. Virginia)

us-east-1

US East (Ohio)

us-east-2

US East (Ohio)

us-east-2

US West (Oregon)

us-west-2

US West (Oregon)**

us-west-2

Canada (Central)

ca-central-1

Canada (Central)*

ca-central-1

US East (N. Virginia)

us-east-1

Europe

Europe (Ireland)**

eu-west-1

UK (London)

eu-west-2

UK (London)**

eu-west-2

Europe (Ireland)

eu-west-1

APAC

Asia Pacific (Singapore)**

ap-southeast-1

Asia Pacific (Tokyo)

ap-northeast-1

Asia Pacific (Sydney)*

ap-southeast-2

Asia Pacific (Singapore)

ap-southeast-1

Asia Pacific (Tokyo)**

ap-northeast-1

Asia Pacific (Sydney)

ap-southeast-2

EU Control Plane

Europe

Europe (Frankfurt)**

eu-central-1

Europe (Ireland)

eu-west-1

Europe (Ireland)**

eu-west-1

Europe (Frankfurt)

eu-central-1

**\*** Because Anypoint MQ is available in only one region in this country, the fallback region is not in the same country as the primary region. **\***\* The fallback region for this region is not in the same country as the primary region. ## Region Unavailability The connector considers a region as unavailable in cases where the Anypoint MQ backend server is: - Down, resulting in HTTP 5xx (Server Error) status codes to the connector. - Up, but is slow or unresponsive. For example, the connector receives Timeout errors while making REST API calls to the backend server. - Available in some situations, but not others. For example, unresponsive for queues, but available for other usage, such as message exchanges. When the connector receives an HTTP 5xx or any server-side error, it temporarily marks the region as down for the specific queue and switches to the fallback queue. The connector periodically checks for new messages in the primary queue to determine if the primary region is back up. You can change the frequency of these checks. For information, see [Configure the Frequency of Fallback Queue Checks](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-failover#configure-check-frequency). ## See Also - [Configuring and Using Queues](https://docs.mulesoft.com/mq/mq-queues) - [Configuring Cross-Region Failover in Your App](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-failover) - [Anypoint MQ Connector 4.x for Mule 4](https://docs.mulesoft.com/anypoint-mq-connector/latest/) --- product: MQ --- # FAQ: Anypoint MQ > For the full documentation index, see: https://docs.mulesoft.com/llms.txt This document lists frequently asked questions about Anypoint MQ. **See Also:** [Anypoint MQ Connectors](https://docs.mulesoft.com/mq/mq-connectors), [REST APIs](https://docs.mulesoft.com/mq/mq-apis), [Release Notes](https://docs.mulesoft.com/release-notes/mq/mq-release-notes). ## Why is Anypoint MQ not shown in Anypoint Platform? Anypoint MQ is an integration add-on to your paid Anypoint Platform package or subscription and isn’t available in the trial edition of Anypoint Platform. To add Anypoint MQ to your package or subscription, contact your account team. After adding Anypoint MQ, wait one hour for Anypoint MQ to become available in Anypoint Platform. For information about Anypoint Integration packages, see [MuleSoft Anypoint Platform Pricing](https://www.mulesoft.com/anypoint-pricing). ## In which regions is Anypoint MQ available? Anypoint MQ standard and FIFO queues are available in these regions:
Control PlaneGeographic AreaRegionRegion Name

US Cloud

North America

US East (N. Virginia)

us-east-1

US East (Ohio)

us-east-2

US West (Oregon)

us-west-2

Canada (Montreal)

ca-central-1

Europe

Ireland (Dublin)

eu-west-1

UK (London)

eu-west-2

Asia Pacific

Singapore (Singapore)

ap-southeast-1

Australia (Sydney)

ap-southeast-2

Japan (Tokyo)

ap-northeast-1

EU Cloud

Europe

Germany (Frankfurt)

eu-central-1

Ireland (Dublin)

eu-west-1

MuleSoft Government Cloud

North America

US GovCloud (West)

us-gov-west-1

Canada Cloud

North America

Canada (Montreal)

ca-central-1 *

Japan Cloud

Asia Pacific

Japan (Tokyo)

ap-northeast-1 *

India Cloud

Asia Pacific

India (Mumbai)

ap-south-1 *

Australia Cloud

Asia Pacific

Australia (Sydney)

ap-southeast-2 *

United Kingdom Cloud

Europe

United Kingdom (London)

eu-west-2 *

**\*** You can’t access or configure some Anypoint MQ features, such as client apps and unencrypted queues. For information, see [Anypoint MQ on Hyperforce](https://docs.mulesoft.com/mq/#mq-on-hyperforce). ## How do I create and send messages into Anypoint MQ from Mule runtime? After you contact your account team to purchase and activate Anypoint MQ, you can use Anypoint Platform to create a queue or message exchange, and send messages to it. For more information, see the [Configuring and Using Queues](https://docs.mulesoft.com/mq/mq-queues) and [Sending Messages to Multiple Queues Using Message Exchanges](https://docs.mulesoft.com/mq/mq-exchanges). ## How does Anypoint MQ encrypt messages? Anypoint MQ uses in-flight HTTPS encryption with Transport Layer Security (TLS) 1.2 protocol to transport messages and doesn’t support the deprecated TLS versions 1.0 and 1.1. If you configure Anypoint MQ queues for encryption at rest, the payloads are encrypted with the AES-256 GCM algorithm on the server side. > [!NOTE] Anypoint MQ encrypts only the message body. Anypoint MQ does not encrypt the `headers` or > `properties` of messages sent to exchanges and queues. If your app requires an additional layer of encryption security, then you can encrypt the payloads yourself before publishing messages to Anypoint MQ. You must manage your encryption keys for both the message publishers and the consumers. ## Why do I see the message decrypted in the UI for my encrypted queues? When you have a queue encrypted, the messages are stored encrypted but they are decrypted when they are read. Encryption and decryption are automatic and transparent to the final user. There’s no option to disable the automatic decryption. If you need to encrypt the message so that the payload remains encrypted, manually encrypt the content. ## How can I send a Java Object as a message? The body of an Anypoint MQ message is sent as a string as part of a JSON message, thus any content that needs to be published should be serializable in a string format from which you can later deserialize. One way to do this is to serialize the Java object to its JSON representation using DataWeave, which can be serialized and deserialized from a string. Sending Java objects that don’t have a proper string serialization causes the message to be unreadable on the receiving end. ## Can I share messages or queues between regions? No, queues and message exchanges are unique to the region in which they were created and can’t share messages or queues between regions. Developers can manually create custom programs that load balance between regions, but Anypoint MQ itself does not provide multi-region support. The queues in each region are separate from those in other regions. You can name queues the same in each region, but queues can’t share messages across regions. ## How does Anypoint MQ pass a correlation ID between publisher and subscriber? Anypoint MQ doesn’t support propagating `correlationId` from a publisher to a subscriber in the same way that APIs propagate it from one layer to another. To pass an ID between publisher and subscriber, add a user property to send with the message. For information, see [Send a Message to a Queue](https://docs.mulesoft.com/mq/mq-queues#send-a-message-to-a-queue). For more information about correlation IDs, see [Total traceability with correlation IDs](https://blogs.mulesoft.com/dev-guides/how-to-tutorials/total-traceability/). ## How many messages can I fetch using the Anypoint MQ user interface? In **Anypoint Platform** > **MQ** > **Message Browser**, you can fetch up to 50 messages from a standard (non-FIFO) queue. For a FIFO queue, the Message Browser UI limits the number of messages you can retrieve to 10. The FIFO restriction exists because the FIFO queues are limited to 10 in-flight messages per message group. For more information about in-flight messages, see [How many in-flight messages can I have per queue?](#inflights) ## Why do I receive fewer messages than my batch size when retrieving messages with the Anypoint MQ REST API? Anypoint MQ is a highly distributed messaging system, so the results of an API call to receive messages are not guaranteed to be entirely representative of what is fully in the queue. Anypoint MQ operates in a best-effort case. For example, if there are 5 messages in a queue, the system returns anywhere from 0-5 messages in a single API call depending on what distributed subsystems are accessed by that request. Subsequent API calls retrieve more messages and if you keep making API requests to receive messages, then you get all of them. Normally in high throughput cases, repeated API calls happen extremely fast. The Anypoint MQ connector, for example, continuously polls the Anypoint MQ backend for new messages and from the user perspective, the messages are processed nearly instantly even though many API calls were used. ## In what order are messages in a standard (non-FIFO) queue? Standard queues attempt to preserve the order of messages, but strict order is not guaranteed. Because standard queues are designed to be scalable and distributed, they can’t guarantee that messages are received in the same order that they are sent. If message order is important, use a [FIFO queue](https://docs.mulesoft.com/mq/mq-queues#fifoqueues) or set Anypoint MQ Connector to the [Consume operation](#process-one-by-one). ## Can messages be larger than 10 MB? Anypoint MQ supports payloads up to 10 MB. If the payload contains any format except text (such as CSV, HTML, JSON, and XML), Anypoint MQ converts it to a string before sending, which increases the payload size. This conversion might result in the payload exceeding the maximum payload size of 10 MB and causing a `Payload too large` error. If a larger size is required, you can split the payload into multiple messages, or implement a claim check style service in which you store the payload in a file system or blob storage, and then put a pointer to the payload in the message so it can be downloaded later. However, you must manage access control to the blob storage for both the sender and receiver. You also need to consider that messages can be received unordered unless you use a FIFO queue. The **Message Browser** page displays the payload only if the payload size is smaller than 1 MB. If the payload size is 1 MB or larger, the **Message Browser** page displays an error. In this case, you can use the Anypoint MQ Broker API to display the message payload. See [Retrieve a Message](https://docs.mulesoft.com/mq/mq-apis#retrieve-message-api). ## Are message exchanges and queues unique and accessible only in their created environment? That is, how do we ensure message exchanges or queues created in one environment are not confused or connected to message exchanges or queues created in a different environment if they have the same name? You can have the same object name for queues and exchanges in different environments, but the client app ID and client secret values must be unique. You can’t access a production queue from a development environment if they don’t have the corresponding client app IDs. ## How can I restrict access to a queue or message exchange? You can use **Anypoint Platform** > **Access Management** > **Business Groups or Environments**. The queues and message exchanges created in a business group or environment are only visible to those with access to the business group or environment. Anypoint MQ access is controlled at the environment and business group levels, not per individual queue or message exchange. Permissions such as **Destination Publisher** and **Destination Subscriber** are granted at the environment level and apply to all destinations in that environment. There is no native mechanism to restrict access to a single queue or message exchange. ## Can I use Anypoint MQ on-premises? You can publish a message from an on-premises system to Anypoint MQ and have another on-premises subscriber pull messages from Anypoint MQ. Currently, Anypoint MQ can’t be deployed on-premises. If you need a messaging source on-premises, you can use Apache Active MQ instead. ## How does Anypoint MQ handle disaster recovery and high availability failover? Within each region, Anypoint MQ services deploy to multiple availability zones (AZs) to provide high availability (HA). If service in one availability zone goes down, the Anypoint MQ service operates normally in that region. If all availability zones go down in a region, the Anypoint MQ service is unavailable in that region until at least one of the availability zones comes back up. Because the storage solution for Anypoint MQ is durable, messages that were already in the Anypoint MQ system before service was interrupted are retained. Anypoint MQ also provides [cross-region failover](https://docs.mulesoft.com/mq/mq-failover) for standard queues. When you enable failover for a queue, Anypoint MQ automatically creates a fallback queue in a [fallback region](https://docs.mulesoft.com/mq/mq-failover#primary-fallback-regions). If a Mule app can’t reach an Anypoint MQ server in a region, it switches to the fallback queue to publish and consume messages. ## Can I use a retry strategy with the Anypoint MQ connector? You can’t use reconnection strategies with the Anypoint MQ connector because it does not use a connection-based protocol. Instead, it uses REST behind the scenes. On the inbound side, you can easily mimic a retry strategy using a max redelivery attribute set to your maximum number of retries and an exception strategy to move to a dead-letter queue (DLQ) when the limit is reached. On the outbound side, you should use the same triggering mechanism. Otherwise, you can use the `until-successful` element with this connector. You should also configure the HTTP connector so that **Global Element Properties** > **Set Max Redelivery** is set to the value of `-1`. ## How can we replay/reprocess messages from a DLQ? There is no built-in functionality to replay messages from a DLQ. You must implement a special flow or app to consume those messages and forward them back to the original queue for reprocessing. ## How do we recover and handle failover? The network that Anypoint MQ runs on provides high availability replications across its many datacenters. ## How do we ensure a message is uniquely processed when failover occurs? If a server fails and failover occurs, messages continue to be processed by other servers on the network in which Anypoint MQ runs. Standard Anypoint MQ queues do not guarantee only-once message delivery. Only FIFO queues support only-once message delivery. The high availability network deduplicates messages for FIFO queues automatically. ## Does Anypoint MQ guarantee message delivery? Yes. Standard queues provide "at least once" message-delivery reliability for messages routed to them. For messages published to a standard exchange, the bindings determine which bound queues, if any, receive each message: a binding with no routing rule receives every message, and a binding with a routing rule receives only messages that match it. See [What happens when a message published to an exchange doesn’t match any routing rule?](#unmatched-routing-rules). ## What happens when a message published to an exchange doesn’t match any routing rule? Bindings without configured message routing rules receive every message published to the exchange. If every binding has a configured routing rule and a message matches none of them, Anypoint MQ doesn’t deliver the message to any bound queue. A successful publish operation confirms that Anypoint MQ accepted the message for the exchange. It doesn’t confirm that a routing rule matched or that a bound queue received the message. If no bound queue receives the message, redelivery and dead-letter queue (DLQ) settings configured on queues don’t apply because the message never enters a queue. For more information, see [Route Messages by Configuring Rules on Message Exchanges](https://docs.mulesoft.com/mq/mq-routing-rules). ## How are API requests calculated? Every API call to Anypoint MQ counts as one API request. Counting each call as a request includes sending, receiving, and acknowledging messages as well as all operations on queues and exchanges. Up to 10 messages can be retrieved from a single API call, which only bills as one request. Even if the request to retrieve messages does not return a message, for example, if the queue is empty, it still bills as a single API request. ## What’s the maximum TPS for Anypoint MQ? Maximum transactions per second (TPS): - Standard queues and exchanges: No maximum TPS - FIFO queues: Maximum of 300 TPS If you batch 10 messages per read and write operation (maximum) using the API, FIFO queues can support up to 3,000 TPS. For more information about batch operations, see [Can I upload and retrieve Anypoint MQ messages in batches?](#batch-upload-retrieve). > [!IMPORTANT] Failed requests count against TPS. ## What’s the maximum number of queues and exchanges in Anypoint MQ? There is no maximum number of queues or exchanges. ## How many in-flight messages can I have per queue? Anypoint MQ supports up to 120,000 in-flight messages per standard (non-FIFO) queue. FIFO queues allow up to 10 in-flight messages per message group due to the extra processing required. Anypoint MQ doesn’t limit the number of message groups in a FIFO queue. A single queue can contain an unlimited number of messages. The maximum duration for any message, either in-flight or not, is two weeks, after which Anypoint MQ deletes the message. ## Does the Anypoint MQ connector store the message and retry sending it? The connector does not store the message for resending it. The connector retries 5 times after which the message is discarded and it becomes the responsibility of the app to decide what to do with a message. ## Are retries synchronous or asynchronous relative to the Mule flow? Retries for sending messages to Anypoint MQ broker are always synchronous. By contrast, the client mode specifies how to establish the connection to the backend and does not govern message-sending retries. ## Are retries governed by the maxRedelivery setting? Retries are arbitrary. The `maxRedelivery` parameter indicates how many times the messages were delivered but not processed (either NACK or TimeOut). ## Can I upload and retrieve Anypoint MQ messages in batches? Using the Anypoint MQ Broker API, you can batch-upload and batch-retrieve messages from a standard or FIFO queue. For information, see [Anypoint MQ Broker API](https://dev-portal.mulesoft.com/apis/anypoint-mq-broker.html). You can upload or retrieve a maximum of 10 messages (default) in a single call. For batch-retrieve operations, use the `batchSize` query parameter to specify the number of messages to retrieve. Anypoint MQ Broker API doesn’t guarantee the number of messages retrieved in a single call. See [Why do I receive fewer messages than my batch size when retrieving messages with the Anypoint MQ REST API?](#batchsize). ## Can non-Mule applications interface with Anypoint MQ? If you have non-Mule applications, you can use the [Anypoint MQ REST APIs](https://docs.mulesoft.com/mq/mq-apis) to send and receive messages. ## What is the throughput capacity of Anypoint MQ? Anypoint MQ is horizontally scalable and supports higher throughputs as needed. ## Can I be notified when a message arrives in a queue? Anypoint MQ provides long polling. You can do a REST request and ask the server to keep the TCP socket open for up to 20 seconds to fulfill your request if there are not enough messages. ## How can I process messages one at a time? You can use [FIFO queues](https://docs.mulesoft.com/mq/mq-queues#fifoqueues) to process messages in order. If you don’t want to use FIFO queues, you can process messages one at a time by setting Anypoint MQ Connector to the `consume` operation. This operation retrieves a message from the queue or receives null if a message is not available. Then, depending on your Mule version: **Mule 4** Add the `maxConcurrency="1"` attribute to the `flow` element. Specify this attribute to set the number of simultaneous invocations that a component can receive at any given time to 1. Mule 4 Example: ```xml ``` More than one in-flight message can occur if the processing time between `anypoint-mq:consume` and `anypoint-mq:ack` is higher than the value of the **Default Acknowledgement Timeout** setting for the queue. ## Can we see the Anypoint MQ headers in the browse message options? Anypoint MQ provides direct access to the message ID and payload. You can see the message headers using the Chrome browser and its Network Inspector feature. ## Does Anypoint MQ connector support shared resources? The only officially supported connectors and transports for shared resources are HTTP/HTTPS, VM, JMS, JMS Caching Connection Factory, Database, WMQ, JBoss Transaction Manager, and Bitronix Transaction Manager. ## How do I create many queues and message exchanges? You can use a `curl` command with the [Anypoint MQ Admin API](https://docs.mulesoft.com/mq/mq-apis#mq-admin-api) in a `for` loop to create the number of queues and message exchanges you need. See [Anypoint MQ REST APIs](https://docs.mulesoft.com/mq/mq-apis). ## Do the API requests-per-month usage charges pertain to all environments? Yes, the usage charges apply to all environments. ## What happens when our usage exceeds our license limit? If your usage exceeds your license limit, Anypoint MQ continues to work. MuleSoft notifies your account administrator and team with any billing-related information. ## Why am I seeing 400 bad request errors when using prefetch to receive messages? When using Anypoint MQ as a message processor with prefetch, use only a global prefetch configuration. For example, this local prefetch doesn’t work: ```xml ``` Use a global prefetch instead: ```xml ``` ## How do I delete a queue? To delete a queue, see [Delete a Queue](https://docs.mulesoft.com/mq/mq-queues#delete-a-queue). ## How do I delete a message exchange? To delete a message exchange, see [Delete a Message Exchange](https://docs.mulesoft.com/mq/mq-exchanges#delete-a-message-exchange). ## See Also - [Knowledge Base Articles](https://help.mulesoft.com/s/knowledge) - [Apache Active MQ](https://activemq.apache.org/) - [Rabbit MQ](https://www.rabbitmq.com/) --- product: MQ --- # Getting Started with Anypoint MQ > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Follow these high-level steps to configure and use Anypoint MQ: 1. Make sure you have a paid Anypoint Platform package or subscription with the Anypoint MQ integration add-on. Contact your account team for information. After purchasing Anypoint MQ, wait one hour for Anypoint MQ to become available in Anypoint Platform. 2. [Set up your environment and access permissions](https://docs.mulesoft.com/mq/mq-access-management). 3. [Configure a connected app](https://docs.mulesoft.com/mq/mq-connected-apps) to get an ID and secret to configure Anypoint Connector for MQ ([Anypoint MQ Connector](https://docs.mulesoft.com/anypoint-mq-connector/latest/)). 4. Configure a [queue](https://docs.mulesoft.com/mq/mq-queues), [message exchange](https://docs.mulesoft.com/mq/mq-exchanges), or a [FIFO queue](https://docs.mulesoft.com/mq/mq-queues#fifoqueues). 5. [Send messages](https://docs.mulesoft.com/mq/mq-queues#send-message-to-queue) to a queue or message exchange. 6. [Get messages](https://docs.mulesoft.com/mq/mq-queues#get-a-message-from-a-queue) from a queue. 7. In Anypoint Studio, configure Anypoint MQ Connector in your Mule app: 1. Install Anypoint MQ Connector using Anypoint Exchange. 2. Create a new Mule project with required building blocks, such as an Anypoint Connector for HTTP (HTTP Connector), Anypoint MQ Connector, Set Payload, and a Logger. 3. Configure Anypoint MQ Connector and provide the ID and secret of the connected app. 4. Set the Anypoint MQ Connector operation to publish or consume messages, or to accept (ACK) or not accept (NACK) a message. 5. Deploy the Mule app. 8. Test the queue: 1. Use a REST client such as `curl` or Postman to send or receive a message. Anypoint MQ sends the string as a message to the queue or message exchange you specified. 2. View your message in a browser or the Studio console. ## See Also - [Anypoint MQ Tutorial](https://docs.mulesoft.com/mq/mq-tutorial) - [Anypoint MQ Connectors](https://docs.mulesoft.com/mq/mq-connectors) - [Anypoint MQ FAQ](https://docs.mulesoft.com/mq/mq-faq) - [Anypoint MQ Release Notes](https://docs.mulesoft.com/mq/mq-release-notes) - [Anypoint MQ Audit Logging](https://docs.mulesoft.com/access-management/audit-logging#to-query-audit-logging-for-anypoint-mq) --- product: MQ --- # Monitoring Anypoint MQ > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Use the Anypoint MQ monitoring features to view usage and audit logging data. - [Viewing Anypoint MQ Usage Data](https://docs.mulesoft.com/mq/mq-usage) You can view a chart that indicates how much data and how many API requests have been consumed, and how many message units were received. - [Accessing Anypoint MQ Audit Logs](https://docs.mulesoft.com/mq/mq-audit-logs) The Anypoint Platform audit logging service logs Anypoint MQ actions on queues, exchanges, and client applications. --- product: MQ --- # Route Messages by Configuring Rules on Message Exchanges > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint MQ includes the ability to create _intelligent message routing rules_ to route a subset of the messages published to an exchange to a specific queue. You configure the message routing rule on the binding on an exchange. When you publish a message to the exchange, the message routing rule routes the message to a queue only if the message includes a property or header that matches the rule. > [!NOTE] Bindings without configured message routing rules receive every message published to the > exchange. If every binding has a configured routing rule and a message matches none of them, > Anypoint MQ doesn’t deliver the message to any bound queue. > [!IMPORTANT] A successful publish operation confirms that Anypoint MQ accepted the message for the > exchange. It doesn’t confirm that a routing rule matched or that a bound queue received the > message. If no bound queue receives the message, redelivery and dead-letter queue (DLQ) settings > configured on queues don’t apply because the message never enters a queue. ![Rules on exchange bindings routing messages to specific queues](/mulesoft/current/en-us/mq/_images/mq-route-message.png) For example, you might want to designate a queue to handle all orders for size medium items and another queue for premium items. To route messages published to an exchange to specific queues: 1. Define message routing rules on the binding between the exchange and the queue. You configure one message routing rule per binding on the exchange. Anypoint MQ evaluates the configured message routing rules against all `headers` and `properties` attributes in the published messages. 2. Specify filtering criteria by defining `properties` and `headers` in the message. If you publish this message to the `purchases` exchange, the exchange forwards it only to `premiumPurchases` queue and not to the `sizeMedium` queue based on the routing rule configuration. ```json { "headers": { "itemSize": "large" }, "body": "User added an item to the cart" } ``` ## Create a Message Routing Rule To create a message routing rule: 1. Sign in to Anypoint Platform. 2. Click **MQ** in navigation area or the main Anypoint Platform screen. 3. Click **Destinations** and then click the name of the exchange to configure rules. 4. On the **Exchange Settings** page, click **Add Rule** to add a rule to a bound queue. ![Exchange Settings page showing the Add Rule button](/mulesoft/current/en-us/mq/_images/mq-exchange-add-rule-bound-queues.png) 5. Complete the fields on the **Create Routing Rule** page. ![Create Routing Rule form showing example values](/mulesoft/current/en-us/mq/_images/mq-exchange-create-routing-rule.png) - Specify the property name and value to match. - For each property type, specify a [matcher type](#matcher-type). 6. Click **Add Rule**. ## Change a Message Routing Rule To change a message routing rule: 1. Sign in to Anypoint Platform. 2. Click **MQ** in navigation area or the main Anypoint Platform screen. 3. Click **Destinations** and then click the name of the exchange to configure rules. 4. On the **Exchange Settings** page, click **Edit Rule** to change a rule on a bound queue. ![Exchange Settings page showing the Edit Rule button](/mulesoft/current/en-us/mq/_images/mq-exchange-edit-rule-bound-queues.png) 5. On the **Edit Routing Rule** page, change the rule settings. For information about property types and matcher types, see [Matcher Type](#matcher-type). 6. Click **Save Rule**. ## Delete a Message Routing Rule To delete a message routing rule: 1. Sign in to Anypoint Platform. 2. Click **MQ** in navigation area or the main Anypoint Platform screen. 3. Click **Destinations** and then click the name of the exchange to configure rules. 4. On the **Exchange Settings** page, click **Delete Rule** . ![Exchange Settings page showing the Delete Rule button](/mulesoft/current/en-us/mq/_images/mq-exchange-delete-rule-bound-queues.png) 5. In the **Delete Routing Rule** confirmation box, select the checkbox and click **Delete Routing Rule** to verify that you want to delete the rule. ## Create or Change a Message Routing Rule with Anypoint Admin API For information about using the Anypoint MQ Admin API to manage message routing rules, see [Create or Change Message Routing Rules](https://docs.mulesoft.com/mq/mq-apis#routing-rules-api). ### Matcher Type
Property TypeMatcher TypeDescription

String

Equals

Message property value is an exact match for the value in this rule.

Prefix

Message property value starts with the value in this rule.

Any of

Message property value matches any of the values in this rule.

None of

Message property value does not match any of the values in this rule.

Exists

Message includes a property with a name that matches the property name in this rule.

Number

Equals

Message property value is equal to the value in this rule.

Less than

Message property value is less than the value in this rule.

Less than or equal

Message property value is less than or equal to the value in this rule.

Greater than

Message property value is greater than the value in this rule.

Greater than or equal

Message property value is greater than or equal to the value in this rule.

Range

Message property value is within the inclusive range of values specified in this rule.

None of

Message property value does not match any of the values in this rule.

Exists

Message includes a property with a name that matches the property name in this rule.

> [!IMPORTANT] Property values support the period (.) character (not the comma (,) character) for > decimal notation in numeric property values. > > If you create routing rules on numeric property values and you use Anypoint MQ Connector to > publish messages, you must upgrade to Anypoint MQ Connector version 3.2.0 or later. Previous > versions of the connector send all property values as strings, which results in messages not > matching routing rules on numeric properties. ## Send a Message with Routing Properties To send messages to an exchange and route them to specific queues, use either: - Anypoint MQ **Message Sender** page: When sending the message: 1. Toggle **Add User Properties**. 2. Specify the filter criteria as property name-value pairs to send. For information, see [Send a Message to a Message Exchange](https://docs.mulesoft.com/mq/mq-exchanges#send-a-message-to-a-message-exchange). - Anypoint MQ Broker API: For information, see [Send a Message with Routing Properties](https://docs.mulesoft.com/mq/mq-apis#send-message-routing). To view the routing properties on a published message: 1. In the **Message Sender** page for the exchange, click **View Messages** for a queue that is bound to the exchange. Anypoint MQ displays the **Message Browser** page for the selected queue. 2. Click **Get Messages**. 3. Click the message row to view the message payload, including the user properties, in the details pane: ![Message Browser details page showing the message payload and user properties](/mulesoft/current/en-us/mq/_images/mq-exchange-user-props.png) See [Get a Message from a Queue](https://docs.mulesoft.com/mq/mq-queues#get-a-message-from-a-queue). ## Requirements and Restrictions > [!IMPORTANT] If you create routing rules on numeric property values and you use Anypoint MQ > Connector to publish messages, you must upgrade to Anypoint MQ Connector version 3.2.0 or later. > Previous versions of the connector send all property values as strings, which results in messages > not matching routing rules on numeric properties. Anypoint MQ supports message routing rules with these restrictions: > [!NOTE] FIFO exchanges don’t support routing rules. To use routing rules, configure a standard > exchange. - Exchanges must have 25 or fewer queue bindings. You can bind a maximum of 25 queues to an exchange with message routing rules defined. If an exchange has more than 25 queue bindings, you can’t use intelligent message routing. - You can configure a message routing rule on only one property with these restrictions: - Maximum size of the property name is 180 bytes. - Maximum size of the property value is 45 KB. - Property values for routing rules can contain whitespace, alphanumeric (a-z, A-Z, 0-9), and punctuation (@ ! & | # $ % - \_ : ; , . ') characters. Anypoint MQ evaluates messages against the routing rule only if they meet these criteria: - Total number of headers and properties is fewer than 500. This total includes operational headers, such as `messageId` and `createdTimestamp`, that Anypoint MQ creates. - Maximum total size of headers and properties is 215 KB. If a message doesn’t meet these criteria, Anypoint MQ ignores the headers and properties when evaluating the message against the message routing rules. Anypoint MQ retains the headers and properties in the payload and, when it publishes the message to the exchange, the headers and properties are available for consumption. ## See Also - [Create Message Routing Rules](https://docs.mulesoft.com/mq/mq-apis#routing-rules-api) - [Send a Message with Routing Properties](https://docs.mulesoft.com/mq/mq-apis#send-message-routing) --- product: MQ --- # Sending Messages to Multiple Queues Using Message Exchanges > For the full documentation index, see: https://docs.mulesoft.com/llms.txt You can send messages to multiple standard or FIFO [queues](https://docs.mulesoft.com/mq/mq-queues) simultaneously by binding those queues to a _message exchange_. By default, a message exchange sends each message to every bound queue. You can instead route messages to specific bound queues by creating _intelligent message-routing rules_ on the bindings. For information, see [Route Messages by Configuring Rules on Message Exchanges](https://docs.mulesoft.com/mq/mq-routing-rules). The maximum size of a message sent to a message exchange is 10 MB. You can bind a maximum of 450 queues to a message exchange. You can bind a maximum of 25 queues to an exchange with message routing rules defined. If an exchange has more than 25 queue bindings, you can’t use intelligent message routing. Before creating a message exchange, create one or more queues. For information, see [Create a Queue](https://docs.mulesoft.com/mq/mq-queues#create-a-queue). > [!NOTE] Message exchanges support only the Publish operation; they don’t support the Consume > operation. Anypoint MQ forwards messages published to a message exchange to the bound queues that > are eligible under the binding configuration, and the app consumes from the queue. > > If an app attempts to consume from a message exchange, the Anypoint MQ REST API throws this error: > `The destination should be a queue.` ## Create a Message Exchange To create a message exchange: 1. Sign in to Anypoint Platform. 2. Click **MQ** from the navigation menu or the main Anypoint Platform screen. 3. Click **Destinations**. 4. Click the **Add** icon to display the menu: 5. Select **Exchange** or **FIFO Exchange**. For **Queue** or **FIFO Queue**, see [Configuring and Using Queues](https://docs.mulesoft.com/mq/mq-queues). 6. Name the message exchange in the **Create Exchange** or **Create FIFO Exchange** page. Message exchange names can contain up to 127 alphanumeric (a-z, A-Z, 0-9) and punctuation (. -) characters. They can’t contain spaces or other characters. 7. Click the checkboxes to bind queues to this message exchange: ![Checkboxes to bind queues to a message exchange in the Create Exchange page](/mulesoft/current/en-us/mq/_images/mq-exchange-bind-queues.png) > [!NOTE] You can bind only standard queues to an exchange and only FIFO queues to a FIFO > exchange. 8. Click **Save Changes**. 9. In the **Destinations** page, click the message exchange type for the new exchange to display the bound queues in the details pane: ## Bind a Queue to a Message Exchange > [!NOTE] You can bind a maximum of 450 queues to a message exchange. You can bind a maximum of 25 > queues to an exchange with message routing rules defined. If an exchange has more than 25 queue > bindings, you can’t use intelligent message routing. To bind a queue to a message exchange: 1. In **Anypoint Platform > MQ**, click **Destinations** in the navigation menu. 2. Click the message exchange ID to display the **Exchange Settings** page: ![Exchange Settings page showing checkboxes for multiple select, and Unbind and Bind buttons](/mulesoft/current/en-us/mq/_images/mq-bind-queue-to-exchange2.png) > [!NOTE] The page displays only standard queues for a message exchange and only FIFO queues for > a FIFO exchange. 3. In the settings page, click **Bind** or **Unbind** for each single queue you want to bind to or unbind from the message exchange. To select multiple queues to bind to the exchange, select the checkboxes and click the **Bind Selected Queues** button that appears: ![Bind Selected Queues button](/mulesoft/current/en-us/mq/_images/mq-exchange-bind-selected-queues.png) ## Send a Message to a Message Exchange Sending a message to a message exchange is similar to sending a message to a queue. The exchange evaluates its bindings and sends the message to each eligible bound queue. The maximum size for a message sent to a message exchange is 10 MB. > [!IMPORTANT] A successful publish operation confirms that Anypoint MQ accepted the message for the > exchange. It doesn’t confirm that a routing rule matched or that a bound queue received the > message. If no bound queue receives the message, redelivery and dead-letter queue (DLQ) settings > configured on queues don’t apply because the message never enters a queue. For details about eligible bindings and unmatched messages, see [Route Messages by Configuring Rules on Message Exchanges](https://docs.mulesoft.com/mq/mq-routing-rules). If the payload contains any format except text (such as CSV, HTML, JSON, and XML), Anypoint MQ converts it to a string before sending, which increases the payload size. This conversion might result in the payload exceeding the maximum payload size of 10 MB and causing a `Payload too large` error. To send a message to a message exchange: 1. In **Anypoint Platform > MQ**, click **Destinations** in the navigation menu. 2. Click the message exchange ID to display the **Exchange Settings** page. 3. In the settings page, click **Message Sender** in the navigation menu: ![Message Sender option for the selected message exchange](/mulesoft/current/en-us/mq/_images/mq-exchange-payload.png) 4. Leave the **Type** field set to **Text**. 5. Enter text in the **Payload** field, such as `Hello Queues from myMessageExchange`. 6. If you want, toggle **Add User Properties**, specify the property name-value pairs to send, and click **Add Property**: ![Message Sender page showing the Add User Properties toggle](/mulesoft/current/en-us/mq/_images/mq-tutorial-message-sender-user-props.png) 7. Click **Send**. 8. Click **View Messages** for a queue that is bound to the exchange to view the queue with the Message Browser. See [Get a Message from a Queue](https://docs.mulesoft.com/mq/mq-queues#get-a-message-from-a-queue). You also send JSON content or comma-separated values (CSV) in the payload by changing the message **Type** value. See [Send a JSON Message to a Queue](https://docs.mulesoft.com/mq/mq-queues#send-a-json-message-to-a-queue) and [Send a CSV Message to a Queue](https://docs.mulesoft.com/mq/mq-queues#send-a-csv-message-to-a-queue). ## Delete a Message Exchange If a message exchange is no longer needed, you can delete it. All queue bindings for the deleted exchange queue are lost. Clients can’t publish or subscribe to the exchange. To delete a message exchange: 1. In **Anypoint Platform > MQ**, click **Destinations** in the navigation menu. 2. In the **Destinations** page, click the message exchange type for the exchange to display the details pane. 3. Click the **Delete** icon: ![Delete icon in the details pane for deleting an exchange](/mulesoft/current/en-us/mq/_images/mq-exchange-delete.png) 4. In the **Delete Exchange** window, select the checkbox to confirm and click **Delete Exchange**. ## See Also - [Configuring and Using Queues](https://docs.mulesoft.com/mq/mq-queues) - [Anypoint MQ Overview](https://docs.mulesoft.com/mq/) - [FAQ: Anypoint MQ](https://docs.mulesoft.com/mq/mq-faq) --- product: MQ --- # Set Up the Environment and Access Permissions > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Create an environment and manage the roles of users who administer Anypoint MQ features in Anypoint Platform for your organization by using Access Management. ## Before You Begin - Create an environment for permissions. Follow the steps in [To Create a New Environment](https://docs.mulesoft.com/access-management/environments#to-create-a-new-environment). - Make sure you have the [permissions](#anypoint-mq-permissions) required to use Anypoint MQ. ## Anypoint MQ Permissions
Required PermissionsGrants the Ability toNotes

View clients

View all client apps, including client app IDs and client secrets for each client app.

View destinations

  • View all destinations and each destination’s settings (ID, Type, Message TTL, and Message Lock Default TTL).

  • View In Queue message stats.

  • View In Flight message stats.

Clear destinations

  • View all destinations and each destination’s settings (ID, Type, Message TTL, and Message Lock Default TTL).

  • View In Queue message stats.

  • View In Flight message stats.

Manage clients

  • View all client apps, including client app IDs and client secrets for each client app.

  • Create client apps.

Administer destinations

  • View all destinations and each destination’s settings (ID, Type, Message TTL, and Message Lock Default TTL).

  • View In Queue message stats.

  • View In Flight message stats.

    • Create new queues, message exchanges, and bindings.

    • Edit existing queues, message exchanges, and bindings.

    • Purge messages from queues.

Manage destinations (deprecated)

  • View all destinations and each destination’s settings (ID, Type, Message TTL, and Message Lock Default TTL).

  • View In Queue message stats.

  • View In Flight message stats.

  • Create new queues and message exchanges.

  • Edit existing queues and message exchange settings.

  • Access Message Sender and Browser pages.

  • Delete messages.

  • Purge messages from queues.

This permission is deprecated. Assign these permissions instead:

  • Administer destinations

  • Destination subscriber for a given environment

  • Destination publisher for a given environment

Destination subscriber for a given environment

  • Consume messages from a destination.

  • Delete messages from a destination.

Destination publisher for a given environment

  • Send messages to a destination.

  • Update message TTL on a destination.

Read MQ stats

View organization and environment statistics.

To assign user permissions, follow the steps in [Grant Permissions to Users](https://docs.mulesoft.com/access-management/users#grant-user-permissions). To use teams to assign permissions, follow the steps in [Using Teams to Manage User Permissions](https://docs.mulesoft.com/access-management/teams). Anypoint MQ access is controlled at the environment and business group levels, not per individual queue or message exchange. Permissions such as **Destination Publisher** and **Destination Subscriber** are granted at the environment level and apply to all destinations in that environment. There is no native mechanism to restrict access to a single queue or message exchange. ## Switch Environments To switch environments: 1. In Anypoint Platform, go to **MQ**. 2. Click the environment button. ![Environment button with Production environment selected](/mulesoft/current/en-us/mq/_images/mq-switch-env.png) - To switch to a different environment, click the name of that environment (for example, **Sandbox**, if you previously created a sandbox environment) and then click **Switch**. - To change your default environment, click **Open your profile to change the default environment** and choose a different environment from the **Default** environment list. ## See Also - [Permissions by Product in Anypoint Platform](https://docs.mulesoft.com/access-management/permissions-by-product) --- product: MQ --- # Tutorial: Create a Queue and Send Messages to It > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Use this tutorial to get started with using Anypoint MQ to send messages to and retrieve messages from a _queue_, which is a temporary storage area for a message. In this tutorial, you: 1. [Create a queue](#create-queue) in Anypoint MQ. 2. [Send messages to the queue](#send-messages), verify that they arrived, and view the message payload. 3. [Configure a connected app](#configure-connected-app) and use the ID and secret to configure Anypoint Connector for MQ (Anypoint MQ Connector) version 4.x. To use connected apps with Anypoint MQ, you must use Anypoint MQ Connector 4.x for Mule 4. If you are using Anypoint MQ Connector version 3.x or earlier, configure a client app instead. For information, see [Configuring Client Apps](https://docs.mulesoft.com/mq/mq-client-apps). 4. [Create a Mule 4.x app in Anypoint Studio 7.x](#configure-mule-4-studio), configure Anypoint MQ Connector, and test the connection. ## Before You Begin Before you begin this tutorial, you must have: - Familiarity with [Anypoint MQ Glossary](https://docs.mulesoft.com/mq/mq-glossary) - A paid Anypoint Platform package or subscription with the Anypoint MQ integration add-on Contact your account team for information. - Anypoint Studio installed on your system - A [`curl` command line tool](https://curl.se/) for testing This tutorial uses the HTTP Listener trigger to initiate Anypoint MQ Connector access and a `curl` command to submit REST API commands to the Anypoint MQ Broker API. ## Step 1. Create a Queue First, you create a queue, send messages to the queue, verify that the messages arrived, and view the message payload. To create a queue: 1. Sign in to Anypoint Platform and click **MQ** in the navigation menu. 2. If you want to test the queue in Anypoint Studio 7.x, switch to any environment except Design. For example, click the environment button and select **Production**: ![Destinations page showing the environment-selection button](/mulesoft/current/en-us/mq/_images/mq-switch-env.png) 3. Click **Destinations**: ![Destinations page showing the Destinations navigation option and the Add button for creating a new queue](/mulesoft/current/en-us/mq/_images/mq-tutorial-destinations-option.png)
1Destinations navigation menu displays available queues.
2Add icon creates a new queue or exchange.
4. Click the **Add** icon (![](/mulesoft/current/en-us/mq/_images/icon-blue-plus.png)) to display the menu: ![Add icon showing the Queue, Exchange, and FIFO Queue menu options](/mulesoft/current/en-us/mq/_images/mq-tutorial-create-choices.png) 5. Select **Queue**. 6. In the **Create Queue** window, enter `myDemoQueue` in the **ID** field: ![Create Queue window showing myDemoQueue in the ID field and other default options](/mulesoft/current/en-us/mq/_images/mq-create-queues.png) Queue names can contain up to 127 alphanumeric (a-z, A-Z, 0-9) and punctuation (. -) characters. They can’t contain spaces or other characters. 7. If you want, specify any other queue settings. For information, see [Create a Queue](https://docs.mulesoft.com/mq/mq-queues#create-a-queue). 8. Click **Create Queue**. Anypoint MQ creates the queue in the **Destinations** page: ![Destinations page showing the new queue](/mulesoft/current/en-us/mq/_images/mq-tutorial-queue-details.png) You have successfully created a queue. Next, you send messages to the queue, verify that the messages arrived, and view the message payload. ## Step 2. Send Messages to a Queue and Verify That They Arrived After you create the queue, you test the queue sending messages to it, validating that the messages arrived in the queue, and retrieving them from the queue. To send and receive messages from a queue: 1. In the **Destinations** page, click `myDemoQueue`. 2. Click **Message Sender** in the navigation menu: ![Message Sender page and option in the navigation menu](/mulesoft/current/en-us/mq/_images/mq-tutorial-message-sender-page.png) 3. Leave the **Type** field set to **Text** and enter `Hello Mules!` in the **Payload** field. 4. If you want, toggle **Add User Properties**, specify the property name-value pairs to send, and click **Add Property**: ![Message Sender page showing the Add User Properties toggle](/mulesoft/current/en-us/mq/_images/mq-tutorial-message-sender-user-props.png) The **Message Sender** page shows added string properties in blue and number properties in gray. 5. Click **Send**. 6. Set the **Type** to **CSV**, enter this in the **Payload** field, and click **Send**: ```csv "dog", "fish", "parrot" ``` 7. Set the **Type** to **JSON**, enter this in the **Payload** field, and click **Send**: ```json { "animal that walks": "dog", "animal that swims": "fish", "animal that flies": "parrot" } ``` Next, verify that the messages arrived in the queue. 8. Click **Destinations**. 9. Click the queue type for `myDemoQueue` to display its details. The details pane shows the number of messages in the queue: ![Details pane showing three messages in the myDemoQueue queue](/mulesoft/current/en-us/mq/_images/mq-tutorial-msgs-in-queue.png) 10. In the details pane, click the queue details label `myDemoQueue`. 11. Click **Message Browser** in the navigation menu: ![Message Browser page and option in the navigation menu](/mulesoft/current/en-us/mq/_images/mq-tutorial-get-messages.png) 12. Enter `5` for the number of messages to retrieve and `10` for the number of seconds to poll. You can retrieve between 1-500 messages and poll for between 1-3600 seconds. 13. Click **Get Messages**. Anypoint MQ retrieves the messages from the queue and displays them in the Message Browser. 14. Click the message row to view the message payload in the details pane: ![Selected message row and details pane showing the payload](/mulesoft/current/en-us/mq/_images/mq-tutorial-msg-browser-payload-details.png)
1Selected message
2Message payload in the details pane
You have successfully created a queue in Anypoint MQ, sent messages to the queue, verified that the messages arrived, and viewed the message payload. Next, you create a connected app to connect a Mule app to Anypoint MQ. ## Step 3. Configure a Connected App After you test the queue, you configure a connected app, which generates the ID and secret you use to configure Anypoint MQ Connector. > [!NOTE] To use connected apps with Anypoint MQ, you must use Anypoint MQ Connector 4.x for Mule 4. > If you are using Anypoint MQ Connector version 3.x or earlier, configure a client app instead. For > information, see [Configuring Client Apps](https://docs.mulesoft.com/mq/mq-client-apps). To create a connected app with Anypoint MQ scopes: 1. In Anypoint Platform, go to **Access Management**. 2. Click **Connected Apps** in the navigation pane. 3. Click **Create app**. ![Connected Apps navigation option and Create app button in Access Management](/mulesoft/current/en-us/mq/_images/mq-tutorial-create-connected-apps.png)
1Connected Apps menu option displays and creates connected apps.
2Create app button creates a connected app.
4. Specify a name, such as `DemoApp1` for the app. 5. Select **App acts on its own behalf (client credentials)**. 6. Click **Add Scopes**. Scopes are roles with associated permissions, which determine which actions the app can perform within an organization and environment. See [Anypoint MQ Scopes](https://docs.mulesoft.com/mq/mq-connected-apps#mq-scopes). ![Add Scopes window showing the scopes to add to Anypoint MQ connected apps](/mulesoft/current/en-us/mq/_images/mq-conn-apps-scopes.png) 7. In **Add Scopes** window: 1. Enter "MQ" in the **Filter scopes** field. 2. Click **Select all** to select all scopes and click **Next**. 3. Select a business group to apply the scopes to and click **Next**. 4. Select the **Production** environment and click **Next**. 5. Click **Add Scopes**. 8. Click **Save**. When you configure the connector in a later step, click **Copy Id** and **Copy Secret** to copy the ID and secret for `DemoApp1`: ![Connected Apps window showing the Copy Id and Copy Secret buttons](/mulesoft/current/en-us/mq/_images/mq-conn-apps-window.png) You have successfully configured a connected app. Next, you create a Mule app in Anypoint Studio and connect it to Anypoint MQ. ## Step 4. Create and Connect a Mule 4.x App to Anypoint MQ in Anypoint Studio 7.x After you configure the connected app, use Anypoint Studio 7.x to configure an app that connects to Anypoint MQ. Then, deploy the app to CloudHub, submit a `curl` command to test the connection, and use Anypoint MQ to view the results. ### Before You Begin - Install Studio 7.x. See [Download and Install Anypoint Studio](https://docs.mulesoft.com/studio/to-download-and-install-studio). - In Anypoint Platform, change to any environment except Design. Ensure that the queue you created in **Anypoint Platform** > **MQ** is also in this environment. ### Configure an App with Anypoint MQ in Anypoint Studio 7.x First, use Studio 7.x to configure an app that connects to Anypoint MQ: 1. Start Studio, click **File** > **New** > **Mule Project**, and then name the project `mq-demo`. 2. Click the **Exchange** icon in the toolbar: ![Exchange icon in the Studio 7.x toolbar](/mulesoft/current/en-us/mq/_images/mq-tutorial-studio7-exchange.png) 3. Enter your Anypoint Platform username and password. 4. In Exchange, click the **Provided by MuleSoft** navigation menu, select **Connectors** from the drop-down menu, and then search for Anypoint MQ Connector: ![Exchange window showing the Provided by MuleSoft menu option and Connectors selected, and ](/mulesoft/current/en-us/mq/_images/mq-tutorial-exchange.png) 5. Select **Anypoint MQ Connector - Mule 4**. Studio 7.x supports Mule 4.x. 6. Click **Add to project**: ![Add to project option in Exchange](/mulesoft/current/en-us/mq/_images/mq-tutorial-exchange-add-to-project.png) 7. At the confirmation prompt, click **Proceed** and then click **OK** in Studio. 8. In the **Mule Palette** view, click **HTTP**, and then drag the **Listener** to the Studio canvas: ![HTTP Connector and Listener operations in the Mule Palette](/mulesoft/current/en-us/mq/_images/mq-tutorial-studio7-palette.png)
1HTTP Connector displays the Listener operation.
2Listener operation identifies the operation to drag to the Mule Palette.
9. Click **Anypoint MQ** and then drag **Publish** to the **Process** area for the Listener on the canvas: ![Publish operation in the Studio 7.x canvas](/mulesoft/current/en-us/mq/_images/mq-tutorial-studio7-flow.png) 10. In the canvas, click **Listener**. 11. In the Listener properties window, set **General** > **Path** to `/mq/{messageId}`: ![Listener properties window showing the Path field value](/mulesoft/current/en-us/mq/_images/mq-tutorial-studio7-listener-props.png) 12. Click the green plus icon (![](/mulesoft/current/en-us/mq/_images/icon-green-plus.png)) for the **Connector configuration** field. 13. In the HTTP Listener **Global Element Properties** window, verify that the value of **Host** is `All Interfaces [0.0.0.0]` and **Port** is `8081`, and then click **OK**: ![Host and Port settings in the Global Element Properties for the Listener](/mulesoft/current/en-us/mq/_images/mq-tutorial-studio7-listener-config.png) The Listener properties window now indicates that there are no errors. 14. In the canvas, click the **Publish** operation. 15. In the Publish properties window, set **Destination** to the [`myDemoQueue`](#create-demo-queue) queue that you created earlier in **Anypoint Platform** > **MQ**: ![Destination property for the Publish operation in Anypoint Studio](/mulesoft/current/en-us/mq/_images/mq-tutorial-studio7-mq-props.png) The location of the queue must be an environment other than Design. 16. Click the green plus icon (![](/mulesoft/current/en-us/mq/_images/icon-green-plus.png)) for the **Connector configuration** field to display the **Global Element Properties** window. 17. Return to your **Anypoint Platform** > **MQ** browser window to copy the URL, ID, and secret values: 1. Click **Destinations**. 2. Click **Copy** and select **Connector version 4.x and later** from the menu to copy the URL: ![Anypoint MQ Destinations page showing the Copy button and the Connector version dropdown](/mulesoft/current/en-us/mq/_images/mq-tutorial-url.png) If you are using Anypoint MQ Connector version 3.x or earlier, configure a client app instead. For information, see [Configuring Client Apps](https://docs.mulesoft.com/mq/mq-client-apps). 3. In the **Anypoint MQ Config** window in Studio, paste the URL in the **URL** field. 4. Return to the [Connected Apps](#connected-apps-window) window and copy the ID and secret for the app. 5. Paste the ID and secret values to the **Anypoint MQ Config** window in Studio: ![Anypoint MQ Config window showing the URL, Client App ID, and Client Secret fields](/mulesoft/current/en-us/mq/_images/mq-tutorial-studio7-mq-config.png) 18. Click **Test Connection** to ensure that the values are correct, and then click **OK** twice. 19. Save your project. 20. In **Package Explorer** in Studio, right-click `mq-demo` and select **Anypoint Platform** > **Deploy to CloudHub**. 21. At the prompt, select the environment to which to deploy the app. 22. In the Runtime Manager **Deploying Application** window, click **Deploy Application**: ![Deploying Applications page in Runtime Manager showing the Deploy Application button](/mulesoft/current/en-us/mq/_images/mq-tutorial-deploy-app.png) You have successfully used Studio 7.x to configure an app that connects to Anypoint MQ. Next, you test the connection by submitting REST API commands to the Anypoint MQ Broker API and using Anypoint MQ to view the results. ### Test Your Mule 4.x App in Studio 7.x After you create the app in Studio 7.x, you test your app using a `curl` command to submit a REST API command to the Anypoint MQ Broker API. Then, use Anypoint MQ to view the results. To test your app: 1. In Anypoint Platform, select **Runtime Manager** > **Applications** and ensure that the `mq-demo` app is running. 2. Click the status for the `mq-demo` app to display the details pane. 3. Copy the **App url** value: ![Runtime Manager application details pane showing the App url value](/mulesoft/current/en-us/mq/_images/mq-tutorial-rtm-deploy-url.png) 4. Run this `curl` command from a command prompt to send the `body` value as an Anypoint MQ message. Replace _APP-URL_ with the **App url** value that you copied from Runtime Manager. ```json curl -X POST \ http://APP-URL/mq/100 \ -H 'content-type: application/json' \ -d '[ { "body": "Welcome to MuleSoft!" } ]' ``` The `100` value in the URL is the message ID value as specified by `/mq/{messageId}` in the HTTP Listener, which is the identifier for your message. If you see a 404 message for `destination not found`, verify that the queue name in the **MQ Publish** > **Destination** field in Studio matches the name of the queue in **Anypoint Platform** > **MQ**. After making changes, redeploy your Mule app to CloudHub by right-clicking the project in Studio 7.x and selecting **Anypoint Platform** > **Deploy to CloudHub**. 5. In **Anypoint Platform** > **MQ** > **Destinations**, click the name of the [`myDemoQueue`](#create-demo-queue) queue that you created earlier and specified in the **Destination** setting for your app in Studio 7.x. 6. Click **Message Browser** in the navigation menu: ![Message Browser page and navigation menu option](/mulesoft/current/en-us/mq/_images/mq-tutorial-get-messages.png) 7. Enter `5` for the number of messages to retrieve and `10` for the number of seconds to poll. 8. Click **Get Messages**. Anypoint MQ retrieves the messages from the queue and displays them in the Message Browser. 9. Click the message row to view the message payload in the details pane: ![Selected message row and details pane showing the payload](/mulesoft/current/en-us/mq/_images/mq-tutorial-msg-browser-payload-details.png)
1Selected message
2Message payload in the details pane
10. Try changing the body text in the `curl` command and repeat the steps to view the message. ### Example App XML for Studio 7.x You can use this XML to create the `mq-demo` app in Studio 7.x. Click the **Configuration XML** tab in Studio and compare your XML to this example. Make corrections if necessary. ```xml ``` ## See Also - [Create a Queue](https://docs.mulesoft.com/mq/mq-queues#create-a-queue) - [Anypoint Studio 7.x](https://docs.mulesoft.com/studio/) - [Anypoint MQ Connector 4.x for Mule 4](https://docs.mulesoft.com/anypoint-mq-connector/latest/) - [Deploy to CloudHub](https://docs.mulesoft.com/cloudhub/deploying-to-cloudhub) --- product: MQ --- # Viewing Anypoint MQ Usage Data > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint MQ uses API requests to calculate billing. To access usage data, use [Anypoint Usage Reports](#access-mq-usage-reports) or the [Anypoint Usage API](#anypoint-usage-api). API requests API requests are used to calculate your monthly quota for billing. - Every API call (via the connector or API) to Anypoint MQ counts as one API request. All requests to the Anypoint MQ Broker API count against your monthly quota. Requests include sending, receiving, and acknowledging messages and operations on queues and exchanges. Requests to the Anypoint MQ Stats API don’t count against your monthly usage. - You can retrieve up to 10 messages from a single API call, which only bills as one request. Even if the request to retrieve messages does not return a message (for example, if the queue is empty), it bills as a single API request. - If a queue sends a message to a DLQ, the message is not charged against the billable API requests. However, if a client sends a message directly to a DLQ, that request is charged. > [!NOTE] Enabling failover for a queue can result in increased API requests because Anypoint MQ > Connector periodically checks the fallback queue for messages to consume. For more information, > see > [Configure the Frequency of Fallback Queue Checks](https://docs.mulesoft.com/anypoint-mq-connector/latest/anypoint-mq-failover#configure-check-frequency). Message units Message units are not used for billing. Message units are used by Anypoint MQ to determine the size of message data in the response. - Each message unit contains 100 KB of data. - Message units are counted by the number of encoded characters in a message. If your usage exceeds your license limit, Anypoint MQ continues to work. MuleSoft notifies your account administrator and team with any billing-related information. ## Access Anypoint MQ Usage Reports To view Anypoint MQ usage reports in Usage: 1. In Anypoint Platform, go to **Usage**. 2. Select **Anypoint MQ** in the **Product** section: ![Anypoint MQ option on the Usage Reports page](/mulesoft/current/en-us/mq/_images/mq-usage-report.png) 3. Select a month from the **Monthly Usage Report** tab or day from the **Daily Usage Report** tab. The report shows usage for the selected period (total and by object): - Message units - Message bytes - API requests - Messages received 4. Click **Export as CSV** to download the usage for the selected period. For more information, see [Usage Reports](https://docs.mulesoft.com/general/usage-reports). ## Retrieve Usage Metrics with the Anypoint Usage API To retrieve Anypoint MQ usage metrics programmatically, use the Anypoint Usage API. The Anypoint Usage API uses AMQL (Anypoint Metric Query Language), a SQL-like query language, to query usage meters. ### Before You Begin - Get a bearer token for an Anypoint Platform user with the **Usage Viewer** permission at the root organization level. See [Get a Bearer Token](https://docs.mulesoft.com/mq/mq-apis#get-bearer-token). ### Discover Available Meters To view all available Anypoint MQ meters and their column names: ```bash curl -X GET 'https://anypoint.mulesoft.com/metering/usage/api/v1/meters:describe' \ -H 'Authorization: Bearer ' ``` ### Query Anypoint MQ Usage To retrieve API request counts for your organization, submit a POST request using AMQL: ```bash curl -X POST 'https://anypoint.mulesoft.com/metering/usage/api/v1/meters:search' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer ' \ -d '{ "query": "SELECT api_requests FROM anypoint_mq_api_requests_count WHERE timestamp between and TIMESERIES P1D" }' ``` Replace `START_EPOCH_MS` and `END_EPOCH_MS` with epoch milliseconds for your date range. > [!NOTE] The Usage API uses epoch milliseconds, not ISO 8601 strings. For example, > `2024-01-01T00:00:00.000Z` = `1704067200000`. ### AMQL Query Reference ```sql SELECT FROM WHERE timestamp between and [AND org_id = ''] [AND env_id = ''] TIMESERIES ```
ParameterDescriptionValues

TIMESERIES

Granularity of results

P1D (daily) or P1M (monthly)

Daily range (P1D)

Maximum query interval

30 days

Monthly range (P1M)

Maximum query interval

60 days

Data recency

Delay for data consolidation

3-day delay

> [!IMPORTANT] `SELECT *` is not supported. Always specify column names explicitly. Use the > `:describe` endpoint to get the current column names for each meter. > [!NOTE] Anypoint MQ Stats API calls do not count against your monthly API request usage. For near > real-time queue and exchange statistics, continue using the > [Anypoint MQ Stats API](https://docs.mulesoft.com/mq/mq-apis#mq-stats-api). ## See Also - [Anypoint MQ FAQ](https://docs.mulesoft.com/mq/mq-faq) - [Usage Reports](https://docs.mulesoft.com/general/usage-reports)