Contact Us 1-800-596-4880

Anypoint MQ Connector — Mule 3

Anypoint MQ Connector provides publish-subscribe messaging in Anypoint Studio. Anypoint MQ supports hybrid use cases, IoT where you collect data from different devices, and a REST API you can use with device applications. You can also use Anypoint MQ with other application frameworks such as node.js to communicate to queues.

Before You Begin

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.


Software Version

Mule Runtime

3.7.4 and later

Anypoint Studio

v5 and later

Install the 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.

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.

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 Install the Connector and ensure you installed the connector.

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

Global Element Properties window:

  1. Specify the URL for the region you want your Anypoint MQ queues and exchanges to reside. See Anypoint MQ regions. Substitute the region name in this URL:

  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.

Connector Properties:

  1. Click the Operation field and specify an operation such as Publish or Consume. For information about the Ack and Nack operations, see Acknowledging Messages - Mule 3.

  2. 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.

  3. 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 — Mule 3.

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=""
  <anypoint-mq:default-subscriber-config name="Anypoint_MQ_Configuration"
  doc:name="Anypoint MQ Configuration">
      <anypoint-mq:connection 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" : "Josephina",
    "lastName" : "Costello",
    "company" : "Acme, Inc"
  <anypoint-mq:publish config-ref="Anypoint_MQ_Configuration"
    messageId="mq42" doc:name="Anypoint MQ">

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"/>
View on GitHub