+
+

Tutorial: Create a Queue and Send Messages to It

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 in Anypoint MQ.

  2. Send messages to the queue, verify that they arrived, and view the message payload.

  3. In Anypoint MQ, register a client app that you then use to configure Anypoint MQ Connector.

  4. Create an app in Design Center, configure Anypoint MQ Connector, and test the connection.

  5. Create an app in Anypoint Studio, configure Anypoint MQ Connector, and test the connection.

    Depending on your Mule version, you create your app in Studio 7 (Mule 4) or Studio 6 (Mule 3).

Prerequisites

  • Familiarity with Anypoint MQ terminology

  • An Anypoint Platform account

  • An Enterprise license

    Contact the MuleSoft Sales team to get a free trial.

  • Anypoint Studio installed on your system

  • A curl command 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.

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. Log in to Anypoint Platform.

  2. Click MQ in the left navigation bar or the main Anypoint Platform screen.

  3. If you want to test the queue in Anypoint Studio 7, switch to any environment except Design.

    For example, click the environment button and select Production:

    Environment button in the left pane
  4. Click Destinations:

    Destinations option and the blue plus icon

    (1)

    Destinations navigation menu

    Displays available queues.

    (2)

    Blue plus (+) icon

    Creates a new queue or exchange.

  5. Click the blue plus icon (+) to display the menu:

    Blue plus icon menu options
  6. Select Queue.

  7. In the Create Queue window, enter myDemoQueue in the ID field:

    Create Queue window

    Queue names can contain up to 127 alphanumeric characters (a-z, A-Z, 0-9), periods (.), and hyphens (-). They cannot contain spaces or other characters.

  8. If you want, specify any other queue settings.

    For information, see Create a Queue.

  9. Click Create Queue.

    Anypoint MQ creates the queue in the Destinations page:

    Destinations page with the type, ID, and details label for the new queue

    (1)

    Queue type

    Displays the queue details pane.

    (2)

    Queue ID

    Displays the Queue Settings page.

    (3)

    Queue details label

    Displays the Queue Settings page.

You have successfully created a queue. Next, you send messages to the queue, verify that the messages arrived, and view the message payload.

Send Messages to a Queue and Verify That They Arrived

After you create the queue, you test the queue you created by 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 the Message Sender navigation menu:

    Message Sender navigation menu
  3. Leave the Type field set to Text and enter Hello Mules! in the Payload field.

  4. If you want, toggle Add User Properties and specify the property name-value pairs to send:

    Add User Properties toggle in the Message Sender page

    User property names can contain up to 42 alphanumeric characters (a-z, A-Z, 0-9), periods (.), hyphens (-), and colons (:). They cannot contain spaces or other characters.

  5. Click Send.

  6. Set the Type to CSV.

  7. Set the Payload to:

    "dog",
    "fish",
    "parrot"
  8. Click Send.

  9. Set the Type to JSON.

  10. Set the Payload to:

    {
    "animal that walks":"dog",
    "animal that swims":"fish",
    "animal that flies":"parrot"
    }
  11. Click Send.

    Next, verify that the messages arrived in the queue.

  12. Click Destinations.

  13. Click the queue type for myDemoQueue to display its details.

    The details pane shows the number of messages in the queue:

    Three messages in the myDemoQueue queue in the details pane
  14. In the details pane, click the queue details label myDemoQueue.

  15. Click the Message Browser navigation menu:

    Message Browser navigation menu
  16. Specify the number of messages (1-500) and the time to poll (1-3600 seconds).

  17. Click Get Messages.

    Anypoint MQ retrieves the messages from the queue and displays them in the Message Browser.

  18. Click the message row to view the message payload in the details pane:

    Selected message row, payload in the details pane, and icons representing Return Messages, Delete, Full Screen, and close details pane (X)

    (1)

    Selected message.

    (2)

    Message payload in the details pane.

    (3)

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

    (4)

    Delete icon

    Deletes the selected message.

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

    (5)

    Full Screen icon

    Displays the message payload in a separate window.

    (6)

    Close icon

    Closes the details pane.

    If the Message Browser displays Message cannot be deleted when you delete a message, the message time-to-live (TTL) has expired.

    Payloads larger than 1 MB don’t appear in the Message Browser. You can retrieve them with the Anypoint Broker API. See Example: Retrieve a Message.

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 register a client Mule app with Anypoint MQ.

Register a Client Mule App

After you test the queue, you register a client app in Anypoint MQ. Registering the client app generates the client app ID and client secret that you use to configure Anypoint MQ Connector.

