aws-greengrass / aws-greengrass-client-device-auth

Apache License 2.0
2 stars 3 forks source link

feat(uat): added unsubscribe to paho-java-client #311

Closed auarbekov closed 1 year ago

auarbekov commented 1 year ago

Issue #, if available: added unsubscribe to paho-java-client

Description of changes:

Why is this change necessary:

How was this change tested: run command mvn exec:java in paho-agent module

Mqtt V5 client's log:

[INFO ] 2023-06-13 17:49:58.873 [main] GRPCLinkImpl - Making gPRC client connection with 127.0.0.1:47619 as best-thing-akezhan...
[INFO ] 2023-06-13 17:49:59.396 [main] GRPCLinkImpl - Client connection with Control is established, local address is 127.0.0.1
[INFO ] 2023-06-13 17:49:59.432 [main] GRPCControlServer - GRPCControlServer created and listed on 127.0.0.1:41253
[INFO ] 2023-06-13 17:49:59.511 [main] GRPCLinkImpl - Handle gRPC requests
[INFO ] 2023-06-13 17:49:59.512 [main] GRPCControlServer - Server awaitTermination
[INFO ] 2023-06-13 17:50:02.546 [grpc-default-executor-0] GRPCControlServer - createMqttConnection: clientId best-thing-akezhan broker a2rytmonq5cblh-ats.iot.eu-central-1.amazonaws.com:8883
[INFO ] 2023-06-13 17:50:08.930 [grpc-default-executor-0] GRPCControlServer - Subscription: filter test/topic QoS 0 noLocal false retainAsPublished false retainHandling 2
[INFO ] 2023-06-13 17:50:08.931 [grpc-default-executor-0] GRPCControlServer - Subscribe: connectionId 1 for 1 filters
[INFO ] 2023-06-13 17:50:09.075 [grpc-default-executor-0] GRPCControlServer - Subscribe response: connectionId 1 reason codes [0] reason string 
[INFO ] 2023-06-13 17:50:14.096 [grpc-default-executor-0] GRPCControlServer - Publish: connectionId 1 topic test/topic QoS 1 retain false
[INFO ] 2023-06-13 17:50:14.229 [grpc-default-executor-0] GRPCControlServer - Publish response: connectionId 1 reason code 0 reason string 
[INFO ] 2023-06-13 17:50:14.233 [MQTT Call: best-thing-akezhan] MqttConnectionImpl - Received MQTT userProperties: region, US
[INFO ] 2023-06-13 17:50:14.233 [MQTT Call: best-thing-akezhan] MqttConnectionImpl - Received MQTT userProperties: type, JSON
[INFO ] 2023-06-13 17:50:14.244 [pool-3-thread-1] MqttConnectionImpl - Received MQTT message: connectionId 1 topic test/topic QoS 0 retain false
[INFO ] 2023-06-13 17:50:19.239 [grpc-default-executor-0] GRPCControlServer - Unsubscribe: connectionId 1 for [test/topic] filters
[INFO ] 2023-06-13 17:50:19.398 [grpc-default-executor-0] GRPCControlServer - Unsubscribe response: connectionId 1 reason codes [0] reason string 
[INFO ] 2023-06-13 17:50:34.409 [grpc-default-executor-0] GRPCControlServer - closeMqttConnection: connectionId 1 reason 4
[INFO ] 2023-06-13 17:50:34.529 [grpc-default-executor-0] GRPCControlServer - shutdownAgent: reason That's it.
[INFO ] 2023-06-13 17:50:34.538 [main] GRPCControlServer - Server awaitTermination done
[INFO ] 2023-06-13 17:50:34.538 [main] GRPCLinkImpl - Shutdown gPRC link
[INFO ] 2023-06-13 17:50:34.549 [main] Main - Execution done successfully

Mqtt V3 client's log:

