--- apiVersion: v1 kind: List items: - apiVersion: v1 kind: ConfigMap metadata: labels: funktion.fabric8.io/kind: Connector provider: fabric8 project: connector-mqtt version: 1.1.9 group: io.fabric8.funktion.connector name: mqtt data: deployment.yml: | --- apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: funktion.fabric8.io/kind: Subscription connector: mqtt spec: replicas: 1 template: metadata: labels: funktion.fabric8.io/kind: Subscription connector: mqtt spec: containers: - image: fabric8/connector-mqtt:1.1.9 name: connector schema.yml: | --- component: kind: component scheme: mqtt syntax: mqtt:name title: MQTT description: Component for communicating with MQTT M2M message brokers using FuseSource MQTT Client. label: messaging,iot deprecated: false async: true javaType: org.apache.camel.component.mqtt.MQTTComponent groupId: org.apache.camel artifactId: camel-mqtt version: 2.18.1 componentProperties: host: kind: property type: string javaType: java.lang.String deprecated: false secret: false description: The URI of the MQTT broker to connect too - this component also supports SSL - e.g. ssl://127.0.0.1:8883 userName: kind: property type: string javaType: java.lang.String deprecated: false secret: false description: Username to be used for authentication against the MQTT broker password: kind: property type: string javaType: java.lang.String deprecated: false secret: false description: Password to be used for authentication against the MQTT broker properties: name: kind: path group: common required: true type: string javaType: java.lang.String deprecated: false secret: false description: A logical name to use which is not the topic name. blockingExecutor: kind: parameter group: common type: object javaType: java.util.concurrent.Executor deprecated: false secret: false description: SSL connections perform blocking operations against internal thread pool unless you call the setBlockingExecutor method to configure that executor they will use instead. byDefaultRetain: kind: parameter group: common type: boolean javaType: boolean deprecated: false secret: false defaultValue: false description: The default retain policy to be used on messages sent to the MQTT broker cleanSession: kind: parameter group: common type: boolean javaType: boolean deprecated: false secret: false defaultValue: false description: Set to false if you want the MQTT server to persist topic subscriptions and ack positions across client sessions. Defaults to true. clientId: kind: parameter group: common type: string javaType: java.lang.String deprecated: false secret: false description: Use to set the client Id of the session. This is what an MQTT server uses to identify a session where setCleanSession(false); is being used. The id must be 23 characters or less. Defaults to auto generated id (based on your socket address port and timestamp). connectAttemptsMax: kind: parameter group: common type: integer javaType: long deprecated: false secret: false defaultValue: -1 description: The maximum number of reconnect attempts before an error is reported back to the client on the first attempt by the client to connect to a server. Set to -1 to use unlimited attempts. Defaults to -1. connectWaitInSeconds: kind: parameter group: common type: integer javaType: int deprecated: false secret: false defaultValue: "10" description: Delay in seconds the Component will wait for a connection to be established to the MQTT broker disconnectWaitInSeconds: kind: parameter group: common type: integer javaType: int deprecated: false secret: false defaultValue: "5" description: The number of seconds the Component will wait for a valid disconnect on stop() from the MQTT broker dispatchQueue: kind: parameter group: common type: object javaType: org.fusesource.hawtdispatch.DispatchQueue deprecated: false secret: false description: A HawtDispatch dispatch queue is used to synchronize access to the connection. If an explicit queue is not configured via the setDispatchQueue method then a new queue will be created for the connection. Setting an explicit queue might be handy if you want multiple connection to share the same queue for synchronization. host: kind: parameter group: common type: string javaType: java.net.URI deprecated: false secret: false defaultValue: tcp://127.0.0.1:1883 description: The URI of the MQTT broker to connect too - this component also supports SSL - e.g. ssl://127.0.0.1:8883 keepAlive: kind: parameter group: common type: integer javaType: short deprecated: false secret: false description: Configures the Keep Alive timer in seconds. Defines the maximum time interval between messages received from a client. It enables the server to detect that the network connection to a client has dropped without having to wait for the long TCP/IP timeout. localAddress: kind: parameter group: common type: string javaType: java.net.URI deprecated: false secret: false description: The local InetAddress and port to use maxReadRate: kind: parameter group: common type: integer javaType: int deprecated: false secret: false description: Sets the maximum bytes per second that this transport will receive data at. This setting throttles reads so that the rate is not exceeded. Defaults to 0 which disables throttling. maxWriteRate: kind: parameter group: common type: integer javaType: int deprecated: false secret: false description: Sets the maximum bytes per second that this transport will send data at. This setting throttles writes so that the rate is not exceeded. Defaults to 0 which disables throttling. mqttQosPropertyName: kind: parameter group: common type: string javaType: java.lang.String deprecated: false secret: false defaultValue: MQTTQos description: The property name to look for on an Exchange for an individual published message. If this is set (one of AtMostOnce AtLeastOnce or ExactlyOnce ) - then that QoS will be set on the message sent to the MQTT message broker. mqttRetainPropertyName: kind: parameter group: common type: string javaType: java.lang.String deprecated: false secret: false defaultValue: MQTTRetain description: The property name to look for on an Exchange for an individual published message. If this is set (expects a Boolean value) - then the retain property will be set on the message sent to the MQTT message broker. mqttTopicPropertyName: kind: parameter group: common type: string javaType: java.lang.String deprecated: false secret: false defaultValue: MQTTTopicPropertyName description: These a properties that are looked for in an Exchange - to publish to publishTopicName: kind: parameter group: common type: string javaType: java.lang.String deprecated: false secret: false defaultValue: camel/mqtt/test description: The default Topic to publish messages on qualityOfService: kind: parameter group: common type: string javaType: java.lang.String enum: - AtMostOnce - AtLeastOne - ExactlyOnce deprecated: false secret: false defaultValue: AtLeastOnce description: Quality of service level to use for topics. receiveBufferSize: kind: parameter group: common type: integer javaType: int deprecated: false secret: false defaultValue: "65536" description: Sets the size of the internal socket receive buffer. Defaults to 65536 (64k) reconnectAttemptsMax: kind: parameter group: common type: integer javaType: long deprecated: false secret: false defaultValue: -1 description: The maximum number of reconnect attempts before an error is reported back to the client after a server connection had previously been established. Set to -1 to use unlimited attempts. Defaults to -1. reconnectBackOffMultiplier: kind: parameter group: common type: number javaType: double deprecated: false secret: false defaultValue: "2.0" description: The Exponential backoff be used between reconnect attempts. Set to 1 to disable exponential backoff. Defaults to 2. reconnectDelay: kind: parameter group: common type: integer javaType: long deprecated: false secret: false defaultValue: "10" description: How long to wait in ms before the first reconnect attempt. Defaults to 10. reconnectDelayMax: kind: parameter group: common type: integer javaType: long deprecated: false secret: false defaultValue: "30000" description: The maximum amount of time in ms to wait between reconnect attempts. Defaults to 30000. sendBufferSize: kind: parameter group: common type: integer javaType: int deprecated: false secret: false defaultValue: "65536" description: Sets the size of the internal socket send buffer. Defaults to 65536 (64k) sendWaitInSeconds: kind: parameter group: common type: integer javaType: int deprecated: false secret: false defaultValue: "5" description: The maximum time the Component will wait for a receipt from the MQTT broker to acknowledge a published message before throwing an exception sslContext: kind: parameter group: common type: object javaType: javax.net.ssl.SSLContext deprecated: false secret: false description: To configure security using SSLContext configuration subscribeTopicName: kind: parameter group: common type: string javaType: java.lang.String deprecated: true secret: false description: These are set on the Endpoint - together with properties inherited from MQTT subscribeTopicNames: kind: parameter group: common type: string javaType: java.lang.String deprecated: false secret: false description: A comma-delimited list of Topics to subscribe to for messages. Note that each item of this list can contain MQTT wildcards ( and/or ) in order to subscribe to topics matching a certain pattern within a hierarchy. For example is a wildcard for all topics at a level within the hierarchy so if a broker has topics topics/one and topics/two then topics/ can be used to subscribe to both. A caveat to consider here is that if the broker adds topics/three the route would also begin to receive messages from that topic. trafficClass: kind: parameter group: common type: integer javaType: int deprecated: false secret: false defaultValue: "8" description: Sets traffic class or type-of-service octet in the IP header for packets sent from the transport. Defaults to 8 which means the traffic should be optimized for throughput. version: kind: parameter group: common type: string javaType: java.lang.String deprecated: false secret: false defaultValue: "3.1" description: Set to 3.1.1 to use MQTT version 3.1.1. Otherwise defaults to the 3.1 protocol version. willMessage: kind: parameter group: common type: string javaType: java.lang.String deprecated: false secret: false description: The Will message to send. Defaults to a zero length message. willQos: kind: parameter group: common type: string javaType: org.fusesource.mqtt.client.QoS enum: - AtMostOnce - AtLeastOne - ExactlyOnce deprecated: false secret: false defaultValue: AtMostOnce description: Sets the quality of service to use for the Will message. Defaults to AT_MOST_ONCE. willRetain: kind: parameter group: common type: string javaType: org.fusesource.mqtt.client.QoS enum: - AT_MOST_ONCE - AT_LEAST_ONCE - EXACTLY_ONCE deprecated: false secret: false description: Set to true if you want the Will to be published with the retain option. willTopic: kind: parameter group: common type: string javaType: java.lang.String deprecated: false secret: false description: If set the server will publish the client's Will message to the specified topics if the client has an unexpected disconnection. bridgeErrorHandler: kind: parameter group: consumer label: consumer type: boolean javaType: boolean optionalPrefix: consumer. deprecated: false secret: false defaultValue: false description: Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored. exceptionHandler: kind: parameter group: consumer (advanced) label: consumer,advanced type: object javaType: org.apache.camel.spi.ExceptionHandler optionalPrefix: consumer. deprecated: false secret: false description: To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored. exchangePattern: kind: parameter group: consumer (advanced) label: consumer,advanced type: string javaType: org.apache.camel.ExchangePattern enum: - InOnly - RobustInOnly - InOut - InOptionalOut - OutOnly - RobustOutOnly - OutIn - OutOptionalIn deprecated: false secret: false description: Sets the exchange pattern when the consumer creates an exchange. synchronous: kind: parameter group: advanced label: advanced type: boolean javaType: boolean deprecated: false secret: false defaultValue: false description: Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). documentation.adoc: |+ [[MQTT-MQTTComponent]] MQTT Component ~~~~~~~~~~~~~~ *Available as of Camel 2.10* The *mqtt:* component is used for communicating with http://mqtt.org[MQTT] compliant message brokers, like http://activemq.apache.org[Apache ActiveMQ] or http://mosquitto.org[Mosquitto] Maven users will need to add the following dependency to their `pom.xml` for this component: [source,xml] ------------------------------------------------------------ org.apache.camel camel-mqtt x.x.x ------------------------------------------------------------ [[MQTT-URIformat]] URI format ^^^^^^^^^^ [source,java] --------------------- mqtt://name[?options] --------------------- Where *name* is the name you want to assign the component. [[MQTT-Options]] Options ^^^^^^^ // component options: START The MQTT component supports 3 options which are listed below. {% raw %} [width="100%",cols="2,1m,7",options="header"] |======================================================================= | Name | Java Type | Description | host | String | The URI of the MQTT broker to connect too - this component also supports SSL - e.g. ssl://127.0.0.1:8883 | userName | String | Username to be used for authentication against the MQTT broker | password | String | Password to be used for authentication against the MQTT broker |======================================================================= {% endraw %} // component options: END // endpoint options: START The MQTT component supports 39 endpoint options which are listed below: {% raw %} [width="100%",cols="2,1,1m,1m,5",options="header"] |======================================================================= | Name | Group | Default | Java Type | Description | name | common | | String | *Required* A logical name to use which is not the topic name. | blockingExecutor | common | | Executor | SSL connections perform blocking operations against internal thread pool unless you call the setBlockingExecutor method to configure that executor they will use instead. | byDefaultRetain | common | false | boolean | The default retain policy to be used on messages sent to the MQTT broker | cleanSession | common | false | boolean | Set to false if you want the MQTT server to persist topic subscriptions and ack positions across client sessions. Defaults to true. | clientId | common | | String | Use to set the client Id of the session. This is what an MQTT server uses to identify a session where setCleanSession(false); is being used. The id must be 23 characters or less. Defaults to auto generated id (based on your socket address port and timestamp). | connectAttemptsMax | common | -1 | long | The maximum number of reconnect attempts before an error is reported back to the client on the first attempt by the client to connect to a server. Set to -1 to use unlimited attempts. Defaults to -1. | connectWaitInSeconds | common | 10 | int | Delay in seconds the Component will wait for a connection to be established to the MQTT broker | disconnectWaitInSeconds | common | 5 | int | The number of seconds the Component will wait for a valid disconnect on stop() from the MQTT broker | dispatchQueue | common | | DispatchQueue | A HawtDispatch dispatch queue is used to synchronize access to the connection. If an explicit queue is not configured via the setDispatchQueue method then a new queue will be created for the connection. Setting an explicit queue might be handy if you want multiple connection to share the same queue for synchronization. | host | common | tcp://127.0.0.1:1883 | URI | The URI of the MQTT broker to connect too - this component also supports SSL - e.g. ssl://127.0.0.1:8883 | keepAlive | common | | short | Configures the Keep Alive timer in seconds. Defines the maximum time interval between messages received from a client. It enables the server to detect that the network connection to a client has dropped without having to wait for the long TCP/IP timeout. | localAddress | common | | URI | The local InetAddress and port to use | maxReadRate | common | | int | Sets the maximum bytes per second that this transport will receive data at. This setting throttles reads so that the rate is not exceeded. Defaults to 0 which disables throttling. | maxWriteRate | common | | int | Sets the maximum bytes per second that this transport will send data at. This setting throttles writes so that the rate is not exceeded. Defaults to 0 which disables throttling. | mqttQosPropertyName | common | MQTTQos | String | The property name to look for on an Exchange for an individual published message. If this is set (one of AtMostOnce AtLeastOnce or ExactlyOnce ) - then that QoS will be set on the message sent to the MQTT message broker. | mqttRetainPropertyName | common | MQTTRetain | String | The property name to look for on an Exchange for an individual published message. If this is set (expects a Boolean value) - then the retain property will be set on the message sent to the MQTT message broker. | mqttTopicPropertyName | common | MQTTTopicPropertyName | String | These a properties that are looked for in an Exchange - to publish to | publishTopicName | common | camel/mqtt/test | String | The default Topic to publish messages on | qualityOfService | common | AtLeastOnce | String | Quality of service level to use for topics. | receiveBufferSize | common | 65536 | int | Sets the size of the internal socket receive buffer. Defaults to 65536 (64k) | reconnectAttemptsMax | common | -1 | long | The maximum number of reconnect attempts before an error is reported back to the client after a server connection had previously been established. Set to -1 to use unlimited attempts. Defaults to -1. | reconnectBackOffMultiplier | common | 2.0 | double | The Exponential backoff be used between reconnect attempts. Set to 1 to disable exponential backoff. Defaults to 2. | reconnectDelay | common | 10 | long | How long to wait in ms before the first reconnect attempt. Defaults to 10. | reconnectDelayMax | common | 30000 | long | The maximum amount of time in ms to wait between reconnect attempts. Defaults to 30000. | sendBufferSize | common | 65536 | int | Sets the size of the internal socket send buffer. Defaults to 65536 (64k) | sendWaitInSeconds | common | 5 | int | The maximum time the Component will wait for a receipt from the MQTT broker to acknowledge a published message before throwing an exception | sslContext | common | | SSLContext | To configure security using SSLContext configuration | subscribeTopicName | common | | String | These are set on the Endpoint - together with properties inherited from MQTT | subscribeTopicNames | common | | String | A comma-delimited list of Topics to subscribe to for messages. Note that each item of this list can contain MQTT wildcards ( and/or ) in order to subscribe to topics matching a certain pattern within a hierarchy. For example is a wildcard for all topics at a level within the hierarchy so if a broker has topics topics/one and topics/two then topics/ can be used to subscribe to both. A caveat to consider here is that if the broker adds topics/three the route would also begin to receive messages from that topic. | trafficClass | common | 8 | int | Sets traffic class or type-of-service octet in the IP header for packets sent from the transport. Defaults to 8 which means the traffic should be optimized for throughput. | version | common | 3.1 | String | Set to 3.1.1 to use MQTT version 3.1.1. Otherwise defaults to the 3.1 protocol version. | willMessage | common | | String | The Will message to send. Defaults to a zero length message. | willQos | common | AtMostOnce | QoS | Sets the quality of service to use for the Will message. Defaults to AT_MOST_ONCE. | willRetain | common | | QoS | Set to true if you want the Will to be published with the retain option. | willTopic | common | | String | If set the server will publish the client's Will message to the specified topics if the client has an unexpected disconnection. | bridgeErrorHandler | consumer | false | boolean | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored. | exceptionHandler | consumer (advanced) | | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored. | exchangePattern | consumer (advanced) | | ExchangePattern | Sets the exchange pattern when the consumer creates an exchange. | synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). |======================================================================= {% endraw %} // endpoint options: END [[MQTT-Samples]] Samples ^^^^^^^ Sending messages: [source,java] ---------------------------------------------------------------------- from("direct:foo").to("mqtt:cheese?publishTopicName=test.mqtt.topic"); ---------------------------------------------------------------------- Consuming messages: [source,java] --------------------------------------------------------------------------------------------------------- from("mqtt:bar?subscribeTopicName=test.mqtt.topic").transform(body().convertToString()).to("mock:result") --------------------------------------------------------------------------------------------------------- [[MQTT-Endpoints]] Endpoints ~~~~~~~~~ Camel supports the link:message-endpoint.html[Message Endpoint] pattern using the http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Endpoint.html[Endpoint] interface. Endpoints are usually created by a link:component.html[Component] and Endpoints are usually referred to in the link:dsl.html[DSL] via their link:uris.html[URIs]. From an Endpoint you can use the following methods * http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Endpoint.html#createProducer()[createProducer()] will create a http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Producer.html[Producer] for sending message exchanges to the endpoint * http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Endpoint.html#createConsumer(org.apache.camel.Processor)[createConsumer()] implements the link:event-driven-consumer.html[Event Driven Consumer] pattern for consuming message exchanges from the endpoint via a http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Processor.html[Processor] when creating a http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Consumer.html[Consumer] * http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Endpoint.html#createPollingConsumer()[createPollingConsumer()] implements the link:polling-consumer.html[Polling Consumer] pattern for consuming message exchanges from the endpoint via a http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/PollingConsumer.html[PollingConsumer] [[MQTT-SeeAlso]] See Also ^^^^^^^^ * link:configuring-camel.html[Configuring Camel] * link:message-endpoint.html[Message Endpoint] pattern * link:uris.html[URIs] * link:writing-components.html[Writing Components]