@Override public void onInit() { super.onInit(); this.dispatcher = this.createDispatcher(); if (this.maxSubscribers == null) { this.maxSubscribers = this.getIntegrationProperty(this.isPubSub ? IntegrationProperties.CHANNELS_MAX_BROADCAST_SUBSCRIBERS : IntegrationProperties.CHANNELS_MAX_UNICAST_SUBSCRIBERS, Integer.class); } setMaxSubscribers(this.maxSubscribers); String queue = obtainQueueName(this.channelName); this.container.setQueueNames(queue); MessageConverter converter = (this.getAmqpTemplate() instanceof RabbitTemplate) ? ((RabbitTemplate) this.getAmqpTemplate()).getMessageConverter() : new SimpleMessageConverter(); MessageListener listener = new DispatchingMessageListener(converter, this.dispatcher, this, this.isPubSub, getMessageBuilderFactory(), getInboundHeaderMapper()); this.container.setMessageListener(listener); if (!this.container.isActive()) { this.container.afterPropertiesSet(); } }
/** * Handle the given exception that arose during listener execution. * <p> * The default implementation logs the exception at error level, not propagating it to the Rabbit provider - * assuming that all handling of acknowledgment and/or transactions is done by this listener container. This can be * overridden in subclasses. * @param ex the exception to handle */ protected void handleListenerException(Throwable ex) { if (isActive()) { // Regular case: failed while active. // Invoke ErrorHandler if available. invokeErrorHandler(ex); } else { // Rare case: listener thread failed after container shutdown. // Log at debug level, to avoid spamming the shutdown log. logger.debug("Listener exception after container shutdown", ex); } }
/** * Handle the given exception that arose during listener execution. * <p> * The default implementation logs the exception at error level, not propagating it to the Rabbit provider - * assuming that all handling of acknowledgment and/or transactions is done by this listener container. This can be * overridden in subclasses. * @param ex the exception to handle */ protected void handleListenerException(Throwable ex) { if (isActive()) { // Regular case: failed while active. // Invoke ErrorHandler if available. invokeErrorHandler(ex); } else { // Rare case: listener thread failed after container shutdown. // Log at debug level, to avoid spamming the shutdown log. logger.debug("Listener exception after container shutdown", ex); } }
/** * Stop the shared Connection, call {@link #doShutdown()}, and close this container. */ public void shutdown() { synchronized (this.lifecycleMonitor) { if (!isActive()) { logger.info("Shutdown ignored - container is not active already"); return; } this.active = false; this.lifecycleMonitor.notifyAll(); } logger.debug("Shutting down Rabbit listener container"); // Shut down the invokers. try { doShutdown(); } catch (Exception ex) { throw convertRabbitAccessException(ex); } finally { synchronized (this.lifecycleMonitor) { this.running = false; this.lifecycleMonitor.notifyAll(); } } }
/** * Stop the shared Connection, call {@link #doShutdown()}, and close this container. */ public void shutdown() { synchronized (this.lifecycleMonitor) { if (!isActive()) { logger.info("Shutdown ignored - container is not active already"); return; } this.active = false; this.lifecycleMonitor.notifyAll(); } logger.debug("Shutting down Rabbit listener container"); // Shut down the invokers. try { doShutdown(); } catch (Exception ex) { throw convertRabbitAccessException(ex); } finally { synchronized (this.lifecycleMonitor) { this.running = false; this.lifecycleMonitor.notifyAll(); } } }
@Override public void onInit() { super.onInit(); this.dispatcher = this.createDispatcher(); if (this.maxSubscribers == null) { this.maxSubscribers = this.getIntegrationProperty(this.isPubSub ? IntegrationProperties.CHANNELS_MAX_BROADCAST_SUBSCRIBERS : IntegrationProperties.CHANNELS_MAX_UNICAST_SUBSCRIBERS, Integer.class); } setMaxSubscribers(this.maxSubscribers); String queue = obtainQueueName(this.channelName); this.container.setQueueNames(queue); MessageConverter converter = (this.getAmqpTemplate() instanceof RabbitTemplate) ? ((RabbitTemplate) this.getAmqpTemplate()).getMessageConverter() : new SimpleMessageConverter(); MessageListener listener = new DispatchingMessageListener(converter, this.dispatcher, this, this.isPubSub, getMessageBuilderFactory(), getInboundHeaderMapper()); this.container.setMessageListener(listener); if (!this.container.isActive()) { this.container.afterPropertiesSet(); } }