...
Code Block |
|
<transportConnector name="mqtt" uri="mqtt://localhost:1883?transport.defaultKeepAlive=60000"/> |
Message Prefetch
When MQTT client connects, it locally create JMS-like consumer to the broker. By default this consumer is created with prefetch size of 1 (message prefetching is explained here in more details). Usually, increasing message prefetch size can boost the performance as messages are dispatched to consumers in batches instead of waiting for the individual acknowledges. To increase prefetch size, you can use activeMQSubscriptionPrefetch transport option, like
Code Block |
<transportConnector name="mqtt" uri="mqtt://localhost:1883?transport.activeMQSubscriptionPrefetch=32766"/>
|
Subscription Strategy
ActiveMQ is a JMS broker in its core, so there needs to be some mapping between MQTT subscriptions and JMS semantics. Subscriptions with QoS=0 (At Most Once) are directly mapped to plain JMS non-persistent topics. For reliable messaging, QoS=1 and QoS=2, by default subscriptions are transformed to JMS durable topic subscribers. This behaviour is desired in most scenarios. For some use cases, it is useful to map these subscriptions to virtual topics. Virtual topics provide a better scalability and are generally better solution if you want to use you MQTT subscribers over network of brokers. To change subscription strategy to use virtual topic, use the following settings:
Code Block |
<transportConnector name="mqtt" uri="mqtt://localhost:1883?transport.subscriptionStrategy=mqtt-virtual-topic-subscriptions"/>
|
Retained Messages
If a message has been published with the retain flag set, then the message will be 'remembered' by the topic so that if a new subscription arrives, the last retained message is sent to the subscription. Underneath, the broker uses retained message subscription recovery policy to retain messages with ActiveMQ.Retain property set. During the message conversion, MQTT messages with retain flag become JMS message with the ActiveMQ.Retain property set and retained by the broker.