Contact Free trial Login

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
    Figure 1. The arrow shows the environment button in the left pane.
  4. Click Destinations:

    Destinations option and blue plus icon
    Figure 2. The screen shows (1) the Destinations option and (2) the blue plus icon (+).
  5. Click the blue plus icon (+) to display the menu:

    Blue plus icon choices
    Figure 3. The screen shows the blue plus icon menu.
  6. Select Queue.

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

    Create Queue window
    Figure 4. The screen shows the 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.

    The queue is created and appears in the Destinations page:

    Destinations page with new queue
    Figure 5. The Destinations page shows (1) the ID, (2) type, and (3) details label for the queue.

    From this page, you can:

    • Click the queue type (1) for the new queue to display its details in the right pane.

    • Click the queue ID (2) or details label (3) to display 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 to display the Queue Settings page.

  2. Click Message Sender in the left pane:

    Message Sender option
    Figure 6. The arrow shows the Message Sender option in the left pane.
  3. Enter Hello Mules! in the Payload field.

    Leave the Type field set to Text.

  4. Click Send.

  5. Set the Type to JSON.

  6. Set the Payload to:

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

  8. Set the Type to CSV.

  9. Set the Payload to:

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

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

  11. Click Destinations.

  12. Click the queue type for myDemoQueue to display its details in the right pane.

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

    Three messages in the myDemoQueue queue in the details pane
    Figure 7. The arrow shows the three messages that you sent to the myDemoQueue queue in the details pane.
  13. In the Destinations page, click myDemoQueue.

  14. In the Queue Settings page, click Message Browser in the left pane:

    Message Browser option and Get Messages button
    Figure 8. The screen shows (1) the Message Browser option and (2) the Get Messages button.
  15. Click Get Messages.

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

    Selected message row
    Figure 9. The screen shows (1) the message row, (2) the message payload in the details pane, (3) the Return Messages icon, and (4) the trash can icon.
    • Click the Return Messages icon to return the message to the queue (for example, to enable other applications to read the message).

      If you return to the Message Sender page or Destinations page, messages automatically return to the queue.

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

    • Click the trash can icon to delete the 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
    Figure 10. The screen shows (1) the Client Apps option and (2) blue plus icon (+) icon.
  3. Click the blue plus icon (+).

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

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

    Client App ID field
    Figure 11. The screen shows (1) the Client App ID field, and (2) the Show and (3) Copy buttons.

    The client secret value is obfuscated unless you click Show.

  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 the Create button to create a new project.

    In the create window, select Create new application:

    Create new application option
    Figure 12. The arrow shows the Create new application option.
  3. In the New Mule Application window, enter mqdemo for the project name and click Create.

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

    Go straight to canvas
    Figure 13. The arrow shows the Go straight to canvas option.
  5. Click the Trigger box and enter H to search for the HTTP Listener:

    Search for the HTTP Listener
    Figure 14. The arrow shows 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 button (X):

    Path value and Close button
    Figure 15. The screen shows (1) the Path value and (2) the Close button (X).
  8. Click the plus icon (+) to the right of the HTTP Listener trigger:

    Plus icon
    Figure 16. The arrow shows the plus icon (+).
  9. In the Select a component window, enter Mu to search for the Mule Anypoint MQ Connector:

    Search for the Mule Anypoint MQ Connector
    Figure 17. The arrow shows the Mule Anypoint MQ Connector.
  10. Click the Publish operation:

    Publish operation
    Figure 18. The arrow shows the 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 tab, specify myDemoQueue in the Destination field.

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

    Destination field and setup link
    Figure 19. The screen shows (1) the Destination field and (2) the Click here to set it up link.
  12. Click Click here to set it up.

  13. Copy the client app ID and client secret from your Anypoint Platform > MQ browser window:

    Client App ID field
    Figure 20. The screen shows (1) the Client App ID field, (2) Show button, and (3) Copy button in the Client Apps details pane.
    1. In the MQ page, click Client Apps and click DemoClientApp to display the details pane.

    2. In the MQ details pane, click the Copy button for the Client App ID field and paste the value in the Client App ID field in the Design Center page.

    3. In the MQ details pane, click the Copy button for the Client Secret field and paste the value in the Client Secret field in the Design Center page:

      Client App ID field and Client Secret field
      Figure 21. The screen shows (1) the Client App ID field and (2) Client Secret field in the Design Center page.
  14. Click Test to ensure that you have access to your client app:

    Success box
    Figure 22. The arrow shows the 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:

      Copy button in the Destinations page
      Figure 23. The arrow shows the Copy button in the Anypoint MQ Destinations page.
  15. Click Save.

  16. Click the Close button (X) to close the Publish Configuration window:

    Close button
    Figure 24. The arrow shows the Close button (X).
  17. Select Deploy Application from the menu to the right of the Test button:

    Deploy Application menu option
    Figure 25. The arrow shows the Deploy Application menu option in Design Center.
  18. In the Deploy Mule application window, select the target environment and application name, and then click Deploy.

    The app starts running in a temporary environment.

    The mqdemo app running in a temporary environment
    Figure 26. The arrow shows a message indicating the mqdemo app is running in a temporary environment.

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
    Figure 27. The arrow shows the deployment URL in the details pane for your app in Design Center.
  2. Copy 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. 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 Design Center.

  5. Click Message Browser in the left menu:

    Message Browser option and Get Messages button
    Figure 28. The screen shows (1) the Message Browser option and (2) the Get Messages button for getting messages from the myDemoQueue queue.
  6. Click Get Messages.

  7. Click the message row to view the message payload that you sent in the curl command in the details pane:

    Selected message row and payload in the details pane
    Figure 29. The screen shows (1) the message row and (2) the message payload in the details pane.
  8. 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, you use Studio 7 to configure an app that connects to Anypoint MQ.