To register a client app:

  1. Log in to Anypoint Platform and click MQ.

  2. Click Client Apps:

    Client Apps option and blue plus icon

    (1)

    Client Apps navigation menu

    Displays and creates client apps.

    (2)

    Blue plus (+) icon

    Adds a client app.

  3. Click the blue plus (+) icon.

  4. In the Create Client App window, enter DemoClientApp and click Save Changes.

  5. Click the client app name to view the client app ID and client secret value in the details pane:

    Client app name, Copy, and Show buttons

    (1)

    Client app name

    Displays client app details.

    (2)

    Copy buttons

    Copies the client app ID or client secret value.

    (3)

    Show button

    Displays the client secret value.

  6. Keep the Client Apps window open so you can copy the client app ID and client secret in a later step.

You have successfully registered a client Mule app in Anypoint MQ. Next, you create a Mule app in Design Center and connect it to Anypoint MQ.

Create and Connect a Mule App to Anypoint MQ in Design Center

After you register the client app, you use Design Center to configure an app that connects to Anypoint MQ, submit REST API commands to the Anypoint MQ Broker API, and use Anypoint MQ to view the results.

Prerequisites

  • Disable password programs such as LastPass or Okta in your browser before using Design Center.

    If enabled, the password program inserts passwords in fields in Design Center, which can cause the app to fail.

  • Leave a browser window open to Anypoint Platform > MQ so that you can access the queue and the client app ID and client secret values for the client app you registered previously.

Configure an App with Anypoint MQ in Design Center

To configure an app in Design Center:

  1. In Anypoint Platform, click Design Center in the left navigation bar or the main Anypoint Platform screen.

  2. Click Create new > New Mule App to create a new integration flow.

  3. In the New Mule App window, enter mqdemo for the project name and click Create App.

  4. In the help wizard, click Go straight to canvas:

    Go straight to canvas link
  5. Click the Trigger box and enter H to search for the HTTP Listener:

    Search for the HTTP Listener
  6. Click HTTP Listener.

  7. In the HTTP Listener window, set the value of Path to /mq/{messageId} and then click the Close icon:

    Path value and Close button

    (1)

    Path field

    Specifies the path to the message ID.

    (2)

    Close (X) icon

    Closes the HTTP Listener window.

  8. Click the plus (+) icon to the right of the HTTP Listener trigger:

    Plus icon
  9. In the Select a component window, enter mule an to search for the Mule Anypoint MQ Connector:

    Search for the Mule Anypoint MQ Connector
  10. Click the connector name, and then click the Publish operation:

    Publish operation

    For the other operations:

    • To construct your Mule app to receive a message sent from a queue, use the Consume operation.

    • If your app has tests to determine if message processing succeeded, use the Ack operation to acknowledge that a message was received and can be deleted.

    • If message processing failed, use the Nack operation to negatively acknowledge the message and return the message to the queue to be accessed again.

  11. In the Configuration page, click Add Connection.

  12. In the Configure Connection page, specify myDemoQueue in the Connection Name field and select Connection as the connection type.

  13. Return to your Anypoint Platform > MQ browser window to copy the URL, client app ID, and client secret values:

    1. Click Destinations and copy the URL to the Configure Connection page in Design Center:

      Copy button in the Destinations page
    2. Click Client Apps and click DemoClientApp to display the details pane.

      Client app name and Copy and Show buttons

      (1)

      Client app name

      Displays client app details.

      (2)

      Copy buttons

      Copies the client app ID or client secret value.

      (3)

      Show button

      Displays the client secret value.

    3. Copy the client app ID and client secret values from the details pane to the Configure Connection page in Design Center:

      Client App ID field and Client Secret field in the Configure Connection page
  14. Click Test to ensure that you have access to your client app:

    Success box
    • If successful, the green Success box appears.

    • If unsuccessful, ensure that the client app ID, client secret, and URL values are correct.

      If the URL does not match the URL in Anypoint Platform > MQ, copy the URL from Anypoint MQ to the Design Center window and click Test again.

  15. Click Save twice.

  16. In the Publish Configuration page, enter myDemoQueue.

    This is the name of the queue you created earlier in this tutorial.

  17. Click the Close (X) icon to close the Publish Configuration page:

    Close icon
  18. Select Deploy Application from the menu to the right of the Test button:

    Deploy Application menu option in Design Center
  19. In the Deploy Mule application window, select the target environment and application name, and then click Deploy.

    After the app deploys successfully, you can click in the Deployment success popup to view the app in Runtime Manager.

