public class MqttSample extends java.lang.Object
MqttStreams
is
a connector used to create a bridge between topology streams
and an MQTT broker.
The sample publishes some messages to a MQTT topic. It also subscribes to the topic and reports the messages received. The messages received may include messages from prior runs of the sample.
By default, the sample requires a running MQTT broker with the following characteristics:
tcp://localhost:1883
Required IBM Streams environment variables:
DISTRIBUTED
DISTRIBUTED
See the MQTT link above for information about setting up a MQTT broker.
This may be executed from the samples/java/functional
directory as:
ant run.mqtt.distributed
- Using Apache Ant, this will run in distributed mode.ant run.mqtt
- Using Apache Ant, this will run in standalone mode.java -cp functionalsamples.jar:../../../com.ibm.streamsx.topology/lib/com.ibm.streamsx.topology.jar:$STREAMS_INSTALL/lib/com.ibm.streams.operator.samples.jar
mqtt.MqttSample CONTEXT_TYPE
[serverURI=<value>]
[userID=<value>] [password=<value>]
[trustStore=<value>] [trustStorePassword=<value>]
[keyStore=<value>] [keyStorePassword=<value>]
- Run directly from the command line.
trustStore
or keyStore
arguments.
DISTRIBUTED
- Run as an IBM Streams distributed application.STANDALONE
- Run as an IBM Streams standalone application.BUNDLE
- Create an IBM Streams application bundle.TOOLKIT
- Create an IBM Streams application toolkit.Constructor and Description |
---|
MqttSample() |
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String[] args) |
void |
publishSubscribe(java.lang.String contextType)
Publish some messages to a topic; subscribe to the topic and report
received messages.
|
public MqttSample()
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public void publishSubscribe(java.lang.String contextType) throws java.lang.Exception
contextType
- string value of a StreamsContext.Type
java.lang.Exception