You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Paho Component

 

Available as of Camel 2.16 

Paho component provides connector for the MQTT messaging protocol using the Paho library.

Adding the component to the project

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-paho</artifactId>
    <version>x.y.z</version>
    <!-- use the same version as your Camel core version -->
</dependency>

URI format

paho:queueName[?options]

You can append query options to the URI in the following format: ?option=value&option=value&... .

URI Options

Option

Default

Description

clientIdcamel-<timestamp>MQTT client identifier.

brokerUrl

tcp://localhost:1883

The URL of the MQTT broker.

persistencememoryClient persistence to be used - memory or file.
qos2Client quality of service level (0-2).
connectOptionsnoneThe reference to the org.eclipse.paho.client.mqttv3.MqttConnectOptions instance located in the Camel registry. Referenced MqttConnectOptions instance will be used by the endpoint to initialize the connection. For example connectOptions=#myConnectOptions notation can be used to reference Spring bean named myConnectOptions.

Examples

Read messages from the MQTT broker installed on the same host as the Camel router:

Car.java
from("paho:some/queue").
  to("mock:test");

Read messages from the remote MQTT broker: 

Car.java
from("paho:some/queue?brokerUrl=tcp://iot.eclipse.org:1883").
  to("mock:test");

Send message to the MQTT broker:

Car.java
from("direct:test").
  to("paho:some/target/queue");


  • No labels