cMQTT
brokers.
cMQTT Standard properties
These properties are used to configure cMQTT running in the Standard Job framework.
The Standard
cMQTT component belongs to the Connectivity family.
Basic settings
ConnectionFactory |
This option appears when Use Connection |
Topic Name |
Type in a name for the message topic in the message broker. |
Advanced settings
Parameters |
Set the optional parameters in the corresponding table. Click |
Usage
Usage rule |
cMQTT can be a start, middle or |
Limitation |
Due to license incompatibility, one or more JARs required to use |
Sending messages to and receiving messages from an MQTT broker
This scenario applies only to Talend Open Studio for ESB, Talend Data Services Platform and Talend Data Fabric.
This scenario will show you how to use the cMQTT component
to send messages to and consume messages from an MQTT broker. To do this, two Routes are
built, a message producer Route, and a consumer Route. Messages are sent to the MQTT
broker in the producer Route and then consumed in the consumer Route.
In this use case, Apache ActiveMQ is used as the message broker which supports the MQTT
protocol. You need to launch the ActiveMQ server before executing the Route. For more
information about installing and launching ActiveMQ server, see the site http://activemq.apache.org/index.html.
Building the producer Route
Dropping and linking the components
-
From the Palette, drag and drop a
cMQConnectionFactory, a cTimer, a cSetBody, a cMQTT, and a
cLog component onto the design
workspace. -
Label the components for better identification of their roles and link
them with the Row > Route connection as shown above.
Configuring the components
-
Double-click the cMQConnectionFactory
component to display its Basic settings
view in the Component tab. -
From the MQ Server list, select MQTT to handle messages.
In the Host Name field, keep the default value “127.0.0.1” as the local ActiveMQ server is
used as the message broker in this example.In the Port field, keep the default
1883.Keep the default settings of the other options. -
Double-click the cTimer component to open
its Basic settings view in the Component tab. -
In the Repeat field, enter
5
to generate the message exchange five times. Keep the default settings of
the other options. -
Double-click the cSetBody component to
open its Basic settings view in the
Component tab. -
Select SIMPLE from the Language list box and type in
"Hello
in the Expression field
world"
as the message body. -
Double-click the cMQTT component to open its Basic settings view in the Component tab.
-
In the ConnectionFactory field, click
[…] and select the MQ connection
factory that you have just configured to handle messages.In the Topic Name field, type in a name
for the topic, for example"mytopic"
. -
Keep the default settings of the cLog component to
log the message exchanges. - Press Ctrl+S to save your Route.
Viewing the code
design workspace to check the generated code.
cTimer_1
is given a payload bycSetBody_1
and then sent to cMQTT_1
andcLog_1
.Building the consumer Route
Arranging the flow of the message
-
From the Palette, drag and drop a cMQConnectionFactory, a cMQTT, and a cLog component
onto the design workspace. -
Label the components for better identification of their roles and link
them with the Row > Route connection as shown above.
Configuring how the message is processed
-
Double-click the cMQConnectionFactory
component to display its Basic settings
view in the Component tab. -
Configure the cMQConnectionFactory
component as the one in the producer Route to connect to the same MQTT
broker. -
Double-click the cMQTT component to
display its Basic settings view in the
Component tab. -
In the ConnectionFactory field, click
[…] and select the MQ connection
factory that you have just configured to handle messages.Specify the same Topic Name in the
consumer cMQTT component as in the
producer. -
Keep the default settings of the cLog component to
log the message exchanges. - Press Ctrl+S to save your Route.
Viewing the code and executing the Route
-
Click the Code tab at the bottom of the
design workspace to check the generated code.As shown above, the message flow is routed fromcMQTT_1
to
cLog_1
. -
Press F6 to execute the Route. In the execution console
you can see that there’s no message exchange yet. -
Execute the producer Route. The logs of the message exchange are printed
in the console. -
In the consumer Route, the messages are consumed and shown in the execution
console. -
In the ActiveMQ Web Console, you can see that the topic
mytopic has been created and the messages are
consumed.