[INFO ] 2023-06-13 17:40:02.839 [main] GRPCLinkImpl - Making gPRC client connection with 127.0.0.1:47619 as best-thing-akezhan...
[INFO ] 2023-06-13 17:40:03.543 [main] GRPCLinkImpl - Client connection with Control is established, local address is 127.0.0.1
[INFO ] 2023-06-13 17:40:03.576 [main] GRPCControlServer - GRPCControlServer created and listed on 127.0.0.1:33695
[INFO ] 2023-06-13 17:40:03.662 [main] GRPCLinkImpl - Handle gRPC requests
[INFO ] 2023-06-13 17:40:03.662 [main] GRPCControlServer - Server awaitTermination
[INFO ] 2023-06-13 17:40:06.696 [grpc-default-executor-0] GRPCControlServer - createMqttConnection: clientId best-thing-akezhan broker a2rytmonq5cblh-ats.iot.eu-central-1.amazonaws.com:8883
[INFO ] 2023-06-13 17:40:08.033 [grpc-default-executor-0] Mqtt311ConnectionImpl - MQTT 3.1.1 connection 1 is establisted
[INFO ] 2023-06-13 17:40:13.087 [grpc-default-executor-0] GRPCControlServer - Subscription: filter test/topic QoS 0 noLocal false retainAsPublished false retainHandling 2
[INFO ] 2023-06-13 17:40:13.088 [grpc-default-executor-0] GRPCControlServer - Subscribe: connectionId 1 for 1 filters
[INFO ] 2023-06-13 17:40:13.317 [grpc-default-executor-0] GRPCControlServer - Subscribe response: connectionId 1 reason codes [0] reason string 
[INFO ] 2023-06-13 17:40:18.333 [grpc-default-executor-0] GRPCControlServer - Publish: connectionId 1 topic test/topic QoS 1 retain false
[INFO ] 2023-06-13 17:40:18.457 [grpc-default-executor-0] GRPCControlServer - Publish response: connectionId 1 reason code 0 reason string 
[INFO ] 2023-06-13 17:40:18.468 [pool-3-thread-1] Mqtt311ConnectionImpl - Received MQTT message: connectionId 1 topic test/topic QoS 0 retain false
[INFO ] 2023-06-13 17:40:23.466 [grpc-default-executor-0] GRPCControlServer - Unsubscribe: connectionId 1 for [test/topic] filters
[INFO ] 2023-06-13 17:40:23.595 [grpc-default-executor-0] GRPCControlServer - Unsubscribe response: connectionId 1 reason codes [0] reason string 
[INFO ] 2023-06-13 17:40:38.608 [grpc-default-executor-0] GRPCControlServer - closeMqttConnection: connectionId 1 reason 4
[INFO ] 2023-06-13 17:40:38.621 [grpc-default-executor-0] Mqtt311ConnectionImpl - MQTT 3.1.1 connection 1 has been disconnected
[INFO ] 2023-06-13 17:40:38.629 [grpc-default-executor-0] GRPCControlServer - shutdownAgent: reason That's it.
[INFO ] 2023-06-13 17:40:38.638 [main] GRPCControlServer - Server awaitTermination done
[INFO ] 2023-06-13 17:40:38.638 [main] GRPCLinkImpl - Shutdown gPRC link
[INFO ] 2023-06-13 17:40:38.648 [main] Main - Execution done successfully

Control's log:

[INFO ] 2023-06-13 17:39:57.423 [com.aws.greengrass.testing.mqtt.client.control.ExampleControl.main()] EngineControlImpl - MQTT client control gRPC server started, listening on 47619
[INFO ] 2023-06-13 17:40:03.524 [grpc-default-executor-0] GRPCDiscoveryServer - RegisterAgent: agentId best-thing-akezhan
[INFO ] 2023-06-13 17:40:03.581 [grpc-default-executor-0] GRPCDiscoveryServer - DiscoveryClient: agentId best-thing-akezhan address 127.0.0.1 port 33695
[INFO ] 2023-06-13 17:40:03.583 [grpc-default-executor-0] EngineControlImpl - Created new agent control for best-thing-akezhan on 127.0.0.1:33695
[INFO ] 2023-06-13 17:40:03.615 [grpc-default-executor-0] ExampleControl - Agent best-thing-akezhan is connected
[INFO ] 2023-06-13 17:40:03.619 [pool-2-thread-1] AgentTestScenario - Playing test scenario for agent id best-thing-akezhan
[INFO ] 2023-06-13 17:40:08.075 [pool-2-thread-1] AgentControlImpl - Created connection with id 1 CONNACK 'sessionPresent: true
'
[INFO ] 2023-06-13 17:40:08.075 [pool-2-thread-1] AgentControlImpl - createMqttConnection: MQTT connectionId 1 created
[INFO ] 2023-06-13 17:40:08.075 [pool-2-thread-1] AgentTestScenario - MQTT connection with id 1 is established
[INFO ] 2023-06-13 17:40:13.078 [pool-2-thread-1] AgentControlImpl - SubscribeMqtt: subscribe on connection 1
[INFO ] 2023-06-13 17:40:13.321 [pool-2-thread-1] AgentTestScenario - Subscribe response: connectionId 1 reason codes [0] reason string ''
[INFO ] 2023-06-13 17:40:18.324 [pool-2-thread-1] AgentControlImpl - PublishMqtt: publishing on connectionId 1 topic test/topic
[INFO ] 2023-06-13 17:40:18.460 [pool-2-thread-1] AgentTestScenario - Published connectionId 1 reason code 0 reason string ''
[INFO ] 2023-06-13 17:40:18.465 [grpc-default-executor-0] GRPCDiscoveryServer - OnReceiveMessage: agentId best-thing-akezhan connectionId 1 topic test/topic QoS 0
[INFO ] 2023-06-13 17:40:18.466 [grpc-default-executor-0] AgentTestScenario - Message received on agentId best-thing-akezhan connectionId 1 topic test/topic QoS 0 content <ByteString@7662bba9 size=12 contents="Hello World!">
[INFO ] 2023-06-13 17:40:23.462 [pool-2-thread-1] AgentControlImpl - UnsubscribeMqtt: unsubscribe on connectionId 1
[INFO ] 2023-06-13 17:40:23.597 [pool-2-thread-1] AgentTestScenario - Unsubscribe response: connectionId 1 reason codes [0] reason string ''
[INFO ] 2023-06-13 17:40:38.624 [pool-2-thread-1] AgentControlImpl - closeMqttConnection: MQTT connectionId 1 closed
[INFO ] 2023-06-13 17:40:38.631 [pool-2-thread-1] AgentControlImpl - shutdown request sent successfully
[INFO ] 2023-06-13 17:40:38.643 [grpc-default-executor-0] GRPCDiscoveryServer - UnregisterAgent: agentId best-thing-akezhan reason Agent shutdown by OTF request 'That's it.'
[INFO ] 2023-06-13 17:40:38.644 [grpc-default-executor-0] ExampleControl - Agent best-thing-akezhan is disconnected

Any additional information or context required to review the change:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.