Browse Source

Minor refactoring for notifications consumers

pull/10395/head
ViacheslavKlimov 2 years ago
parent
commit
b16d8484e9
  1. 2
      application/src/main/java/org/thingsboard/server/service/queue/processing/AbstractConsumerService.java
  2. 14
      common/message/src/main/java/org/thingsboard/server/common/msg/queue/ServiceType.java

2
application/src/main/java/org/thingsboard/server/service/queue/processing/AbstractConsumerService.java

@ -85,7 +85,7 @@ public abstract class AbstractConsumerService<N extends com.google.protobuf.Gene
this.scheduler = Executors.newSingleThreadScheduledExecutor(ThingsBoardThreadFactory.forName(prefix + "-consumer-scheduler")); this.scheduler = Executors.newSingleThreadScheduledExecutor(ThingsBoardThreadFactory.forName(prefix + "-consumer-scheduler"));
this.nfConsumer = QueueConsumerManager.<TbProtoQueueMsg<N>>builder() this.nfConsumer = QueueConsumerManager.<TbProtoQueueMsg<N>>builder()
.name("TB Notifications") .name(getServiceType().getLabel() + " Notifications")
.msgPackProcessor(this::processNotifications) .msgPackProcessor(this::processNotifications)
.pollInterval(getNotificationPollDuration()) .pollInterval(getNotificationPollDuration())
.consumerCreator(this::createNotificationsConsumer) .consumerCreator(this::createNotificationsConsumer)

14
common/message/src/main/java/org/thingsboard/server/common/msg/queue/ServiceType.java

@ -15,11 +15,23 @@
*/ */
package org.thingsboard.server.common.msg.queue; package org.thingsboard.server.common.msg.queue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
@Getter
public enum ServiceType { public enum ServiceType {
TB_CORE, TB_RULE_ENGINE, TB_TRANSPORT, JS_EXECUTOR, TB_VC_EXECUTOR; TB_CORE("TB Core"),
TB_RULE_ENGINE("TB Rule Engine"),
TB_TRANSPORT("TB Transport"),
JS_EXECUTOR("JS Executor"),
TB_VC_EXECUTOR("TB VC Executor");
private final String label;
public static ServiceType of(String serviceType) { public static ServiceType of(String serviceType) {
return ServiceType.valueOf(serviceType.replace("-", "_").toUpperCase()); return ServiceType.valueOf(serviceType.replace("-", "_").toUpperCase());
} }
} }

Loading…
Cancel
Save