To work with Mqtt, Mqtt Message broker/server required.
Mosquitto (http://mosquitto.org/) is an open source Mqtt Broker
In ubuntu mosquitto can be installed using the command $ sudo apt-get install mosquitto
Eclipse paho project provides Java library for Mqtt Client http://www.eclipse.org/paho/
Example Java code for Mqtt Publisher and Subscriber can be found here https://bitbucket.org/mkjinesh/mqttclient
Usage: MQTTWordCount <master> <MqttbrokerUrl> <topic>
In local mode, <master> should be 'local[n]' with n > 1
<MqttbrokerUrl> and <topic> describe where Mqtt publisher is running.
To run this example locally, you may run publisher as
$ ./bin/run-example org.apache.spark.streaming.examples.MQTTPublisher tcp://localhost:1883 foo
and run the example as
$ ./bin/run-example org.apache.spark.streaming.examples.MQTTWordCount local[2] tcp://localhost:1883 foo
A sample wordcount with MqttStream stream
To work with Mqtt, Mqtt Message broker/server required. Mosquitto (http://mosquitto.org/) is an open source Mqtt Broker In ubuntu mosquitto can be installed using the command
$ sudo apt-get install mosquitto
Eclipse paho project provides Java library for Mqtt Client http://www.eclipse.org/paho/ Example Java code for Mqtt Publisher and Subscriber can be found here https://bitbucket.org/mkjinesh/mqttclient Usage: MQTTWordCount <master> <MqttbrokerUrl> <topic> In local mode, <master> should be 'local[n]' with n > 1 <MqttbrokerUrl> and <topic> describe where Mqtt publisher is running.To run this example locally, you may run publisher as
$ ./bin/run-example org.apache.spark.streaming.examples.MQTTPublisher tcp://localhost:1883 foo
and run the example as$ ./bin/run-example org.apache.spark.streaming.examples.MQTTWordCount local[2] tcp://localhost:1883 foo