Commit 12973cecf1b05ca71d24d5545d60b74b6af3b176
Committed by
Andrew Shvayka
1 parent
9fa82078
added method destroy to admins and aws sqs factories
Showing
4 changed files
with
72 additions
and
0 deletions
... | ... | @@ -39,6 +39,8 @@ import org.thingsboard.server.queue.sqs.TbAwsSqsProducerTemplate; |
39 | 39 | import org.thingsboard.server.queue.sqs.TbAwsSqsQueueAttributes; |
40 | 40 | import org.thingsboard.server.queue.sqs.TbAwsSqsSettings; |
41 | 41 | |
42 | +import javax.annotation.PreDestroy; | |
43 | + | |
42 | 44 | @Component |
43 | 45 | @ConditionalOnExpression("'${queue.type:null}'=='aws-sqs' && '${service.type:null}'=='monolith'") |
44 | 46 | public class AwsSqsMonolithQueueFactory implements TbCoreQueueFactory, TbRuleEngineQueueFactory { |
... | ... | @@ -145,4 +147,23 @@ public class AwsSqsMonolithQueueFactory implements TbCoreQueueFactory, TbRuleEng |
145 | 147 | public TbQueueRequestTemplate<TbProtoJsQueueMsg<JsInvokeProtos.RemoteJsRequest>, TbProtoQueueMsg<JsInvokeProtos.RemoteJsResponse>> createRemoteJsRequestTemplate() { |
146 | 148 | return null; |
147 | 149 | } |
150 | + | |
151 | + @PreDestroy | |
152 | + private void destroy() { | |
153 | + if (coreAdmin != null) { | |
154 | + coreAdmin.destroy(); | |
155 | + } | |
156 | + if (ruleEngineAdmin != null) { | |
157 | + ruleEngineAdmin.destroy(); | |
158 | + } | |
159 | + if (jsExecutorAdmin != null) { | |
160 | + jsExecutorAdmin.destroy(); | |
161 | + } | |
162 | + if (transportApiAdmin != null) { | |
163 | + transportApiAdmin.destroy(); | |
164 | + } | |
165 | + if (notificationAdmin != null) { | |
166 | + notificationAdmin.destroy(); | |
167 | + } | |
168 | + } | |
148 | 169 | } | ... | ... |
... | ... | @@ -43,6 +43,8 @@ import org.thingsboard.server.queue.sqs.TbAwsSqsProducerTemplate; |
43 | 43 | import org.thingsboard.server.queue.sqs.TbAwsSqsQueueAttributes; |
44 | 44 | import org.thingsboard.server.queue.sqs.TbAwsSqsSettings; |
45 | 45 | |
46 | +import javax.annotation.PreDestroy; | |
47 | + | |
46 | 48 | @Component |
47 | 49 | @ConditionalOnExpression("'${queue.type:null}'=='aws-sqs' && '${service.type:null}'=='tb-core'") |
48 | 50 | public class AwsSqsTbCoreQueueFactory implements TbCoreQueueFactory { |
... | ... | @@ -134,4 +136,23 @@ public class AwsSqsTbCoreQueueFactory implements TbCoreQueueFactory { |
134 | 136 | public TbQueueRequestTemplate<TbProtoJsQueueMsg<JsInvokeProtos.RemoteJsRequest>, TbProtoQueueMsg<JsInvokeProtos.RemoteJsResponse>> createRemoteJsRequestTemplate() { |
135 | 137 | return null; |
136 | 138 | } |
139 | + | |
140 | + @PreDestroy | |
141 | + private void destroy() { | |
142 | + if (coreAdmin != null) { | |
143 | + coreAdmin.destroy(); | |
144 | + } | |
145 | + if (ruleEngineAdmin != null) { | |
146 | + ruleEngineAdmin.destroy(); | |
147 | + } | |
148 | + if (jsExecutorAdmin != null) { | |
149 | + jsExecutorAdmin.destroy(); | |
150 | + } | |
151 | + if (transportApiAdmin != null) { | |
152 | + transportApiAdmin.destroy(); | |
153 | + } | |
154 | + if (notificationAdmin != null) { | |
155 | + notificationAdmin.destroy(); | |
156 | + } | |
157 | + } | |
137 | 158 | } | ... | ... |
common/queue/src/main/java/org/thingsboard/server/queue/provider/AwsSqsTbRuleEngineQueueFactory.java
... | ... | @@ -40,6 +40,8 @@ import org.thingsboard.server.queue.sqs.TbAwsSqsProducerTemplate; |
40 | 40 | import org.thingsboard.server.queue.sqs.TbAwsSqsQueueAttributes; |
41 | 41 | import org.thingsboard.server.queue.sqs.TbAwsSqsSettings; |
42 | 42 | |
43 | +import javax.annotation.PreDestroy; | |
44 | + | |
43 | 45 | @Component |
44 | 46 | @ConditionalOnExpression("'${queue.type:null}'=='aws-sqs' && '${service.type:null}'=='tb-rule-engine'") |
45 | 47 | public class AwsSqsTbRuleEngineQueueFactory implements TbRuleEngineQueueFactory { |
... | ... | @@ -114,4 +116,20 @@ public class AwsSqsTbRuleEngineQueueFactory implements TbRuleEngineQueueFactory |
114 | 116 | public TbQueueRequestTemplate<TbProtoJsQueueMsg<JsInvokeProtos.RemoteJsRequest>, TbProtoQueueMsg<JsInvokeProtos.RemoteJsResponse>> createRemoteJsRequestTemplate() { |
115 | 117 | return null; |
116 | 118 | } |
119 | + | |
120 | + @PreDestroy | |
121 | + private void destroy() { | |
122 | + if (coreAdmin != null) { | |
123 | + coreAdmin.destroy(); | |
124 | + } | |
125 | + if (ruleEngineAdmin != null) { | |
126 | + ruleEngineAdmin.destroy(); | |
127 | + } | |
128 | + if (jsExecutorAdmin != null) { | |
129 | + jsExecutorAdmin.destroy(); | |
130 | + } | |
131 | + if (notificationAdmin != null) { | |
132 | + notificationAdmin.destroy(); | |
133 | + } | |
134 | + } | |
117 | 135 | } | ... | ... |
... | ... | @@ -38,6 +38,8 @@ import org.thingsboard.server.queue.sqs.TbAwsSqsProducerTemplate; |
38 | 38 | import org.thingsboard.server.queue.sqs.TbAwsSqsQueueAttributes; |
39 | 39 | import org.thingsboard.server.queue.sqs.TbAwsSqsSettings; |
40 | 40 | |
41 | +import javax.annotation.PreDestroy; | |
42 | + | |
41 | 43 | @Component |
42 | 44 | @ConditionalOnExpression("'${queue.type:null}'=='aws-sqs' && ('${service.type:null}'=='monolith' || '${service.type:null}'=='tb-transport')") |
43 | 45 | @Slf4j |
... | ... | @@ -100,4 +102,14 @@ public class AwsSqsTransportQueueFactory implements TbTransportQueueFactory { |
100 | 102 | return new TbAwsSqsConsumerTemplate<>(notificationAdmin, sqsSettings, transportNotificationSettings.getNotificationsTopic() + "_" + serviceInfoProvider.getServiceId(), |
101 | 103 | msg -> new TbProtoQueueMsg<>(msg.getKey(), ToTransportMsg.parseFrom(msg.getData()), msg.getHeaders())); |
102 | 104 | } |
105 | + | |
106 | + @PreDestroy | |
107 | + private void destroy() { | |
108 | + if (transportApiAdmin != null) { | |
109 | + transportApiAdmin.destroy(); | |
110 | + } | |
111 | + if (notificationAdmin != null) { | |
112 | + notificationAdmin.destroy(); | |
113 | + } | |
114 | + } | |
103 | 115 | } | ... | ... |