Child pages
  • MQTT
Skip to end of metadata
Go to start of metadata

MQTT Component

Available as of Camel 2.10

The mqtt: component is used for communicating with MQTT compliant message brokers, like Apache ActiveMQ or Mosquitto

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

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

URI format

mqtt://name[?options]

Where name is the name you want to assign the component.

Options

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

Samples

Sending messages:

from("direct:foo").to("mqtt:cheese?publishTopicName=test.mqtt.topic");

Consuming messages:

from("mqtt:bar?subscribeTopicName=test.mqtt.topic").transform(body().convertToString()).to("mock:result")

Endpoints

Camel supports the Message Endpoint pattern using the Endpoint interface. Endpoints are usually created by a Component and Endpoints are usually referred to in the DSL via their URIs.

From an Endpoint you can use the following methods

See Also

  • No labels