End-to-end debugging
After you develop the device-side and server-side services, perform joint debugging. To do this, start the server-side program to connect to IoT Platform, and then run a device simulation script to report data.
Start the server-side program
In IntelliJ IDEA, run the AmqpClient.java program.
Thread.sleep(60 * 1000);, which stops the program after one minute. In a production environment, you can adjust the runtime as required.15:11:29.075 [FailoverProvider: async work thread] DEBUG org.apache.qpid.jms.provider.failover.FailoverProvider - Executing Failover Task: create ...
configuredURI = failover:(amqps://xxx.amqp.iothub.aliyuncs.com:5671?amqp.idleTimeout=80000)?failover.reconnectDelay=30, connectedURI = null } (1)
15:11:29.104 [AmqpProvider :(4):[amqps://xxx.amqp.iothub.aliyuncs.com:5671]] DEBUG org.apache.qpid.jms.provider.amqp.builders.AmqpConnectionBuilder - AmqpConnection {
ID:xxx } is now open:
15:11:29.105 [AmqpProvider :(4):[amqps://xxx.amqp.iothub.aliyuncs.com:5671]] INFO org.apache.qpid.jms.JmsConnection - Connection ID:xxx connected to server:
amqps://xxx.amqp.iothub.aliyuncs.com:5671
15:11:29.105 [QpidJMS Connection Executor: ID:xxx] INFO com.aliyun.iotx.demo.AmqpClient - onConnectionEstablished, remoteUri:amqps://xxx.amqp.iothub.aliyuncs.com:5671?amqp
.idleTimeout=80000
15:11:29.105 [main] DEBUG org.apache.qpid.jms.provider.failover.FailoverProvider - Executing Failover Task: create -> JmsSessionInfo { ID:xxx } (2)
15:11:29.117 [main] DEBUG org.apache.qpid.jms.provider.failover.FailoverProvider - Executing Failover Task: create -> JmsConsumerInfo { ID:xxx, destination = default } (3)
15:11:29.149 [main] DEBUG org.apache.qpid.jms.provider.failover.FailoverProvider - Executing Failover Task: start -> JmsConsumerInfo: { ID:xxx, destination = default } (4)
15:11:29.151 [main] INFO com.aliyun.iotx.demo.AmqpClient - amqp demo is started successfully, and will exit after 60s
Start the device and report data
In your command prompt, cd to the directory that contains the iot_device.js file. Then, run the following command to start the device.
node iot_device.js
The handheld infrared thermometer device reports temperature data to IoT Platform:
- Message topic:
/a1*********/hz9527/user/data. - Message payload:
{"temperature":24}.
Check the cloud data flow
Log in to the IoT Platform console, navigate to your instance, and in the left-side navigation pane, choose .
On the Cloud-side Run Log tab, you can view the device's upstream messages, including their topic and payload, to track the message flow.
The log entries show the following sequence:
- The device reports a message (marked as ①).
- The rules engine forwards the message to AMQP (marked as ②).
- AMQP pushes the message to the server-side (marked as ③).
- The server-side sends an ACK response for the message (marked as ④).
Verify server-side message consumption
The server side prints the message data received from IoT Platform in real time. The log entry shows the full content of the original device message.
15:59:17.072 [pool-1-thread-2] INFO com.aliyun.iotx.demo.AmqpClient - receive message,
topic = /gxxx/device1/user/data,
messageId = xxx,
content = {"area":"East China","province":"Zhejiang","city":"Hangzhou","district":"Binjiang","temperature":23,"time":"2022-08-18 15:59:17","deviceName":"device1"}
15:59:17.072 [AmqpProvider :(4):[amqps://xxx.amqp.iothub.aliyuncs.com:5671]] DEBUG org.apache.qpid.jms.provider.amqp.AmqpConsumer - Accepted Ack of message: JmsInboundMessageDispatch { sequence = 20,
messageId = xxx, consumerId = ID:xxx }
In the IoT Platform console for your instance, choose in the left-side navigation pane. Click the Consumer Group List tab. Find the Handheld Thermometer Data Consumer Group and click View. On the Consumer Group Details page, you can see metrics such as the message processing rate, message backlog, the processing time of the last message, and information about online clients, which represent your server side.