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 | 15 | */ |
16 | 16 | package org.thingsboard.server.controller; |
17 | 17 | |
18 | +import org.springframework.beans.factory.annotation.Autowired; | |
18 | 19 | import org.springframework.security.access.prepost.PreAuthorize; |
19 | 20 | import org.springframework.web.bind.annotation.RequestMapping; |
20 | 21 | import org.springframework.web.bind.annotation.RequestMethod; |
... | ... | @@ -23,17 +24,23 @@ import org.springframework.web.bind.annotation.ResponseBody; |
23 | 24 | import org.springframework.web.bind.annotation.RestController; |
24 | 25 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
25 | 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 | 29 | import org.thingsboard.server.queue.util.TbCoreComponent; |
27 | 30 | |
28 | 31 | import java.util.Arrays; |
29 | 32 | import java.util.Collections; |
30 | 33 | import java.util.List; |
34 | +import java.util.stream.Collectors; | |
31 | 35 | |
32 | 36 | @RestController |
33 | 37 | @TbCoreComponent |
34 | 38 | @RequestMapping("/api") |
35 | 39 | public class QueueController extends BaseController { |
36 | 40 | |
41 | + @Autowired(required = false) | |
42 | + private TbQueueRuleEngineSettings ruleEngineSettings; | |
43 | + | |
37 | 44 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
38 | 45 | @RequestMapping(value = "/tenant/queues", params = {"serviceType"}, method = RequestMethod.GET) |
39 | 46 | @ResponseBody |
... | ... | @@ -43,7 +50,12 @@ public class QueueController extends BaseController { |
43 | 50 | ServiceType type = ServiceType.valueOf(serviceType); |
44 | 51 | switch (type) { |
45 | 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 | 59 | default: |
48 | 60 | return Collections.emptyList(); |
49 | 61 | } | ... | ... |