To test the service binding between Watson IoT Platform and Event Streams, let’s set up a simulated device.
Browse to Settings, select Device Simulator and enable the Activate Device Simulator option. You can use the default configuration to simulate events at a fixed frequency.
Once the simulation has been created and enabled, you will see events being generated.
If you have set up the data store connector correctly, you should see the messages published to the Kafka topic in the Event Streams service.
When you run the sample IBM consumer application, you should see the Message consumed log messages:
$ java -jar ./build/libs/kafka-java-console-sample-2.0.jar <kafka_brokers_sasl> <api_key> -consumer[2020-01-13 17:33:40,572] INFO Using command line arguments to find credentials. (com.eventstreams.samples.EventStreamsConsoleSample)
[2020-01-13 17:33:40,576] INFO Kafka Endpoints: broker-1-t111111q7ljf7f4n.kafka.svc02.us-south.eventstreams.cloud.ibm.com:9093 (com.eventstreams.samples.EventStreamsConsoleSample)
[2020-01-13 17:33:42,234] INFO Creating the topic kafka-java-console-sample-topic (com.eventstreams.samples.EventStreamsConsoleSample)
[2020-01-13 17:33:48,058] INFO Topic kafka-java-console-sample-topic already exists (com.eventstreams.samples.EventStreamsConsoleSample)
[2020-01-13 17:33:50,505] INFO [Partition(topic = kafka-java-console-sample-topic, partition = 0, leader = 2, replicas = [2,3,4], isr = [4,3,2], offlineReplicas = [])] (com.eventstreams.samples.ConsumerRunnable)
[2020-01-13 17:33:50,511] INFO EventStreamsConsoleSample will run until interrupted. (com.eventstreams.samples.EventStreamsConsoleSample)
[2020-01-13 17:33:50,512] INFO class com.eventstreams.samples.ConsumerRunnable is starting. (com.eventstreams.samples.ConsumerRunnable)
[2020-01-13 17:33:59,527] INFO No messages consumed (com.eventstreams.samples.ConsumerRunnable)
[2020-01-13 17:34:02,532] INFO No messages consumed (com.eventstreams.samples.ConsumerRunnable)
[2020-01-13 17:34:02,865] INFO Message consumed: ConsumerRecord(topic = kafka-java-console-sample-topic, partition = 0, leaderEpoch = 6, offset = 106, CreateTime = 1578908009923, serialized key size = 139, serialized value size = 19, headers = RecordHeaders(headers = [], isReadOnly = false), key = {“orgId”:”bmckzu”,”format”:”json”,”timestamp”:”2020-01-13T09:33:28.095Z”,”deviceType”:”sensor”,”deviceId”:”sensor_1″,”eventType”:”event_1″}, value = {“randomNumber”:99}) (com.eventstreams.samples.ConsumerRunnable)
If you have the sample Joget Kafka app running, you should see the following log output showing the received messages:
INFO 17 Jan 2020 16:31:58 org.joget.kafka.ConsumerRunnable – Executing script. Offset: 422
INFO 17 Jan 2020 16:31:58 org.joget.kafka.ConsumerRunnable – Key={“orgId”:”bmckzu”,”format”:”json”,”timestamp”:”2020-01-17T08:31:56.169Z”,”deviceType”:”sensor”,”deviceId”:”sensor_1″,”eventType”:”event_1″}. Value={“randomNumber”:8}
INFO 17 Jan 2020 16:31:58 KafkaConsumer – Message received {“orgId”:”bmckzu”,”format”:”json”,”timestamp”:”2020-01-17T08:31:56.169Z”,”deviceType”:”sensor”,”deviceId”:”sensor_1″,”eventType”:”event_1″}={“randomNumber”:8}
INFO 17 Jan 2020 16:31:58 org.joget.kafka.ConsumerRunnable – Script execution complete.
INFO 17 Jan 2020 16:31:58 org.joget.kafka.ConsumerRunnable – Script result: null
INFO 17 Jan 2020 16:31:58 org.joget.kafka.ConsumerRunnable – Executing script. Offset: 423