List of usage examples for javax.jms MessageListener toString
public String toString()
From source file:dk.netarkivet.common.distribute.JMSConnection.java
/** * Method adds a listener to the given queue or topic. * * @param channelName the messagequeue to listen to * @param ml the messagelistener * * @throws IOFailure if the operation failed. *//*from w w w .j a v a 2 s . c om*/ private void setListener(String channelName, MessageListener ml) { log.debug("Adding " + ml.toString() + " as listener to " + channelName); String errMsg = "JMS-error - could not add Listener to queue/topic: " + channelName; int tries = 0; boolean operationSuccessful = false; Exception lastException = null; while (!operationSuccessful && tries < JMS_MAXTRIES) { tries++; try { connectionLock.readLock().lock(); try { getConsumer(channelName, ml).setMessageListener(ml); } finally { connectionLock.readLock().unlock(); } operationSuccessful = true; } catch (JMSException e) { lastException = e; log.debug("Set listener failed (try " + tries + ")", e); if (tries < JMS_MAXTRIES) { onException(e); log.debug("Will sleep a while before trying to set listener" + " again"); TimeUtils.exponentialBackoffSleep(tries, Calendar.MINUTE); } } catch (Exception e) { lastException = e; log.debug("Set listener failed (try " + tries + ")", e); if (tries < JMS_MAXTRIES) { reconnect(); log.debug("Will sleep a while before trying to set listener" + " again"); TimeUtils.exponentialBackoffSleep(tries, Calendar.MINUTE); } } } if (!operationSuccessful) { log.warn(errMsg, lastException); throw new IOFailure(errMsg, lastException); } }