added method destroy to admins and aws sqs factories
This commit is contained in:
parent
9fa82078a0
commit
12973cecf1
@ -39,6 +39,8 @@ import org.thingsboard.server.queue.sqs.TbAwsSqsProducerTemplate;
|
||||
import org.thingsboard.server.queue.sqs.TbAwsSqsQueueAttributes;
|
||||
import org.thingsboard.server.queue.sqs.TbAwsSqsSettings;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
@Component
|
||||
@ConditionalOnExpression("'${queue.type:null}'=='aws-sqs' && '${service.type:null}'=='monolith'")
|
||||
public class AwsSqsMonolithQueueFactory implements TbCoreQueueFactory, TbRuleEngineQueueFactory {
|
||||
@ -145,4 +147,23 @@ public class AwsSqsMonolithQueueFactory implements TbCoreQueueFactory, TbRuleEng
|
||||
public TbQueueRequestTemplate<TbProtoJsQueueMsg<JsInvokeProtos.RemoteJsRequest>, TbProtoQueueMsg<JsInvokeProtos.RemoteJsResponse>> createRemoteJsRequestTemplate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
private void destroy() {
|
||||
if (coreAdmin != null) {
|
||||
coreAdmin.destroy();
|
||||
}
|
||||
if (ruleEngineAdmin != null) {
|
||||
ruleEngineAdmin.destroy();
|
||||
}
|
||||
if (jsExecutorAdmin != null) {
|
||||
jsExecutorAdmin.destroy();
|
||||
}
|
||||
if (transportApiAdmin != null) {
|
||||
transportApiAdmin.destroy();
|
||||
}
|
||||
if (notificationAdmin != null) {
|
||||
notificationAdmin.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,6 +43,8 @@ import org.thingsboard.server.queue.sqs.TbAwsSqsProducerTemplate;
|
||||
import org.thingsboard.server.queue.sqs.TbAwsSqsQueueAttributes;
|
||||
import org.thingsboard.server.queue.sqs.TbAwsSqsSettings;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
@Component
|
||||
@ConditionalOnExpression("'${queue.type:null}'=='aws-sqs' && '${service.type:null}'=='tb-core'")
|
||||
public class AwsSqsTbCoreQueueFactory implements TbCoreQueueFactory {
|
||||
@ -134,4 +136,23 @@ public class AwsSqsTbCoreQueueFactory implements TbCoreQueueFactory {
|
||||
public TbQueueRequestTemplate<TbProtoJsQueueMsg<JsInvokeProtos.RemoteJsRequest>, TbProtoQueueMsg<JsInvokeProtos.RemoteJsResponse>> createRemoteJsRequestTemplate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
private void destroy() {
|
||||
if (coreAdmin != null) {
|
||||
coreAdmin.destroy();
|
||||
}
|
||||
if (ruleEngineAdmin != null) {
|
||||
ruleEngineAdmin.destroy();
|
||||
}
|
||||
if (jsExecutorAdmin != null) {
|
||||
jsExecutorAdmin.destroy();
|
||||
}
|
||||
if (transportApiAdmin != null) {
|
||||
transportApiAdmin.destroy();
|
||||
}
|
||||
if (notificationAdmin != null) {
|
||||
notificationAdmin.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,6 +40,8 @@ import org.thingsboard.server.queue.sqs.TbAwsSqsProducerTemplate;
|
||||
import org.thingsboard.server.queue.sqs.TbAwsSqsQueueAttributes;
|
||||
import org.thingsboard.server.queue.sqs.TbAwsSqsSettings;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
@Component
|
||||
@ConditionalOnExpression("'${queue.type:null}'=='aws-sqs' && '${service.type:null}'=='tb-rule-engine'")
|
||||
public class AwsSqsTbRuleEngineQueueFactory implements TbRuleEngineQueueFactory {
|
||||
@ -114,4 +116,20 @@ public class AwsSqsTbRuleEngineQueueFactory implements TbRuleEngineQueueFactory
|
||||
public TbQueueRequestTemplate<TbProtoJsQueueMsg<JsInvokeProtos.RemoteJsRequest>, TbProtoQueueMsg<JsInvokeProtos.RemoteJsResponse>> createRemoteJsRequestTemplate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
private void destroy() {
|
||||
if (coreAdmin != null) {
|
||||
coreAdmin.destroy();
|
||||
}
|
||||
if (ruleEngineAdmin != null) {
|
||||
ruleEngineAdmin.destroy();
|
||||
}
|
||||
if (jsExecutorAdmin != null) {
|
||||
jsExecutorAdmin.destroy();
|
||||
}
|
||||
if (notificationAdmin != null) {
|
||||
notificationAdmin.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,8 @@ import org.thingsboard.server.queue.sqs.TbAwsSqsProducerTemplate;
|
||||
import org.thingsboard.server.queue.sqs.TbAwsSqsQueueAttributes;
|
||||
import org.thingsboard.server.queue.sqs.TbAwsSqsSettings;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
@Component
|
||||
@ConditionalOnExpression("'${queue.type:null}'=='aws-sqs' && ('${service.type:null}'=='monolith' || '${service.type:null}'=='tb-transport')")
|
||||
@Slf4j
|
||||
@ -100,4 +102,14 @@ public class AwsSqsTransportQueueFactory implements TbTransportQueueFactory {
|
||||
return new TbAwsSqsConsumerTemplate<>(notificationAdmin, sqsSettings, transportNotificationSettings.getNotificationsTopic() + "_" + serviceInfoProvider.getServiceId(),
|
||||
msg -> new TbProtoQueueMsg<>(msg.getKey(), ToTransportMsg.parseFrom(msg.getData()), msg.getHeaders()));
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
private void destroy() {
|
||||
if (transportApiAdmin != null) {
|
||||
transportApiAdmin.destroy();
|
||||
}
|
||||
if (notificationAdmin != null) {
|
||||
notificationAdmin.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user