Skip to content

Commit b2173c6

Browse files
Updated to support turning off entity or event topics
1 parent aca286e commit b2173c6

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/src/main/java/tak/server/plugins/messagebroker/RabbitMQClient.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
public class RabbitMQClient {
2121
private MessageProducer _producer;
2222
private String _exchangeName = "dragonfly";
23+
private Boolean _enableEntityRouting = true;
24+
private Boolean _enableEventRouting = true;
2325
private String _entityRoutingKey = "dragonfly.demo_entities";
2426
private String _eventRoutingKey = "dragonfly.events";
2527
private String _rabbitHost = "some-rabbit";
@@ -55,8 +57,15 @@ public void SetupConsumption(MessageProducer producer, PluginConfiguration confi
5557
_channel.exchangeDeclare(_exchangeName, "topic", true);
5658
String queueName = _channel.queueDeclare().getQueue();
5759

58-
_channel.queueBind(queueName, _exchangeName, _eventRoutingKey);
59-
_channel.queueBind(queueName, _exchangeName, _entityRoutingKey);
60+
if (_enableEventRouting == true)
61+
_channel.queueBind(queueName, _exchangeName, _eventRoutingKey);
62+
else
63+
logger.info("Event Routing disabled");
64+
65+
if (_enableEntityRouting == true)
66+
_channel.queueBind(queueName, _exchangeName, _entityRoutingKey);
67+
else
68+
logger.info("Entity Routing disabled");
6069

6170
DeliverCallback deliverCallback = (consumerTag, delivery) -> {
6271
String message = new String(delivery.getBody(), "UTF-8");
@@ -140,5 +149,13 @@ private void SetupConfiguration(PluginConfiguration configuration) {
140149
if (configuration.containsProperty("useRapidX")) {
141150
_useRapidX = (boolean)configuration.getProperty("useRapidX");
142151
}
152+
153+
if (configuration.containsProperty("rabbitmq.enableEntityRouting")) {
154+
_enableEntityRouting = (boolean)configuration.getProperty("rabbitmq.enableEntityRouting");
155+
}
156+
157+
if (configuration.containsProperty("rabbitmq.enableEventRouting")) {
158+
_enableEventRouting = (boolean)configuration.getProperty("rabbitmq.enableEventRouting");
159+
}
143160
}
144161
}

TAK Server Plugin/Plugin/src/takserver-sender-plugin-mcs/tak.server.plugins.McsSenderPlugin.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ rabbitmq:
77
username: "rapidx"
88
password: "dragonfly"
99
entityKey: "dragonfly.demo_entities"
10+
enableEntityRouting: true
1011
eventKey: "dragonfly.events"
12+
enableEventRouting: true
1113

TAK Server Plugin/RabbitMQ Client/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Program
1717
private static string USERNAME = "rapidx";
1818
private static bool USE_RAPIDX = true;
1919

20-
private static string MESSAGE = "{\"uid\":\"ExampleCompany.12345-abcde-6789-fghij\",\"type\":\"a-f-G-U-C\",\"time\":\"1614187736429\",\"start\":\"1614187736429\",\"stale\":\"1614191352000\",\"how\":\"m-g\",\"point\":{\"lat\":\"39.0495\",\"lon\":\"-85.7445\",\"hae\":\"9999999\",\"ce\":\"9999999\",\"le\":\"9999999\"},\"detail\":{\"milsym2525C\":\"SFGPUCI*****\"}}";
20+
private static string MESSAGE = "{\"uid\":\"ExampleCompany.12345-abcde-6789-fghij\",\"type\":\"a-f-G-U-C\",\"time\":\"1614187736429\",\"start\":\"1614187736429\",\"stale\":\"1614191352000\",\"how\":\"m-g\",\"point\":{\"lat\":\"39.0495\",\"lon\":\"-85.7445\",\"hae\":\"9999999\",\"ce\":\"9999999\",\"le\":\"9999999\"},\"detail\":{\"milsym2525C\":\"SFGPUCI*****\", \"video\":\"https://cdn.bitdegree.org/learn/Pexels%20Videos%203373.mp4?raw=true\", \"feedType\":\"OSH_SENSOR\",\"serviceDetails\":{\"serviceUrl\":\"THE SERVICE URL\",\"provider\":{\"providerName\":\"SOME NAME\",\"providerData\":\"SOME DATA\"},\"offeringID\":\"THE OFFERING ID\",\"temporalData\":\"THE TEMPORAL DATA\"}}}";
2121

2222
private static string EVENT_MESSAGE = "{\"cot_uid\":\"b5034f03-b209-47a8-aa39-31d32e8ee337\",\"message\":\"This is a demo alert\",\"type\":\"warning\"}";
2323

0 commit comments

Comments
 (0)