Contact Free trial Login

Anypoint MQ Connector

MuleSoft recommends against deployments to Mule 3.8. Standard Support for this version ended on November 16, 2018, and Mule 3.8 will reach its End of Life on November 16, 2021, when Extended Support ends.

The Anypoint MQ connector provides publish-subscribe messaging to Mule applications in the cloud or on-premise using the Anypoint MQ cloud service.

Anypoint MQ supports a wide range of messaging use cases: enterprise messaging patterns, asynchronous communications between microservices, IoT, and more. Anypoint MQ also has a REST api for publishing or consuming messages using any framework such as node.js, Java, Go, and devops bash scripts.


To use this connector, you should be familiar with Anypoint Studio, Anypoint connectors, and Mule flows. The Anypoint MQ connector is free, but connecting to the service in Anypoint Platform requires a license.

Note: You cannot complete the configuration information in this document without an Anypoint MQ license. Contact MuleSoft Sales for a trial license.


Software Version

Mule Runtime

3.7.4 and later

Anypoint Studio

v5 and later

To Install This Connector

  1. In Anypoint Studio, click the Exchange icon in the Studio taskbar.

  2. Click Login in Anypoint Exchange and supply your Anypoint Platform credentials.

  3. In the Exchange window, search for this connector, and click Install.

  4. Follow the prompts to install the connector.

To Update from an Older Version

When an updated version of a connector is released, Anypoint Studio displays the Updates Available popup in the bottom right corner of Studio. Click the popup and install the new version.

To Configure with the Studio Visual Editor

  1. In Studio, click File > New > Mule Project.

  2. Search for "http" and drag the HTTP connector to the Studio Canvas. Click the HTTP connector, and click the green plus sign to the right of Connector Configuration. Click OK to accept the defaults. In the HTTP properties window, set the Path to /mq/{messageId}.

  3. Search for "mq" and drag the Anypoint MQ connector to the canvas. If you cannot find this connector, return to To Install This Connector and ensure you installed the connector.

  4. Click the green plus sign to the right of Connector Configuration.

  5. In the Global Element Properties window:

    1. Specify the URL for the region you want your MQ queues and exchanges to reside.

      Possible values are:

      • US East (N. Virginia):

      • US West (Oregon):

      • EU (Ireland):

      • Asia Pacific (Singapore):

      • Asia Pacific (Sydney):

        FIFO queues can reside in US East, US West, and EU Ireland.

    2. In Anypoint Platform, click MQ > Client Apps. If needed, create a client app.

    3. Copy the Anypoint Platform > MQ > Client App > Client App ID value to Studio’s Client ID field.

    4. Copy the Client App > Client Secret value to Studio’s Client Secret field. You can ignore the other settings to test your connector.

    5. Click OK.

  6. Click the Operation field and specify an operation such as Publish or Consume. For information on the Ack and Nack operations, see About Acknowledgement Mode.

  7. If using the Publish or Consume operations, specify the Destination as the name of the queue or message exchange that you set in Anypoint Platform.

  8. For the Publish operation, you can leave the Message ID field empty, or specify a message ID if you want to publish a specific message ID. If a message ID is not set, MQ auto generates a unique message ID for each message that’s sent to a queue. When publishing to FIFO queues, if you specify a Message ID and the Message ID is the same on multiple messages, the messages with the same Message ID are not redelivered.

For a list of all other configuration fields, see the Anypoint MQ Connector Reference.

MQ Schema and Endpoint

If you are creating an XML or standalone application, add this dependency to your pom.xml file:


Note: If you are creating an application using Anypoint Studio, when you install the MQ connector, the MQ dependency in the pom.xml file is updated for you.

Additional dependencies for Gradle, EBT, and Ivy are listed in Anypoint Exchange in the Anypoint MQ Connector asset. Click Dependency Snippets for a complete list.


XML and Standalone Configuration

For a list of XML fields, see Anypoint MQ Connector Reference.

Anypoint MQ XML Examples

This section provides these topics:

Example 1: MQ and DataWeave

The following example illustrates the use of the Anypoint MQ connector with DataWeave to transform a Mule message to JSON:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:dw=""
	xmlns:anypoint-mq="" xmlns:http="" xmlns="" xmlns:doc=""
  <anypoint-mq:config name="Anypoint_MQ_Configuration" doc:name="Anypoint MQ Configuration">
      <anypoint-mq:provider url="" clientId="<id>" clientSecret="<secret>"/>
<flow name="producerFlow">
  <poll doc:name="Poll">
    <dw:transform-message doc:name="Create Customer">
    <dw:set-payload><![CDATA[%dw 1.0
%output application/json
    "firstName" : "Joe",
    "lastName" : "Schmoe",
    "company" : "Acme, Inc"
        <anypoint-mq:publish config-ref="Anypoint_MQ_Configuration" destination="MyExchange" doc:name="Anypoint MQ">
            <anypoint-mq:message-builder messageId="mq42"/>

Example 2: MQ and Object Store

The following example shows the use of the Anypoint MQ connector to consume information from an object store.

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:anypoint-mq=""

    <objectstore:config name="ObjectStore_Configuration" partition="employees" doc:name="ObjectStore: Configuration"/>
    <http:listener-config name="HTTP_Listener_Configuration" host="" port="8081" doc:name="HTTP Listener Configuration"/>
    <anypoint-mq:config name="Anypoint_MQ_Configuration" doc:name="Anypoint MQ Configuration">
        <anypoint-mq:provider url="" clientId="<ID>" clientSecret="<SECRET>"/>
    <flow name="objectstore-store-flow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/store" doc:name="HTTP"/>
        <objectstore:store config-ref="ObjectStore_Configuration" key="#[message.inboundProperties.'http.query.params'.key]" value-ref="#[message.inboundProperties.'http.query.params'.value]" doc:name="ObjectStore"/>
        <anypoint-mq:consume config-ref="Anypoint_MQ_Configuration" destination="MyDemoQueue" doc:name="Anypoint MQ"/>
        <set-payload value= "OK" doc:name="Set Payload"/>
    <flow name="objectstore-retrieve-employee-flow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/retrieve" doc:name="HTTP"/>
        <objectstore:retrieve config-ref="ObjectStore_Configuration" key="#[message.inboundProperties.'http.query.params'.key]" doc:name="Retrieve"/>
        <logger message="Value: #[payload]" level="INFO" doc:name="Log"/>
        <set-payload value="Value : #[payload]" doc:name="Show"/>

Was this article helpful?

πŸ’™ Thanks for your feedback!

Edit on GitHub