Message Image  

Learn how to use MQTT in enterprise message flows in IBM® App Connect on IBM Cloud™

 View Only
Thu July 23, 2020 06:06 AM

In IBM® App Connect on IBM Cloud™ you can deploy integrations to run enterprise message flows to directly access your secure MQTT for processing, enabling flows in the cloud to connect to applications and devices that send and receive messages by using the MQ Telemetry Transport (MQTT) messaging protocol.

Screenshot_2020-06-03_at_11_08_37.png

Scenario:

You want an enterprise message flow to directly access your secure MQTT for processing, and want the message flow to run in App Connect on IBM Cloud. You can deploy message flows that use MQTT to run in App Connect on IBM Cloud plans that provide enterprise capabilities.

First, find or create everything you need:

Procedure

  1. Import the BAR file from the archive file MQTT-with-SSL.zip into your instance of App Connect on IBM Cloud. This creates an Integration server.

    Screenshot_2020-06-03_at_11_09_19.png

  2. Click the integration server tile to display its contents and attached policies.
  3. Click Attached Policies at the top of the page and with the flow stopped, click Manage and then Create and attach a policy.
  4. Select the Truststore Certificate policy type and then give the policy a name. This name can be anything and is only used as a way of identifying the policy in the UI.
  5. Upload the certificate (PEM format) provided in the archive file above by dragging it into the policy window.
  6. Input the alias to be used in the truststore for this certificate and click Add to add the certificate and alias to the policy.
  7. Click Create to create the policy.
  8. Start the flow. (Select the menu of the Integration server’s tile on the Dashboard, then click Start.)
  9. Open a terminal window and run curl -X POST <URL> -u iib:<PASSWORD> -d "<test><message>ACE is Awesome</message></test>" --insecure substituting the values of <URL> and <PASSWORD> from the credentials of the integration. This command will return something similar to <test><message>ACE is Awesome</message><header>455648540000000004000000ffd14dadd502000000000000</header></test> with a different header.

Troubleshooting

If the certificate is invalid it can be downloaded from test.mosquitto.org as mosquitto.org.der (der format) and will need to be converted to PEM format.

MQTT Brokers with Basic Authentication

  1. Open up the attached Project Interchange (PI) file MQTT-Basic-Auth.zip in the App Connect Enterprise toolkit and open the mqtt message flow.
  2. Double-click the MQTT Publish node and in the Basic tab of the Properties window input your host name and port.
  3. Do the same for the MQTT Subscribe node, double click it and in the Basic tab of the Properties window input your host name and port.
  4. Save and compile the project into a BAR file by right clicking the project and selecting New and BAR file and give it a name.
  5. Import the BAR file into your instance of App Connect on IBM Cloud. This creates an Integration server.
  6. Click the Attach Policy tab and create a policy. Select the MQTT policy type and then give the policy a name. This name can be anything and is only used as a way of identifying the policy in the UI.
  7. Input the Security Identity which should match what is set on the node in the toolkit. In the PI provided it is si1.
  8. Enter the username and password of your MQTT server into the policy and then click Create.
  9. Start the flow by clicking the 3 dots in the top right and Start.
  10. After the flow has started select the `Contents` tab and select Credentials to get the credentials of the integration.
  11. Open a terminal window and run curl -X POST <URL> -u iib:<PASSWORD> -d "<test><message>ACE is Awesome</message></test>" --insecure substituting the values of <URL> and <PASSWORD> from the credentials of the integration. This command will return something similar to <test><message>ACE is Awesome</message><header>455648540000000004000000ffd14dadd502000000000000</header></test> with a different header.

#AppConnect
#MQTT
#AppConnect-IBMCloud