Browse Source

Improve KafkaEdgeGrpcSession

pull/11924/head
Andrii Landiak 2 years ago
parent
commit
be25681416
  1. 6
      application/src/main/java/org/thingsboard/server/service/edge/rpc/KafkaEdgeGrpcSession.java

6
application/src/main/java/org/thingsboard/server/service/edge/rpc/KafkaEdgeGrpcSession.java

@ -44,7 +44,7 @@ import java.util.function.BiConsumer;
@Slf4j @Slf4j
public class KafkaEdgeGrpcSession extends AbstractEdgeGrpcSession { public class KafkaEdgeGrpcSession extends AbstractEdgeGrpcSession {
private final TbQueueConsumer<TbProtoQueueMsg<ToEdgeEventNotificationMsg>> edgeEventsConsumer; private final TbCoreQueueFactory tbCoreQueueFactory;
private volatile boolean isHighPriorityProcessing; private volatile boolean isHighPriorityProcessing;
@ -57,7 +57,7 @@ public class KafkaEdgeGrpcSession extends AbstractEdgeGrpcSession {
BiConsumer<Edge, UUID> sessionCloseListener, ScheduledExecutorService sendDownlinkExecutorService, BiConsumer<Edge, UUID> sessionCloseListener, ScheduledExecutorService sendDownlinkExecutorService,
int maxInboundMessageSize, int maxHighPriorityQueueSizePerSession) { int maxInboundMessageSize, int maxHighPriorityQueueSizePerSession) {
super(ctx, outputStream, sessionOpenListener, sessionCloseListener, sendDownlinkExecutorService, maxInboundMessageSize, maxHighPriorityQueueSizePerSession); super(ctx, outputStream, sessionOpenListener, sessionCloseListener, sendDownlinkExecutorService, maxInboundMessageSize, maxHighPriorityQueueSizePerSession);
edgeEventsConsumer = tbCoreQueueFactory.createEdgeEventMsgConsumer(tenantId, edge.getId()); this.tbCoreQueueFactory = tbCoreQueueFactory;
} }
private void processMsgs(List<TbProtoQueueMsg<ToEdgeEventNotificationMsg>> msgs, TbQueueConsumer<TbProtoQueueMsg<ToEdgeEventNotificationMsg>> consumer) { private void processMsgs(List<TbProtoQueueMsg<ToEdgeEventNotificationMsg>> msgs, TbQueueConsumer<TbProtoQueueMsg<ToEdgeEventNotificationMsg>> consumer) {
@ -102,7 +102,7 @@ public class KafkaEdgeGrpcSession extends AbstractEdgeGrpcSession {
.name("TB Edge events") .name("TB Edge events")
.msgPackProcessor(this::processMsgs) .msgPackProcessor(this::processMsgs)
.pollInterval(ctx.getEdgeEventStorageSettings().getNoRecordsSleepInterval()) .pollInterval(ctx.getEdgeEventStorageSettings().getNoRecordsSleepInterval())
.consumerCreator(() -> edgeEventsConsumer) .consumerCreator(() -> tbCoreQueueFactory.createEdgeEventMsgConsumer(tenantId, edge.getId()))
.consumerExecutor(consumerExecutor) .consumerExecutor(consumerExecutor)
.threadPrefix("edge-events") .threadPrefix("edge-events")
.build(); .build();

Loading…
Cancel
Save