To configure an app in Studio:

  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
    Figure 30. The arrow shows the Exchange icon in the Studio 7 toolbar.
  3. Enter your Anypoint Platform username and password.

  4. In Exchange, select Provided by MuleSoft, and then search for the Anypoint MQ Connector:

    Provided by MuleSoft option and search field in Exchange
    Figure 31. The screen shows (1) the Provided by MuleSoft option and (2) the search field.
  5. Select Anypoint MQ Connector - Mule 4.

    Studio 7 supports Mule 4.

  6. Click Add to project:

    Add to project icon in Exchange
    Figure 32. The arrow shows the Add to project icon in Exchange.
  7. At the confirmation prompt, click Proceed and then click OK.

  8. In the Mule Palette view, click HTTP, and then drag the Listener to the Studio canvas:

    HTTP Connector and Listener operations in Mule Palette
    Figure 33. The screen shows (1) the HTTP Connector and (2) the Listener operation.
  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
    Figure 34. The arrow shows the 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
    Figure 35. The screen shows (1) the Path property and (2) the Connector configuration icon for the Listener.
  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 0.0.0.0 and Port is set to 8081, and then click OK.

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

  14. In the canvas, click Publish.

  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
    Figure 36. The screen shows (1) the Destination property of the Publish operation and (2) the green plus icon (+) for connector configuration.

    The queue must be in an environment other than Design.

  16. Click the green plus icon (+) to the right of the Connector configuration field.

  17. Click Copy in the Destinations page in Anypoint MQ to copy the URL and paste it in the Destination field in Studio:

    Copy button in the Destinations page
    Figure 37. The arrow shows the Copy button in the Anypoint MQ Destinations page.
  18. Copy the client app ID and client secret from the Client Apps page in Anypoint MQ to Studio:

    Client App ID field
    Figure 38. The screen shows (1) the Client App ID field, (2) Show button, and (3) Copy button.
    1. In the MQ page, click Client Apps and click DemoClientApp to display the details pane.

    2. In the MQ details pane, click the Copy button for the Client App ID field and paste the value in the Client App ID field in the Anypoint MQ Config window.

    3. In the MQ details pane, click the Copy button for the Client Secret field and paste the value in the Client Secret field in Anypoint MQ Config window:

      URL
      Figure 39. The screen shows (1) the URL field, (2) the Client App ID field, (3) the Client Secret field, and (4) the Test Connection button.
  19. Click Test Connection to ensure that the values are correct, and then click OK twice.

  20. Save your project.

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

  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 in the Deploying Applications page
    Figure 40. The arrow shows the 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 in Runtime Manager
    Figure 41. The arrow shows App url in the details pane 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": "Message via Runtime Manager"
      }
    ]'

    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 Message Browser in the left menu:

    Message Browser option and Get Messages button
    Figure 42. The screen shows (1) the Message Browser option and (2) the Get Messages button for getting messages from the myDemoQueue queue.
  7. Click Get Messages.

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

    Selected message row and payload in the details pane
    Figure 43. The screen shows (1) the message row and (2) the message payload in the details pane.
  9. 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="fcdcaaf1-fac4-4342-b126-158785965810" >
        <anypoint-mq:connection url="https://mq-us-east-1.qax.anypoint.mulesoft.com/api/v1" clientId="f8f65e21d83544778c9293889a74bcc0" clientSecret="d3B290FAe0474e80b7E42178FB43CA75" />
    </anypoint-mq:config>
    <anypoint-mq:config name="Anypoint_MQ_Config1" doc:name="Anypoint MQ Config" doc:id="d23f7edd-6edd-49ec-9a45-6126f1b6c551" >
        <anypoint-mq:connection url="https://mq-us-east-1.qax.anypoint.mulesoft.com/api/v1" clientId="f8f65e21d83544778c9293889a74bcc0" clientSecret="d3B290FAe0474e80b7E42178FB43CA75" />
    </anypoint-mq:config>
    <anypoint-mq:config name="Anypoint_MQ_Config2" doc:name="Anypoint MQ Config" doc:id="ff879c25-59fb-4662-b7e1-d6a879e4a1a1" >
        <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_Config2"/>
    </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 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
      Figure 44. The arrow shows the Exchange icon in the Studio 6 toolbar.
    2. Enter your Anypoint Platform username and password.

    3. In Exchange, select Provided by MuleSoft, and then search for Anypoint MQ Connector:

      Provided by MuleSoft option and search field in Exchange
      Figure 45. The screen shows (1) the Provided by MuleSoft option and (2) the search field.
    4. Select Anypoint MQ Connector - Mule 3.

      Studio 6 supports Mule 3.

    5. Click Install:

      Install icon in Exchange
      Figure 46. The arrow shows the Install icon in the Exchange page.
    6. At the prompt, check the items to install and click Next twice.

    7. Accept the license agreement and click Finish.

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

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

    HTTP Connector in Mule Palette
    Figure 47. The arrow shows the HTTP Connector.
  4. 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 7 Canvas
      Figure 48. The arrow shows the flow in the canvas.
  5. In the canvas, click HTTP.

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

    HTTP properties
    Figure 49. The screen shows (1) the Path property and (2) the Connector configuration icon for the HTTP Connector.
  7. Click the HTTP connector and click the green plus icon (+) to the right of Connector Configuration.

  8. 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:

  9. In the canvas, click Set Payload.

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

    #[message.inboundProperties.'http.uri.params'.messageId]
    Payload in the Value field
    Figure 50. The arrow shows the payload in the Value field.
  11. In the canvas, click Anypoint MQ.

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

  13. In the Anypoint MQ Configuration Global Element Properties window, add the information from Anypoint Platform:

  14. Click Copy in the Destinations page in Anypoint MQ to copy the URL and paste it in the URL field in Studio:

    Copy button on the Destinations page
    Figure 51. The arrow shows the Copy button on the Anypoint MQ Destinations page.
  15. Copy the client app ID and client secret from the Client Apps page in Anypoint MQ to Studio:

    Client App ID field
    Figure 52. The screen shows (1) the Client App ID field, (2) Show button, and (3) Copy button.
    1. In the MQ page, click Client Apps and click DemoClientApp to display the details pane.

    2. In the MQ details pane, click the Copy button for the Client App ID field and paste the value in the Client App ID field in the Anypoint MQ Configuration window.

    3. In the MQ details pane, click the Copy button for the Client Secret field and paste the value in the Client Secret field in Anypoint MQ Configuration window:

      URL
      Figure 53. The screen shows (1) the URL field, (2) the Client App ID field, and (3) the Client Secret field.
  16. Click OK.

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

  18. Set Destination to the myDemoQueue queue that you created earlier in Anypoint Platform > MQ.

    The queue must be in an environment other than Design.

    Operation and Destination properties for the Anypoint MQ configuration
    Figure 54. The screen shows (1) the Operation and Destination properties in the Anypoint MQ properties window.
  19. In the canvas, click Logger.

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

    Message payload in Logger properties
    Figure 55. The arrow shows the Message field in the Logger properties window.
  21. Save your project.

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

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

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

    Deploy Application button on the Deploying Applications page
    Figure 56. 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>

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.