[BAHIR-29] Add basic documentation for MQTT Connector
Project: http://git-wip-us.apache.org/repos/asf/bahir/repo Commit: http://git-wip-us.apache.org/repos/asf/bahir/commit/619936d3 Tree: http://git-wip-us.apache.org/repos/asf/bahir/tree/619936d3 Diff: http://git-wip-us.apache.org/repos/asf/bahir/diff/619936d3 Branch: refs/heads/master Commit: 619936d39d18b7af45b7acec9af02b599a43b056 Parents: 858ad27 Author: Luciano Resende <lrese...@apache.org> Authored: Mon Aug 1 19:18:35 2016 +0300 Committer: Luciano Resende <lrese...@apache.org> Committed: Wed Aug 3 22:11:30 2016 +0300 ---------------------------------------------------------------------- streaming-mqtt/README.md | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bahir/blob/619936d3/streaming-mqtt/README.md ---------------------------------------------------------------------- diff --git a/streaming-mqtt/README.md b/streaming-mqtt/README.md new file mode 100644 index 0000000..9687dfe --- /dev/null +++ b/streaming-mqtt/README.md @@ -0,0 +1,54 @@ + +[MQTT](http://mqtt.org/) is MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium. + +## Linking + +Using SBT: + +``` +libraryDependencies += "org.apache.bahir" %% "spark-streaming-mqtt" % "2.0.0" +``` + +Using Maven: + +```xml +<dependency> + <groupId>org.apache.bahir</groupId> + <artifactId>spark-streaming-mqtt_2.11</artifactId> + <version>2.0.0</version> +</dependency> +``` + +This library can also be added to Spark jobs launched through `spark-shell` or `spark-submit` by using the `--packages` command line option. +For example, to include it when starting the spark shell: + +``` +$ bin/spark-shell --packages org.apache.bahir:spark-streaming_mqtt_2.11:2.0.0 +``` + +Unlike using `--jars`, using `--packages` ensures that this library and its dependencies will be added to the classpath. +The `--packages` argument can also be used with `bin/spark-submit`. + +This library is cross-published for Scala 2.10 and Scala 2.11, so users should replace the proper Scala version (2.10 or 2.11) in the commands listed above. + +## Examples + +### Scala API + +You need to extend `ActorReceiver` so as to store received data into Spark using `store(...)` methods. The supervisor strategy of +this actor can be configured to handle failures, etc. + +```Scala +val lines = MQTTUtils.createStream(ssc, brokerUrl, topic) +``` + +### Java API + +You need to extend `JavaActorReceiver` so as to store received data into Spark using `store(...)` methods. The supervisor strategy of +this actor can be configured to handle failures, etc. + +```Java +JavaDStream<String> lines = MQTTUtils.createStream(jssc, brokerUrl, topic); +``` + +See end-to-end examples at ([MQTT Examples](https://github.com/apache/bahir/tree/master/streaming-mqtt/examples) \ No newline at end of file