You have successfully used Design Center 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 Design Center App

After you create your app in Design Center, you test your app using a curl command to submit a REST API command to the Anypoint MQ Broker API and use Anypoint MQ to view the results.

To test your app:

  1. In Design Center, click the project type for your app to display the details pane:

    Deployment URL in details pane
  2. Copy the value of Deployment url.

  3. Run the following curl command from a command prompt to send the body value as an Anypoint MQ message.

    Replace DEPLOYMENT-URL with the deployment URL from Design Center.

    curl -X POST \
      http://DEPLOYMENT-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 the /mq{messageId} value in the HTTP Listener, which is the identifier for your message.

    Next, you verify that the message arrived in the queue.

  4. Select Anypoint Platform > MQ > Destinations.

  5. Click the name of the myDemoQueue queue that you created earlier and specified in the Destination setting for your app in Design Center.

  6. Click the Message Browser navigation menu:

    Message Browser navigation menu
  7. Specify the number of messages (1-500) and the time to poll (1-3600 seconds).

  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, payload in the details pane, and Return Messages, Delete, Full Screen, and close details pane (X) icons

    (1)

    Selected message.

    (2)

    Message payload in the details pane.

    (3)

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

    (4)

    Delete icon

    Deletes the selected message.

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

    (5)

    Full Screen icon

    Displays the message payload in a separate window.

    (6)

    Close icon

    Closes the details pane.

    If the Message Browser displays Message cannot be deleted when you delete a message, the message time-to-live (TTL) has expired.

    Payloads larger than 1 MB don’t appear in the Message Browser. You can retrieve them with the Anypoint Broker API. See Example: Retrieve a Message.
  10. Try changing the body text in the curl command and repeat the steps to view the message.

You have successfully tested your app using a curl command to submit a REST API command to the Anypoint MQ Broker API and using Anypoint MQ to view the results. Next, you create a Mule app in Anypoint Studio 7 and connect it to Anypoint MQ.

Create and Connect a Mule 4 App to Anypoint MQ in Anypoint Studio 7

You can now use Anypoint Studio 7 to create a Mule 4 app similar to the app you created in Design Center. In Studio 7, you can deploy the app to CloudHub and submit a curl command to test the connection.

Prerequisites

  • Install Studio 7.

  • 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

First, use Studio 7 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 toolbar
  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:

    Provided by MuleSoft menu, Connectors drop-down menu, and search field in Exchange
  5. Select Anypoint MQ Connector - Mule 4.

    Studio 7 supports Mule 4.

  6. Click Add to project:

    Add to project icon in Exchange
  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

    (1)

    HTTP Connector

    Displays the Listener operation.

    (2)

    Listener operation

    Identifies the operation to drag to the Mule Palette.

  9. Click Anypoint MQ and then drag Publish to the Process area to the right of the Listener on the canvas:

    Publish operation in the Studio 7 canvas
  10. In the canvas, click Listener.

  11. In the Listener properties window, set General > Path to /mq/{messageId}:

    Listener properties window
  12. Click the green plus (+) icon to the right of the Connector configuration field.

  13. In the HTTP Listener Global Element Properties window, verify that Host is set to All Interfaces [0.0.0.0] and Port is set to 8081, and then click OK:

    Host and Port settings in the Global Element Properties for the Listener

    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 queue that you created earlier in Anypoint Platform > MQ:

    Destination property and green plus icon for the Publish operation

    The queue must be located in an environment other than Design.

  16. Click the green plus (+) icon to the right of the Connector configuration field to display the Global Element Properties window.

  17. Return to your Anypoint Platform > MQ browser window to copy the URL, client app ID, and client secret values:

    1. Click Destinations and click copy to copy the URL to the URL field in Studio:

      Copy button in the Destinations page
    2. Click Client Apps and click DemoClientApp to display the details pane.

      Client app name and Copy and Show buttons

      (1)

      Client app name

      Displays client app details.

      (2)

      Copy buttons

      Copies the client app ID or client secret value.

      (3)

      Show button

      Displays the client secret value.

    3. Copy the client app ID and client secret values from the details pane to the Anypoint MQ Configuration window in Studio:

      URL, Client App ID, and Client Secret fields and Test Connection button in Anypoint MQ Config window
  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 Anypoint Platform Deploying Application window, click Deploy Application:

    Deploy Application button in the Deploying Applications page

You have successfully used Studio 7 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 App

