/** * Resume the lister - Brings the lister into active mode back from a paused state * * @throws AxisFault on error */ @Override public void resume() throws AxisFault { if (state != BaseConstants.PAUSED) return; try { for (JMSEndpoint endpoint : getEndpoints()) { endpoint.getServiceTaskManager().resume(); } state = BaseConstants.STARTED; log.info("Listener resumed"); } catch (AxisJMSException e) { log.error("At least one service could not be resumed", e); } }
/** * Stops listening for messages for the service thats undeployed or stopped * * @param endpoint the jms endpoint which is connected with the service */ @Override protected void stopEndpoint(JMSEndpoint endpoint) { ServiceTaskManager stm = endpoint.getServiceTaskManager(); if (log.isDebugEnabled()) { log.debug( "Stopping listening on destination : " + stm.getDestinationJNDIName() + " for service : " + stm.getServiceName()); } stm.stop(); log.info("Stopped listening for JMS messages to service : " + endpoint.getServiceName()); }
/** * Listen for JMS messages on behalf of the given service * * @param endpoint the jms endpoint which is connected with the service */ @Override protected void startEndpoint(JMSEndpoint endpoint) throws AxisFault { ServiceTaskManager stm = endpoint.getServiceTaskManager(); boolean connected = false; /* The following parameters are used when trying to connect with the JMS provider at the start up*/ int r = 1; long retryDuration = 10000; double reconnectionProgressionFactor = 2.0; long maxReconnectDuration = 1000 * 60 * 60; // 1 hour // First we will check whether jms provider is started or not, as if not it will throw a // continuous error log // If jms provider not started we will wait for exponentially increasing time intervals, till // the provider is started while (!connected) { boolean jmsProviderStarted = checkJMSConnection(stm); if (jmsProviderStarted) { log.info( "Connection attempt: " + r + " for JMS Provider for service: " + stm.getServiceName() + " was successful!"); connected = true; stm.start(); for (int i = 0; i < 3; i++) { // Check the consumer count rather than the active task count. Reason: if the // destination is of type topic, then the transport is only ready to receive // messages if at least one consumer exists. This is of not much importance, // except for automated tests. if (stm.getConsumerCount() > 0) { log.info( "Started to listen on destination : " + stm.getDestinationJNDIName() + " of type " + JMSUtils.getDestinationTypeAsString(stm.getDestinationType()) + " for service " + stm.getServiceName()); return; } try { Thread.sleep(1000); } catch (InterruptedException ignore) { } } log.warn( "Polling tasks on destination : " + stm.getDestinationJNDIName() + " of type " + JMSUtils.getDestinationTypeAsString(stm.getDestinationType()) + " for service " + stm.getServiceName() + " have not yet started after 3 seconds .."); } else { log.error( "Unable to continue server startup as it seems the JMS Provider is not yet started. Please start the JMS provider now."); retryDuration = (long) (retryDuration * reconnectionProgressionFactor); log.error( "Connection attempt : " + (r++) + " for JMS Provider failed. Next retry in " + (retryDuration / 1000) + " seconds"); if (retryDuration > maxReconnectDuration) { retryDuration = maxReconnectDuration; } try { Thread.sleep(retryDuration); } catch (InterruptedException ignore) { } } } }