I would like to receive MQTT messages in Wildfly 11 with the embedded Apache Artemis.
Current state:
I added the MQTT protocol support to the Wildfly embedded Apache Artemis (added the "missing" folder and artemis-mqtt-protocol-.jar and enabled the protocol in the module.xml)
I am using the full standalone configuration and added acceptor for MTQQ:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0"> <server name="default"> <remote-acceptor name="mqtt-acceptor" socket-binding="mqtt"> <param name="protocols" value="MQTT"/> </remote-acceptor>
and topic as:
<jms-topic name="testEndpoint" entries="java:/jms/testEndpoint"/>
- Also added the mqtt to socket binding
From the log I can see that it works:
AMQ221020: Started Acceptor at 127.0.0.1:1883 for protocols [MQTT]
AMQ221007: Server is now live AMQ221001: Apache ActiveMQ Artemis Message Broker version 1.5.5.jbossorg-008
AMQ221003: Deploying queue jms.queue.DLQ
WFLYMSGAMQ0002: Bound messaging object to jndi name java:/ConnectionFactory
AMQ221003: Deploying queue jms.queue.ExpiryQueue
WFLYMSGAMQ0002: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
AMQ221052: Deploying topic jms.topic.testEndpoint
- Next I wrote a simple MDB as:
@MessageDriven(
activationConfig = { @ActivationConfigProperty(propertyName = "destination",
propertyValue = "testEndpoint"),
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Topic")
},
mappedName = "testEndpoint")
public class TestEndpoint implements MessageListener {
private static final Logger logger = Logger.getLogger(TestEndpoint.class.getName());
public void onMessage(Message message) {
try {
logger.debug("message: " + message.getClass().getName());
} catch (Exception e) {
logger.debug("exception: " + e.getMessage());
}
}
}
- I can connect to the server on port 1883 and when I send a message to testEndpoint I can see in the logs:
SESSION CREATED: 63f14f85-0fa2-4fe7-a27b-03ef8e6639a2
Couldn't find any bindings for address=testEndpoint on message=ServerMessage[messageID=962,durable=true,userID=null,priority=0, bodySize=512, timestamp=0,expiration=0, durable=true, address=testEndpoint,properties=TypedProperties[mqtt.message.retain=true,mqtt.qos.level=1]]@749653273
Message ServerMessage[messageID=962,durable=true,userID=null,priority=0, bodySize=512, timestamp=0,expiration=0, durable=true, address=testEndpoint,properties=TypedProperties[mqtt.message.retain=true,mqtt.qos.level=1]]@749653273 is not going anywhere as it didn't have a binding on address:testEndpoint
QueueImpl[name=$sys.mqtt.retain.testEndpoint, postOffice=PostOfficeImpl [server=ActiveMQServerImpl::serverUUID=c58c74d5-ea71-11e7-9621-a434d929f4aa]]@6ff93fb4 doing deliver. messageReferences=0
So it looks like I am missing some binding somewhere, but I can not find what it would be. Anybody has any idea?