Commit 282caa68 authored by Andre Freyssinet's avatar Andre Freyssinet

Adds correlation informations in logging to ease the message tracking.

parent dc5ad0aa
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2010 - 2020 ScalAgent Distributed Technologies
* Copyright (C) 2010 - 2021 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -70,11 +70,9 @@ public class AcquisitionModule implements ReliableTransmitter {
clazz = clazz.getSuperclass();
}
if (isDaemon && isHandler) {
throw new Exception("Acquisition class " + className
+ " can't implement both AcquisitionHandler and AcquisitionDaemon interfaces.");
throw new Exception("Acquisition class " + className + " can't implement both AcquisitionHandler and AcquisitionDaemon interfaces.");
} else if (!isDaemon && !isHandler) {
throw new Exception("Acquisition class " + className
+ " must implement either AcquisitionHandler or AcquisitionDaemon interface.");
throw new Exception("Acquisition class " + className + " must implement either AcquisitionHandler or AcquisitionDaemon interface.");
}
}
......@@ -147,8 +145,9 @@ public class AcquisitionModule implements ReliableTransmitter {
if (acquisitionHandler instanceof AcquisitionDaemon) {
isDaemon = true;
}
setProperties(properties);
// Creates and starts the AccquisitionModule.
setProperties(properties);
} catch (Exception exc) {
logger.log(BasicLevel.ERROR, "AcquisitionModule: can't create acquisition handler.", exc);
}
......@@ -404,6 +403,8 @@ public class AcquisitionModule implements ReliableTransmitter {
for (Iterator iterator = messages.iterator(); iterator.hasNext();) {
Message message = (Message) iterator.next();
if ((message.getProperty(message.CORRELATION_ID) == null) && (message.id != null))
message.setProperty(message.CORRELATION_ID, message.id);
message.id = "ID:" + destination.getDestinationId() + '_' + msgCount;
message.setDestination(destination.getId().toString(),
destination.hasName()?destination.getName():null,
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2020 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2021 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
......@@ -949,9 +949,12 @@ public class Queue extends Destination implements QueueMBean {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "Message " + msgId + " acknowledged.");
} else if ((logger.isLoggable(BasicLevel.WARN) || logmsg.isLoggable(BasicLevel.WARN))) {
logger.log(BasicLevel.WARN, "Message " + msgId + " not found for acknowledgement.");
logmsg.log(BasicLevel.WARN, getName() + ": message " + msgId + " not found for acknowledgement.");
} else {
if ((logger.isLoggable(BasicLevel.WARN) || logmsg.isLoggable(BasicLevel.WARN))) {
String str = getName() + ": message " + msgId + " not found for acknowledgement.";
logger.log(BasicLevel.WARN, str);
logmsg.log(BasicLevel.WARN, str);
}
}
}
......@@ -1442,12 +1445,25 @@ public class Queue extends Destination implements QueueMBean {
receiving = false;
}
private static final String getIdString(Message msg) {
String jmsCorrelationId = msg.getCorrelationId();
Object joramCorrelationId = msg.getMsg().getProperty(msg.getMsg().CORRELATION_ID);
if ((jmsCorrelationId == null) && (joramCorrelationId == null))
return msg.getId();
if (jmsCorrelationId == null) jmsCorrelationId = "";
if (joramCorrelationId == null) joramCorrelationId = "";
return msg.getId() + " [" + jmsCorrelationId + '/' + joramCorrelationId + "]";
}
void addDeliveryTimeMessage(Message msg, int clientCtx, boolean throwsExceptionOnFullDest, boolean isHeader) throws AccessException {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "Queue.addDeliveryTimeMessage(" + msg + ", " + clientCtx + ')');
if (logmsg.isLoggable(BasicLevel.INFO))
logmsg.log(BasicLevel.INFO, getName() + ": gets new delayed message " + msg.getId() + ", " + msg.order);
logmsg.log(BasicLevel.INFO, getName() + ": gets new delayed message " + getIdString(msg) + ", " + msg.order);
// queue is full
if (nbMaxMsg > -1 && nbMaxMsg <= (messages.size() + deliveryTable.size() + getDelayedMessageCount())) {
......@@ -1659,7 +1675,7 @@ public class Queue extends Destination implements QueueMBean {
protected final void storeMessage(Message msg, boolean throwsExceptionOnFullDest) throws AccessException {
if (addMessage(msg, throwsExceptionOnFullDest)) {
if (logmsg.isLoggable(BasicLevel.INFO))
logmsg.log(BasicLevel.INFO, getName() + ": adds new message " + msg.getId() + ", " + msg.order);
logmsg.log(BasicLevel.INFO, getName() + ": adds new message " + getIdString(msg) + ", " + msg.order);
if (msg.isPersistent()) {
// Persisting the message.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment