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.
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
- 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.
- Click the integration server tile to display its contents and attached policies.
- Click
Attached Policies
at the top of the page and with the flow stopped, click Manage
and then Create and attach a policy
.
- 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.
- Upload the certificate (PEM format) provided in the archive file above by dragging it into the policy window.
- Input the alias to be used in the truststore for this certificate and click
Add
to add the certificate and alias to the policy.
- Click
Create
to create the policy.
- Start the flow. (Select the menu of the Integration server’s tile on the Dashboard, then click Start.)
- 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
- Open up the attached Project Interchange (PI) file MQTT-Basic-Auth.zip in the App Connect Enterprise toolkit and open the
mqtt
message flow.
- Double-click the
MQTT Publish
node and in the Basic
tab of the Properties
window input your host name and port.
- 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.
- 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.
- Import the BAR file into your instance of App Connect on IBM Cloud. This creates an Integration server.
- 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.
- Input the Security Identity which should match what is set on the node in the toolkit. In the PI provided it is
si1
.
- Enter the username and password of your MQTT server into the policy and then click Create.
- Start the flow by clicking the 3 dots in the top right and
Start
.
- After the flow has started select the `Contents` tab and select
Credentials
to get the credentials of the integration.
- 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.