public AbstractMessageListenerContainer chooseMessageListenerContainerImplementation(JmsEndpoint endpoint) { switch (consumerType) { case Simple: return new SimpleJmsMessageListenerContainer(endpoint); case Default: return new DefaultJmsMessageListenerContainer(endpoint); case Custom: return getCustomMessageListenerContainer(endpoint); default: throw new IllegalArgumentException("Unknown consumer type: " + consumerType); } }
@Override public void stop() throws JmsException { if (logger.isDebugEnabled()) { logger.debug("Stopping listenerContainer: " + this + " with cacheLevel: " + getCacheLevel() + " and sharedConnectionEnabled: " + sharedConnectionEnabled()); } super.stop(); if (taskExecutor instanceof ThreadPoolTaskExecutor) { ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) taskExecutor; executor.destroy(); } }
@Override protected void stopSharedConnection() { if (logger.isDebugEnabled()) { if (sharedConnectionEnabled()) { logger.debug("Stopping shared connection on listenerContainer: " + this); } } super.stopSharedConnection(); } }
@Override protected boolean runningAllowed() { // we can stop quickly if CamelContext is being stopped, and we do not accept messages while stopping // this allows a more cleanly shutdown of the message listener boolean quickStop = false; if (isAllowQuickStop() && !endpoint.isAcceptMessagesWhileStopping()) { quickStop = endpoint.getCamelContext().getStatus().isStopping(); } if (quickStop) { // log at debug level so its quicker to see we are stopping quicker from the logs logger.debug("runningAllowed() -> false due CamelContext is stopping and endpoint configured to not accept messages while stopping"); return false; } else { // otherwise we only run if the endpoint is running boolean answer = endpoint.isRunning(); // log at trace level as otherwise this can be noisy during normal operation logger.trace("runningAllowed() -> " + answer); return answer; } }
protected TaskExecutor createDefaultTaskExecutor() { String pattern = endpoint.getCamelContext().getExecutorServiceManager().getThreadNamePattern(); String beanName = getBeanName() == null ? endpoint.getThreadName() : getBeanName();
@Override public void destroy() { if (logger.isDebugEnabled()) { logger.debug("Destroying listenerContainer: " + this + " with cacheLevel: " + getCacheLevel() + " and sharedConnectionEnabled: " + sharedConnectionEnabled()); } super.destroy(); if (taskExecutor instanceof ThreadPoolTaskExecutor) { ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) taskExecutor; executor.destroy(); } }
@Override protected AbstractMessageListenerContainer createListenerContainer() throws Exception { DefaultMessageListenerContainer answer = new DefaultJmsMessageListenerContainer(endpoint, endpoint.isAllowReplyManagerQuickStop());