Commit f471001c authored by Andre Freyssinet's avatar Andre Freyssinet

Logging enhancements.

parent ac30755b
......@@ -1617,18 +1617,16 @@ public class Session implements javax.jms.Session, SessionMBean {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, this + ": committed.");
}
// Catching an exception if the sendings or acknowledgement went wrong:
catch (JMSException jE) {
if (logger.isLoggable(BasicLevel.ERROR))
logger.log(BasicLevel.ERROR, "", jE);
TransactionRolledBackException tE = new TransactionRolledBackException(
"A JMSException was thrown during the commit.");
} catch (JMSException jE) {
// Catching an exception if the sendings or acknowledgement went wrong:
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.ERROR, "A JMSException was thrown during the commit", jE);
else
logger.log(BasicLevel.ERROR, "A JMSException was thrown during the commit: " + jE.getMessage());
TransactionRolledBackException tE = new TransactionRolledBackException("A JMSException was thrown during the commit.");
tE.setLinkedException(jE);
if (logger.isLoggable(BasicLevel.ERROR))
logger.log(BasicLevel.ERROR, "Exception: " + tE);
rollback();
throw tE;
}
......
......@@ -217,7 +217,7 @@ public class JMSAcquisition implements AcquisitionDaemon {
*/
public void onMessage(javax.jms.Message jmsMessage) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, connection.getName() + ".onMessage(" + jmsMessage + ')');
logger.log(BasicLevel.DEBUG, "JMSAcquisition[" + connection.getName() + "].onMessage(" + jmsMessage + ')');
try {
org.objectweb.joram.client.jms.Message clientMessage = null;
......@@ -226,10 +226,12 @@ public class JMSAcquisition implements AcquisitionDaemon {
org.objectweb.joram.client.jms.Message.prepareJMSMessage(clientMessage);
} catch (JMSException conversionExc) {
// Conversion error: denying the message.
if (logger.isLoggable(BasicLevel.WARN))
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.WARN,
"JMSAcquisition[" + connection.getName() + "].onMessage, rollback, can not convert message.", conversionExc);
else
logger.log(BasicLevel.WARN,
connection.getName() + ".onMessage: rollback, can not convert message.",
conversionExc);
"JMSAcquisition[" + connection.getName() + "].onMessage, rollback, can not convert message: " + conversionExc.getMessage());
session.rollback();
return;
......@@ -237,23 +239,28 @@ public class JMSAcquisition implements AcquisitionDaemon {
transmitter.transmit(clientMessage.getMomMsg(), jmsMessage.getJMSMessageID());
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, connection.getName() + ".onMessage: Try to commit.");
logger.log(BasicLevel.DEBUG, "JMSAcquisition[" + connection.getName() + "].onMessage: Try to commit.");
session.commit();
} catch (JMSException exc) {
// Commit or rollback failed: nothing to do.
logger.log(BasicLevel.ERROR,
connection.getName() + ".onMessage(" + jmsMessage + ')', exc);
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.ERROR, "JMSAcquisition[" + connection.getName() + "].onMessage(" + jmsMessage + ')', exc);
else
logger.log(BasicLevel.ERROR, "JMSAcquisition[" + connection.getName() + "].onMessage(" + jmsMessage + "): " + exc.getMessage());
} catch (Throwable t) {
logger.log(BasicLevel.ERROR,
connection.getName() + ".onMessage(" + jmsMessage + ')', t);
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.ERROR, "JMSAcquisition[" + connection.getName() + "].onMessage(" + jmsMessage + ')', t);
else
logger.log(BasicLevel.ERROR, "JMSAcquisition[" + connection.getName() + "].onMessage(" + jmsMessage + "): " + t.getMessage());
}
}
public void onException(JMSException exception) {
if (logger.isLoggable(BasicLevel.DEBUG)) {
logger.log(BasicLevel.DEBUG, connection.getName() + ": Consumer error for session " + session);
}
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.WARN, "JMSAcquisition[" + connection.getName() + "]: Consumer error for session " + session, exception);
else
logger.log(BasicLevel.WARN, "JMSAcquisition[" + connection.getName() + "]: Consumer error for session " + session, exception);
if (!closing) {
listeners.remove(connection.getName());
}
......
......@@ -351,9 +351,10 @@ public class JMSModule implements ExceptionListener, Serializable, JMSModuleMBea
* Reacts by launching a reconnection process.
*/
public void onException(JMSException exc) {
if (logger.isLoggable(BasicLevel.WARN)) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.WARN, "JMSModule.onException()", exc);
}
else
logger.log(BasicLevel.WARN, "JMSModule.onException(): " + exc.getMessage());
if (listeners != null) {
for (Iterator<JmsListener> listener = listeners.iterator(); listener.hasNext();) {
......@@ -368,7 +369,10 @@ public class JMSModule implements ExceptionListener, Serializable, JMSModuleMBea
try {
cnx.close();
} catch (JMSException exc2) {
logger.log(BasicLevel.INFO, "JMSModule.onException(), error closing the connection", exc2);
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.INFO, "JMSModule.onException(), error closing the connection", exc2);
else
logger.log(BasicLevel.INFO, "JMSModule.onException(), error closing the connection: " + exc2.getMessage());
}
}
......
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