Commit a477cad1b7acb45bddd45d4db107f0c414d3061c
Committed by
Andrew Shvayka
1 parent
5465703d
QueueController has return queue list from yaml config (TbQueueRuleEngineSetting…
…s). Tip: queue list consumes UI on device profile details
Showing
1 changed file
with
13 additions
and
1 deletions
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.controller; | 16 | package org.thingsboard.server.controller; |
17 | 17 | ||
18 | +import org.springframework.beans.factory.annotation.Autowired; | ||
18 | import org.springframework.security.access.prepost.PreAuthorize; | 19 | import org.springframework.security.access.prepost.PreAuthorize; |
19 | import org.springframework.web.bind.annotation.RequestMapping; | 20 | import org.springframework.web.bind.annotation.RequestMapping; |
20 | import org.springframework.web.bind.annotation.RequestMethod; | 21 | import org.springframework.web.bind.annotation.RequestMethod; |
@@ -23,17 +24,23 @@ import org.springframework.web.bind.annotation.ResponseBody; | @@ -23,17 +24,23 @@ import org.springframework.web.bind.annotation.ResponseBody; | ||
23 | import org.springframework.web.bind.annotation.RestController; | 24 | import org.springframework.web.bind.annotation.RestController; |
24 | import org.thingsboard.server.common.data.exception.ThingsboardException; | 25 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
25 | import org.thingsboard.server.common.msg.queue.ServiceType; | 26 | import org.thingsboard.server.common.msg.queue.ServiceType; |
27 | +import org.thingsboard.server.queue.settings.TbQueueRuleEngineSettings; | ||
28 | +import org.thingsboard.server.queue.settings.TbRuleEngineQueueConfiguration; | ||
26 | import org.thingsboard.server.queue.util.TbCoreComponent; | 29 | import org.thingsboard.server.queue.util.TbCoreComponent; |
27 | 30 | ||
28 | import java.util.Arrays; | 31 | import java.util.Arrays; |
29 | import java.util.Collections; | 32 | import java.util.Collections; |
30 | import java.util.List; | 33 | import java.util.List; |
34 | +import java.util.stream.Collectors; | ||
31 | 35 | ||
32 | @RestController | 36 | @RestController |
33 | @TbCoreComponent | 37 | @TbCoreComponent |
34 | @RequestMapping("/api") | 38 | @RequestMapping("/api") |
35 | public class QueueController extends BaseController { | 39 | public class QueueController extends BaseController { |
36 | 40 | ||
41 | + @Autowired(required = false) | ||
42 | + private TbQueueRuleEngineSettings ruleEngineSettings; | ||
43 | + | ||
37 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 44 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
38 | @RequestMapping(value = "/tenant/queues", params = {"serviceType"}, method = RequestMethod.GET) | 45 | @RequestMapping(value = "/tenant/queues", params = {"serviceType"}, method = RequestMethod.GET) |
39 | @ResponseBody | 46 | @ResponseBody |
@@ -43,7 +50,12 @@ public class QueueController extends BaseController { | @@ -43,7 +50,12 @@ public class QueueController extends BaseController { | ||
43 | ServiceType type = ServiceType.valueOf(serviceType); | 50 | ServiceType type = ServiceType.valueOf(serviceType); |
44 | switch (type) { | 51 | switch (type) { |
45 | case TB_RULE_ENGINE: | 52 | case TB_RULE_ENGINE: |
46 | - return Arrays.asList("Main", "HighPriority", "SequentialByOriginator"); | 53 | + if (ruleEngineSettings == null) { |
54 | + return Arrays.asList("Main", "HighPriority", "SequentialByOriginator"); | ||
55 | + } | ||
56 | + return ruleEngineSettings.getQueues().stream() | ||
57 | + .map(TbRuleEngineQueueConfiguration::getName) | ||
58 | + .collect(Collectors.toList()); | ||
47 | default: | 59 | default: |
48 | return Collections.emptyList(); | 60 | return Collections.emptyList(); |
49 | } | 61 | } |