After you create the app in Studio 7, you test your app using a curl command to submit a REST API command to the Anypoint MQ Broker API and 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 its details in the right pane.

  3. Copy the App url value:

    App url value in Runtime Manager
  4. Run the following 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.

    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 the /mq{messageId} value in the HTTP Listener, which is the identifier for your message.

    If you see a 404 message for destination not found, verify that the name of the queue in the Studio 7 MQ Publish > Destination field 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 and selecting Anypoint Platform > Deploy to CloudHub.

  5. In Anypoint Platform > MQ > Destinations, click the name of the myDemoQueue queue that you created earlier and specified in the Destination setting for your app in Studio 7.

  6. Click the Message Browser navigation menu:

    Message Browser navigation menu
  7. Specify the number of messages (1-500) and the time to poll (1-3600 seconds).

  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, payload in the details pane, and icons representing Return Messages, Delete, Full Screen, and close details pane (X)

    (1)

    Selected message.

    (2)

    Message payload in the details pane.

    (3)

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

    (4)

    Delete icon

    Deletes the selected message.

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

    (5)

    Full Screen icon

    Displays the message payload in a separate window.

    (6)

    Close icon

    Closes the details pane.

    If the Message Browser displays Message cannot be deleted when you delete a message, the message time-to-live (TTL) has expired.

    Payloads larger than 1 MB don’t appear in the Message Browser. You can retrieve them with the Anypoint Broker API. See Example: Retrieve a Message.
  10. Try changing the body text in the curl command and repeat the steps to view the message.

You can now configure Anypoint MQ in Studio 7, submit REST API commands to the Anypoint MQ Broker API, and use Anypoint MQ to view the results.

Studio 7 XML

You can use this XML to create the mq-demo app in Studio 7.

Click Configuration XML tab in Studio and compare your XML to the following. Make corrections if needed.

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

<mule xmlns:anypoint-mq="http://www.mulesoft.org/schema/mule/anypoint-mq" xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/anypoint-mq http://www.mulesoft.org/schema/mule/anypoint-mq/current/mule-anypoint-mq.xsd">
	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="0778dad7-d959-4396-8532-883a6c230501" >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>
	<anypoint-mq:config name="Anypoint_MQ_Config" doc:name="Anypoint MQ Config" doc:id="973e27ca-beff-4510-88d8-11a05053355b" >
		<anypoint-mq:connection url="https://mq-us-east-1.qax.anypoint.mulesoft.com/api/v1" clientId="CLIENT-ID" clientSecret="CLIENT-SECRET" />
	</anypoint-mq:config>
	<flow name="mq-demoFlow" doc:id="1e7b7e94-0759-4a2f-83f0-f425ca95b571" >
		<http:listener doc:name="Listener" doc:id="57828e3a-d5c0-4b94-ac82-84e2c0e4dd2e" config-ref="HTTP_Listener_config" path="/mq/{messageId}"/>
		<anypoint-mq:publish doc:name="Publish" doc:id="17060fa4-d043-4b2f-bc5b-ecc3c905f5a2" destination="myDemoQueue" config-ref="Anypoint_MQ_Config"/>
	</flow>
</mule>

Create and Connect a Mule 3 App to Anypoint MQ in Anypoint Studio 6

If you use Mule 3, you can use Anypoint Studio 6 to create a Mule 3 app similar to the app you created in Design Center. In Studio 6, you can deploy the app to CloudHub and submit a curl command to test the connection.

This section applies only to Anypoint Studio 6. For Studio 7, see Create and Connect a Mule 4 App to Anypoint MQ in Anypoint Studio 7.

Prerequisites

  • Install Studio 6.

  • 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 a Mule 3 App with Anypoint MQ in Anypoint Studio 6

