NO-JIRA Traces on Resource Adapter Message Handler

This commit is contained in:
Clebert Suconic 2017-07-25 12:57:10 -04:00
parent cd9ce6a502
commit 1796e5935f
1 changed files with 21 additions and 22 deletions

View File

@ -47,16 +47,15 @@ import org.apache.activemq.artemis.service.extensions.ServiceUtils;
import org.apache.activemq.artemis.service.extensions.xa.ActiveMQXAResourceWrapper; import org.apache.activemq.artemis.service.extensions.xa.ActiveMQXAResourceWrapper;
import org.apache.activemq.artemis.utils.FutureLatch; import org.apache.activemq.artemis.utils.FutureLatch;
import org.apache.activemq.artemis.utils.VersionLoader; import org.apache.activemq.artemis.utils.VersionLoader;
import org.jboss.logging.Logger;
/** /**
* The message handler * The message handler
*/ */
public class ActiveMQMessageHandler implements MessageHandler, FailoverEventListener { public class ActiveMQMessageHandler implements MessageHandler, FailoverEventListener {
/** private static final Logger logger = Logger.getLogger(ActiveMQMessageHandler.class);
* Trace enabled
*/
private static boolean trace = ActiveMQRALogger.LOGGER.isTraceEnabled();
/** /**
* The session * The session
*/ */
@ -102,8 +101,8 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList
} }
public void setup() throws Exception { public void setup() throws Exception {
if (ActiveMQMessageHandler.trace) { if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("setup()"); logger.trace("setup()");
} }
ActiveMQActivationSpec spec = activation.getActivationSpec(); ActiveMQActivationSpec spec = activation.getActivationSpec();
@ -125,7 +124,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList
if (!spec.isShareSubscriptions()) { if (!spec.isShareSubscriptions()) {
throw new javax.jms.IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)"); throw new javax.jms.IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)");
} else if (ActiveMQRALogger.LOGGER.isDebugEnabled()) { } else if (ActiveMQRALogger.LOGGER.isDebugEnabled()) {
ActiveMQRALogger.LOGGER.debug("the mdb on destination " + queueName + " already had " + logger.debug("the mdb on destination " + queueName + " already had " +
subResponse.getConsumerCount() + subResponse.getConsumerCount() +
" consumers but the MDB is configured to share subscriptions, so no exceptions are thrown"); " consumers but the MDB is configured to share subscriptions, so no exceptions are thrown");
} }
@ -214,8 +213,8 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList
* Stop the handler * Stop the handler
*/ */
public void teardown() { public void teardown() {
if (ActiveMQMessageHandler.trace) { if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("teardown()"); logger.trace("teardown()");
} }
try { try {
@ -224,7 +223,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList
endpoint = null; endpoint = null;
} }
} catch (Throwable t) { } catch (Throwable t) {
ActiveMQRALogger.LOGGER.debug("Error releasing endpoint " + endpoint, t); logger.debug("Error releasing endpoint " + endpoint, t);
} }
//only do this if we haven't been disconnected at some point whilst failing over //only do this if we haven't been disconnected at some point whilst failing over
@ -242,7 +241,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList
} }
} }
} catch (Throwable t) { } catch (Throwable t) {
ActiveMQRALogger.LOGGER.debug("Error closing core-queue consumer", t); logger.debug("Error closing core-queue consumer", t);
} }
try { try {
@ -250,14 +249,14 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList
session.close(); session.close();
} }
} catch (Throwable t) { } catch (Throwable t) {
ActiveMQRALogger.LOGGER.debug("Error releasing session " + session, t); logger.debug("Error releasing session " + session, t);
} }
try { try {
if (cf != null) { if (cf != null) {
cf.close(); cf.close();
} }
} catch (Throwable t) { } catch (Throwable t) {
ActiveMQRALogger.LOGGER.debug("Error releasing session factory " + session, t); logger.debug("Error releasing session factory " + session, t);
} }
} else { } else {
//otherwise we just clean up //otherwise we just clean up
@ -266,7 +265,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList
cf.cleanup(); cf.cleanup();
} }
} catch (Throwable t) { } catch (Throwable t) {
ActiveMQRALogger.LOGGER.debug("Error releasing session factory " + session, t); logger.debug("Error releasing session factory " + session, t);
} }
} }
@ -274,8 +273,8 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList
@Override @Override
public void onMessage(final ClientMessage message) { public void onMessage(final ClientMessage message) {
if (ActiveMQMessageHandler.trace) { if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("onMessage(" + message + ")"); logger.trace("onMessage(" + message + ")");
} }
ActiveMQMessage msg = ActiveMQMessage.createMessage(message, session, options); ActiveMQMessage msg = ActiveMQMessage.createMessage(message, session, options);
@ -286,8 +285,8 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList
tm.setTransactionTimeout(activation.getActivationSpec().getTransactionTimeout()); tm.setTransactionTimeout(activation.getActivationSpec().getTransactionTimeout());
} }
if (trace) { if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("HornetQMessageHandler::calling beforeDelivery on message " + message); logger.trace("HornetQMessageHandler::calling beforeDelivery on message " + message);
} }
endpoint.beforeDelivery(ActiveMQActivation.ONMESSAGE); endpoint.beforeDelivery(ActiveMQActivation.ONMESSAGE);
@ -306,8 +305,8 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList
message.individualAcknowledge(); message.individualAcknowledge();
} }
if (trace) { if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("HornetQMessageHandler::calling afterDelivery on message " + message); logger.trace("HornetQMessageHandler::calling afterDelivery on message " + message);
} }
try { try {
@ -324,8 +323,8 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList
session.commit(); session.commit();
} }
if (trace) { if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("finished onMessage on " + message); logger.trace("finished onMessage on " + message);
} }
} catch (Throwable e) { } catch (Throwable e) {
ActiveMQRALogger.LOGGER.errorDeliveringMessage(e); ActiveMQRALogger.LOGGER.errorDeliveringMessage(e);