WSO2 Message Broker (WSO2 MB) uses two transport protocols for the purpose of brokering messages between publishers and subscribers. These protocols are the Advanced Message Queueing Protocol (AMQP) and the Message Queueing and Telemetry Transport (MQTT).
The topics given below explains how these protocols are enabled and configured for WSO2 MB:
Advanced Message Queuing Protocol (AMQP)
The Advance Message Queueing Protocol (AMQP) is a wire-level messaging protocol used by WSO2 MB for message queueing.
Enabling the transport
The <MB_HOME>/repository/conf/broker.xml
file contains parameters related to configuring the AMQP transport. The transport can be enabled as shown in the following extract of the broker.xml
file:
<amqp enabled="true"> <!-- most of the amqp configurations reside in qpid-config.xml since we inherit the qpid messaging model during AMQP.--> <sslConnection enabled="true" port="8672"> <keyStore> <location>repository/resources/security/wso2carbon.jks</location> <password>wso2carbon</password> <certType>SunX509</certType> </keyStore> <trustStore> <location>repository/resources/security/client-truststore.jks</location> <password>wso2carbon</password> <certType>SunX509</certType> </trustStore> </sslConnection> <maximumRedeliveryAttempts>10</maximumRedeliveryAttempts> <allowSharedTopicSubscriptions>false</allowSharedTopicSubscriptions> <allowStrictNameValidation>true</allowStrictNameValidation> </amqp>
Related Parameters
Parameter Name | Description | Default Value |
---|---|---|
enabled | If the value of this parameter is true , the AMQP transport is enabled and the AMQP protocol will be applied to messages sent to the specified listening port. | true |
port | The listening port specified for the AMQP transport. The AMQP broker would be initialized with this port by default. | 5672 |
sslPort | The listening SSL port for the specified AMQP transport. The AMQP security socket will be initialized with this port by default. | 8672 |
maximumRedeliveryAttempts | The maximum number of times the WSO2 MB should attempt to redeliver a message that has not reached a subscriber. For example, when this value is set to 10, another 10 attempts will be made to deliver the message. The default value can be changed depending on your reliability requirements. | 10 |
allowSharedTopicSubscriptions | If this parameter is true , a durable subscription to a topic can be shared among multiple subscribers. That is, multiple clients can subscribe to a topic in WSO2 MB using the same client ID. Read more about durable subscriptions to topics. | false |
allowStrictNameValidation | If this parameter is true, the queue names and topic names will be validated according to the AMQP specification. When this parameter is set to false , it is possible to use ":" in topic names. | true |
Refer the description of the broker.xml file for further details.
Message Queueing and Telemetry Transport
The Message Queueing and Telemetry Transport (MQTT) is a lightweight, broker-based publish/subscribe messaging protocol, which enables an extremely lightweight publish/subscribe messaging model. WSO2 MB 3.0.0 and later versions fully support MQTT version 3.1.0, and partially supports version 3.1.1.
The MQTT protocol allows a message to be sent to a topic based on three levels of QoS (Quality of Service) as explained below.
QoS 1 - At Most One - At this level, messages are delivered to subscribers in the most efficient manner. A message is dispatched only once.
QoS 2 - At Least One - At this level, the system will ensure that a message is received by the subscriber at least once. The level of delivery is assured through acknowledged delivery.
QoS 3 - Exactly Once - At this level, the message is delivered only once to its subscriber. This level is also defined as Assured Delivery.
Enabling the transport
The <MB_HOME>/repository/conf/broker.xml
file contains parameters related to configuring the MQTT transport. The transport can be enabled as shown in the following extract of the broker.xml
file.
<mqtt enabled="true"> <port>1883</port> <sslPort>8883</sslPort> <!-- put proper default ssl port --> <inboundBufferSize>32768</inboundBufferSize> <deliveryBufferSize>32768</deliveryBufferSize> <security> <authentication>OPTIONAL</authentication> <authenticator>org.wso2.carbon.andes.authentication.andes.CarbonBasedMQTTAuthenticator</authenticator> </security> </mqtt>
Related Parameters
Parameter Name | Description | Default Value |
---|---|---|
enabled | If the value for this parameter is true , the MQTT transport is enabled and the MQTT protocol will be applied to messages that are sent to the specified listening port. | true |
port | The listening port for the MQTT transport. The MQTT broker will be initialized with the specified port by default. This value would be incremented based on the offset specified in the carbon.xml . | 1883 |
sslPort | The listening SSL port for the MQTT transport. The MQTT secure socket will be initialized with the specified port by default. | 8883 |
Refer the description of the broker.xml file for further details.