To configure a Mule 3 app in Studio 6:

  1. Start Studio, click File > New > Mule Project, name the project mq-demo-studio-6, and then click Finish.

  2. Install the Anypoint MQ Connector:

    1. Click the Exchange icon in the toolbar:

      Exchange icon in the Studio 6 toolbar
    2. Enter your Anypoint Platform username and password.

  3. In Exchange, click the Provided by MuleSoft navigation menu, select Connectors from the drop-down menu, and then search for Anypoint MQ Connector:

    Provided by MuleSoft menu, Connectors drop-down menu, and search field in Exchange
    1. Select Anypoint MQ Connector - Mule 3.

      Studio 6 supports Mule 3.

    2. Click Install:

      Install icon on the Exchange page
    3. At the prompt, check the items to install and click Next twice.

    4. Accept the license agreement and click Finish.

    5. At the prompt, click Restart Now to finish installing the connector.

  4. In the Mule Palette, drag HTTP to the Studio canvas:

    HTTP Connector in Mule Palette
  5. In the Mule Palette:

    1. Search for set, and then drag Set Payload to the Process area to the right of HTTP on the canvas.

    2. Search for mq, and then drag Anypoint MQ to the canvas to the right of Set Payload.

    3. Search for logger, and then drag Logger to the canvas to the right of Anypoint MQ.

      Flow in Studio 6 Canvas
  6. In the canvas, click HTTP.

  7. In the HTTP properties window, set General > Path to /mq/{messageId}:

    HTTP properties window
  8. Click the HTTP connector and click the green plus icon (+) to the right of Connector Configuration.

  9. In the HTTP Connector Global Element Properties window, verify that Host is set to 0.0.0.0 and Port is set to 8081, and then click OK.

    The HTTP properties window now indicates that there are no errors.

  10. In the canvas, click Set Payload.

  11. In the Set Payload properties window, set General > Value to:

    #[message.inboundProperties.'http.uri.params'.messageId]
    Payload in the Value field
  12. In the canvas, click Anypoint MQ.

  13. In the Anypoint MQ properties window, click the green plus icon (+) to the right of Connector Configuration.

  14. Return to your Anypoint Platform > MQ browser window to copy the URL, client app ID, and client secret values:

    1. Click Destinations and copy the URL to the URL field in Studio:

      Copy button in the Destinations page
    2. Click Client Apps and click DemoClientApp to display the details pane.

      Client app name and Copy and Show buttons

      (1)

      Client app name

      Displays client app details.

      (2)

      Copy buttons

      Copies the client app ID or client secret value.

      (3)

      Show button

      Displays the client secret value.

    3. Copy the client app ID and client secret values from the details pane to the Anypoint MQ Configuration window in Studio:

      URL, Client App ID, and Client Secret fields in the Anypoint MQ Configuration window
  15. Click OK.

  16. In the Anypoint MQ properties window, click the Operation field and select publish from the menu:

    Operation and Destination fields in the Anypoint MQ properties window
  17. Set Destination to the myDemoQueue queue that you created earlier in Anypoint Platform > MQ.

    The queue must be in an environment other than Design.

  18. In the canvas, click Logger.

  19. In the Logger properties window, set General > Message to MQ Message: #[payload]:

    Message payload in Logger properties
  20. Save your project.

  21. In Package Explorer in Studio, right-click mq-demo-studio-6 and select Anypoint Platform > Deploy to Cloud.

  22. At the prompt, select the environment to which to deploy the app.

  23. In the Anypoint Platform Deploying Application window, click Deploy Application:

    Deploy Application button on the Deploying Applications page
    Figure 1. The arrow shows the Deploy Application button on the Deploying Applications page.

You have successfully used Studio 6 to configure a Mule 3 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 3 App in Studio 6

To test your Mule 3 app, follow the steps in Test Your App to use a curl command to submit a REST API command to the Anypoint MQ Broker API and use Anypoint MQ to view the results.

Studio 6 XML

After you configure your app using the Anypoint MQ Connector, you can check your configuration against this XML.

Click Configuration XML in Studio and compare your XML to the following. If needed, you can make corrections.

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

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:anypoint-mq="http://www.mulesoft.org/schema/mule/anypoint-mq" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
  xmlns:spring="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/anypoint-mq http://www.mulesoft.org/schema/mule/anypoint-mq/current/mule-anypoint-mq.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <anypoint-mq:config name="Anypoint_MQ_Configuration" doc:name="Anypoint MQ Configuration">
        <anypoint-mq:provider url="https://mq-us-east-1.anypoint.mulesoft.com/api/v1" clientId="CLIENT_ID" clientSecret="CLIENT_SECRET"/>
    </anypoint-mq:config>
    <flow name="mq-demo-studio-6Flow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/mq/{messageId}" doc:name="HTTP"/>
        <set-payload value="#[message.inboundProperties.'http.uri.params'.messageId]" doc:name="Set Payload"/>
        <anypoint-mq:publish config-ref="Anypoint_MQ_Configuration" destination="myDemoQueue" doc:name="Anypoint MQ"/>
        <logger message="MQ Message: #[payload]" level="INFO" doc:name="Logger"/>
    </flow>
</mule>

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub
Submit your feedback!
Share your thoughts to help us build the best documentation experience for you!
Take our latest survey!