Contact Free trial Login

Anypoint MQ Connector

Select

The Anypoint MQ connector provides publish-subscribe messaging to Mule applications 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.

For more information, see the Anypoint MQ documentation set and additional resources listed in See Also.

Prerequisites

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. Free trial software is available.

Compatibility

Software Version

Mule Runtime

4.0.0 and later

Anypoint Studio

v7 and later

This documentation applies only to Mule 4. For Mule 3 compatible connector information, see Mule 3 MQ Connector.

Install This Connector

From Anypoint Exchange:

  1. In Anypoint Studio, click the Exchange icon in the Studio task bar.

  2. Click Login in Anypoint Exchange and supply your Anypoint Platform username and password.

  3. Search for the connector and click Install.

  4. Follow the prompts to install the connector.

For applications written in XML or that are standalone:

  1. Open your Mule project in Anypoint Studio.

  2. Add the connector as a dependency in the pom.xml file:

    <dependency>
      <groupId>com.mulesoft.connectors</groupId>
      <artifactId>anypoint-mq-connector</artifactId>
      <version>${mq.latest.version}</version>
      <classifier>mule-plugin</classifier>
    </dependency>

For the latest POM, Gradle, or SBT dependencies, see the Exchange Anypoint MQ Connector asset. Click Dependency Snippets for a complete list.

Configure with the Studio Visual Editor

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

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

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

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

    Possible values are:

    • North America:

      • US East (N. Virginia): https://mq-us-east-1.anypoint.mulesoft.com/api/v1

      • US West (Oregon): https://mq-us-west-2.anypoint.mulesoft.com/api/v1

      • Central Canada: https://mq-ca-central-1.anypoint.mulesoft.com/api/v1

    • Europe:

      • EU (Ireland): https://mq-eu-west-1.anypoint.mulesoft.com/api/v1

      • EU (London): https://mq-eu-west-2.anypoint.mulesoft.com/api/v1

    • APAC:

      • Asia Pacific (Singapore): https://mq-ap-southeast-1.anypoint.mulesoft.com/api/v1

      • Asia Pacific (Sydney): https://mq-ap-southeast-2.anypoint.mulesoft.com/api/v1

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

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

  6. Copy the Anypoint Platform > MQ > Client App > Client App ID value to the Studio Client ID field.

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

  8. Click OK.

  9. Click the Operation field and specify an operation such as Publish or Consume.

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

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

Possible operations are:

Operation Description

Publish

Publishes messages to a queue or message exchange.

Consume

Consumes messages from a queue.

Subscribe

Waits for messages from a queue.

Ack

Indicates that the message has been consumed correctly and deletes the message from in-flight status.

Nack

Changes the status of the message from in-flight to in-queue to be consumed again by a subscriber.

For a list of configuration fields for each operation and information about XML elements, see the Anypoint MQ Connector Reference.

Example: MQ Bridge with DataWeave

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

<anypoint-mq:default-subscriber-config name="MQ_Configuration">
    <anypoint-mq:connection url="https://mq-us-east-1.anypoint.mulesoft.com/api/v1"
    clientId="${env.clientId}" clientSecret="${env.clientSecrete}"/>
</anypoint-mq:default-subscriber-config>

<flow name="producerFlow">
  <anypoint-mq:subscriber config="MQ_Configuration" destination="${inbound}"/>

  <http:request config-ref="Invoice_API" method="POST" path="/invoicesProcessing" >
    <http:body>#[output application/json ---
    {
        body : payload,
        origin : attributes.message.properties.orgId,
        trackingNumber : attributes.message.id
    }]</http:body>
  </http:request>
</flow>

Was this article helpful?

πŸ’™ Thanks for your feedback!

Edit on GitHub