Sanket Tagalpallewar
Sanket Tagalpallewar

Reputation: 133

How to receive message published on a topic using mqtt protocol in spring:jms application?

I am new to activemq.

I have a publisher which publish a message to a topic using mqtt protocol. And now I want to write a subscriber using Spring + JMS which will listen for the message on that topic.

I have following questions:

1) Can I have a same topic if I write the subscriber using tcp protocol.I mean to say, publisher will use MQTT to publish on a topic and subscriber will listen on that topic using TCP broker URL.

2) If above is not possible then how can I write a subscriber using spring + jms that will listen and receive the messages published on the topic using mqtt ?

Thank you in advance.

Upvotes: 3

Views: 934

Answers (1)

Petter Nordlander
Petter Nordlander

Reputation: 22279

Did you even try? Yes, it works pretty much as you expect it to. MQTT msgs gets converted to JMS if you try read it with JMS (OpenWire).

From web site:

Message transformations

MQTT messages are transformed into an JMS ByteMessage. Conversely, the body of any JMS Message is converted to a byte buffer to be the payload of an MQTT message.

Upvotes: 3

Related Questions