Commit 4c6cf6ec2a050b614ce78198311e70c4884b47c0
Committed by
Andrew Shvayka
1 parent
f325edef
added removing persistent rpc from pending map
Showing
1 changed file
with
16 additions
and
3 deletions
... | ... | @@ -26,7 +26,6 @@ import lombok.extern.slf4j.Slf4j; |
26 | 26 | import org.apache.commons.collections.CollectionUtils; |
27 | 27 | import org.thingsboard.common.util.JacksonUtil; |
28 | 28 | import org.thingsboard.common.util.LinkedHashMapRemoveEldest; |
29 | -import org.thingsboard.server.common.data.rpc.RpcError; | |
30 | 29 | import org.thingsboard.rule.engine.api.msg.DeviceAttributesEventNotificationMsg; |
31 | 30 | import org.thingsboard.rule.engine.api.msg.DeviceCredentialsUpdateNotificationMsg; |
32 | 31 | import org.thingsboard.rule.engine.api.msg.DeviceEdgeUpdateMsg; |
... | ... | @@ -52,6 +51,7 @@ import org.thingsboard.server.common.data.page.PageLink; |
52 | 51 | import org.thingsboard.server.common.data.relation.EntityRelation; |
53 | 52 | import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
54 | 53 | import org.thingsboard.server.common.data.rpc.Rpc; |
54 | +import org.thingsboard.server.common.data.rpc.RpcError; | |
55 | 55 | import org.thingsboard.server.common.data.rpc.RpcStatus; |
56 | 56 | import org.thingsboard.server.common.data.rpc.ToDeviceRpcRequestBody; |
57 | 57 | import org.thingsboard.server.common.data.security.DeviceCredentials; |
... | ... | @@ -59,6 +59,7 @@ import org.thingsboard.server.common.data.security.DeviceCredentialsType; |
59 | 59 | import org.thingsboard.server.common.msg.TbActorMsg; |
60 | 60 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
61 | 61 | import org.thingsboard.server.common.msg.queue.TbCallback; |
62 | +import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse; | |
62 | 63 | import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequest; |
63 | 64 | import org.thingsboard.server.common.msg.timeout.DeviceActorServerSideRpcTimeoutMsg; |
64 | 65 | import org.thingsboard.server.gen.transport.TransportProtos; |
... | ... | @@ -86,7 +87,6 @@ import org.thingsboard.server.gen.transport.TransportProtos.ToTransportMsg; |
86 | 87 | import org.thingsboard.server.gen.transport.TransportProtos.ToTransportUpdateCredentialsProto; |
87 | 88 | import org.thingsboard.server.gen.transport.TransportProtos.TransportToDeviceActorMsg; |
88 | 89 | import org.thingsboard.server.gen.transport.TransportProtos.TsKvProto; |
89 | -import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse; | |
90 | 90 | import org.thingsboard.server.service.rpc.FromDeviceRpcResponseActorMsg; |
91 | 91 | import org.thingsboard.server.service.rpc.RemoveRpcActorMsg; |
92 | 92 | import org.thingsboard.server.service.rpc.ToDeviceRpcRequestActorMsg; |
... | ... | @@ -551,7 +551,20 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor { |
551 | 551 | |
552 | 552 | private void processPersistedRpcResponses(TbActorCtx context, SessionInfoProto sessionInfo, ToDevicePersistedRpcResponseMsg responseMsg) { |
553 | 553 | UUID rpcId = new UUID(responseMsg.getRequestIdMSB(), responseMsg.getRequestIdLSB()); |
554 | - systemContext.getTbRpcService().save(tenantId, new RpcId(rpcId), RpcStatus.valueOf(responseMsg.getStatus()), null); | |
554 | + RpcStatus status = RpcStatus.valueOf(responseMsg.getStatus()); | |
555 | + | |
556 | + ToDeviceRpcRequestMetadata md; | |
557 | + if (RpcStatus.DELIVERED.equals(status)) { | |
558 | + md = toDeviceRpcPendingMap.get(responseMsg.getRequestId()); | |
559 | + } else { | |
560 | + md = toDeviceRpcPendingMap.remove(responseMsg.getRequestId()); | |
561 | + } | |
562 | + | |
563 | + if (md != null) { | |
564 | + systemContext.getTbRpcService().save(tenantId, new RpcId(rpcId), status, null); | |
565 | + } else { | |
566 | + log.debug("[{}] Rpc has already removed from pending map.", rpcId); | |
567 | + } | |
555 | 568 | } |
556 | 569 | |
557 | 570 | private void processSubscriptionCommands(TbActorCtx context, SessionInfoProto sessionInfo, SubscribeToAttributeUpdatesMsg subscribeCmd) { | ... | ... |