bartpeperkamp
bartpeperkamp

Reputation: 49

Node and MQTT, do something on message

I am building a specific device based on Node, Cylon and am publishing events to a MQTT broker. I'd like to know how to perform a certain action once a certain MQTT message comes to the device. Can anybody point me in the right direction? I'm a bit lost in the matter ;)

I use this to publish data:

mqtt.publish(thingTopic,  JSON.stringify(data));

I'd like to create something like this:

if certain message arrives at broker -> do a post or get request to internal url.

The question is a bit vague, i must admit...

Upvotes: 2

Views: 1814

Answers (1)

Pierre-Luc
Pierre-Luc

Reputation: 730

You would probably need to build your own custom MQTT broker to achieve what you are looking for which is not really the point of the pub/sub message paradigm. Instead of customizing the MQTT broker, look into creating your own subscribing application that will react to messages being received from the MQTT Broker.

Hopefully the following sequence diagram will help understand.

Sequence Diagram

Upvotes: 3

Related Questions