Skip to content

Commit

Permalink
Added some log guarding
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Williams committed Mar 5, 2021
1 parent 86a2da0 commit 0f3ad9e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class McsSenderPlugin extends MessageSenderBase implements MessageCallbac
private MessageConsumer _messageConsumer;
private BlockingQueue<String> _blockingQueue;
private ExecutorService _executor = Executors.newFixedThreadPool(2);

public static Boolean VerboseLogging = false;

@SuppressWarnings("unchecked")
public McsSenderPlugin() {
Expand All @@ -65,6 +67,10 @@ public void start() {
try {
_logger.info("Configuration Properties: " + config.getProperties());

if (config.containsProperty("verboseLogging")) {
VerboseLogging = (boolean)config.getProperty("verboseLogging");
}

setupConnection();
}
catch (Exception e) {
Expand Down Expand Up @@ -106,10 +112,12 @@ public void messageReceived(String message){
return;
}

_logger.info("TAK message converted: " + takMessage);
if(VerboseLogging)
_logger.info("TAK message converted: " + takMessage);

send(takMessage);
} catch (Exception exception) {
_logger.error("error converting message", exception);
_logger.error("error converting message ", message, exception);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import tak.server.plugins.processing.*;
import tak.server.plugins.PluginConfiguration;
import tak.server.plugins.McsSenderPlugin;

public class RabbitMQConsumer {
private MessageProducer _producer;
Expand Down Expand Up @@ -49,9 +50,11 @@ public void SetupConsumption(MessageProducer producer, PluginConfiguration confi
String queueName = _channel.queueDeclare().getQueue();
_channel.queueBind(queueName, _exchangeName, _routingKey);


DeliverCallback deliverCallback = (consumerTag, delivery) -> {
String message = new String(delivery.getBody(), "UTF-8");
logger.info("Msg Received '" + delivery.getEnvelope().getRoutingKey() + "':'" + message + "'");
if (McsSenderPlugin.VerboseLogging)
logger.info("Msg Received '" + delivery.getEnvelope().getRoutingKey() + "':'" + message + "'");
_producer.AddMessage(message);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.util.concurrent.atomic.AtomicBoolean;

import tak.server.plugins.McsSenderPlugin;
import tak.server.plugins.interfaces.*;

public class MessageConsumer {
Expand All @@ -34,7 +35,8 @@ public void Start(){
try {
while(_running.get()) {
String message = _queue.take();
_logger.info("message received in consumer sending to callback");
if (McsSenderPlugin.VerboseLogging)
_logger.info("message received in consumer sending to callback");
_callback.messageReceived(message);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
processing_queue_size: 10
useRapidX : true
verboseLogging : false
rabbitmq:
exchange_name: "dragonfly"
routing_key: "dragonfly.demo_entities"
Expand Down

0 comments on commit 0f3ad9e

Please sign in to comment.