List of usage examples for org.springframework.amqp.rabbit.listener RabbitListenerEndpoint getId
String getId();
From source file:org.springframework.amqp.rabbit.config.AbstractRabbitListenerContainerFactory.java
@Override public C createListenerContainer(RabbitListenerEndpoint endpoint) { C instance = createContainerInstance(); if (this.connectionFactory != null) { instance.setConnectionFactory(this.connectionFactory); }//from w ww.j a v a 2 s. co m if (this.errorHandler != null) { instance.setErrorHandler(this.errorHandler); } if (this.messageConverter != null) { instance.setMessageConverter(this.messageConverter); } if (this.acknowledgeMode != null) { instance.setAcknowledgeMode(this.acknowledgeMode); } if (this.channelTransacted != null) { instance.setChannelTransacted(this.channelTransacted); } if (this.applicationContext != null) { instance.setApplicationContext(this.applicationContext); } if (this.taskExecutor != null) { instance.setTaskExecutor(this.taskExecutor); } if (this.transactionManager != null) { instance.setTransactionManager(this.transactionManager); } if (this.prefetchCount != null) { instance.setPrefetchCount(this.prefetchCount); } if (this.defaultRequeueRejected != null) { instance.setDefaultRequeueRejected(this.defaultRequeueRejected); } if (this.adviceChain != null) { instance.setAdviceChain(this.adviceChain); } if (this.recoveryBackOff != null) { instance.setRecoveryBackOff(this.recoveryBackOff); } if (this.mismatchedQueuesFatal != null) { instance.setMismatchedQueuesFatal(this.mismatchedQueuesFatal); } if (this.missingQueuesFatal != null) { instance.setMissingQueuesFatal(this.missingQueuesFatal); } if (this.consumerTagStrategy != null) { instance.setConsumerTagStrategy(this.consumerTagStrategy); } if (this.idleEventInterval != null) { instance.setIdleEventInterval(this.idleEventInterval); } if (this.failedDeclarationRetryInterval != null) { instance.setFailedDeclarationRetryInterval(this.failedDeclarationRetryInterval); } if (this.applicationEventPublisher != null) { instance.setApplicationEventPublisher(this.applicationEventPublisher); } if (this.autoStartup != null) { instance.setAutoStartup(this.autoStartup); } if (this.phase != null) { instance.setPhase(this.phase); } instance.setListenerId(endpoint.getId()); endpoint.setupListenerContainer(instance); initializeContainer(instance); return instance; }
From source file:org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.java
/** * Create a message listener container for the given {@link RabbitListenerEndpoint}. * <p>This create the necessary infrastructure to honor that endpoint * with regards to its configuration.//from ww w .j a v a 2s. c o m * <p>The {@code startImmediately} flag determines if the container should be * started immediately. * @param endpoint the endpoint to add. * @param factory the {@link RabbitListenerContainerFactory} to use. * @param startImmediately start the container immediately if necessary * @see #getListenerContainers() * @see #getListenerContainer(String) */ @SuppressWarnings("unchecked") public void registerListenerContainer(RabbitListenerEndpoint endpoint, RabbitListenerContainerFactory<?> factory, boolean startImmediately) { Assert.notNull(endpoint, "Endpoint must not be null"); Assert.notNull(factory, "Factory must not be null"); String id = endpoint.getId(); Assert.hasText(id, "Endpoint id must not be empty"); synchronized (this.listenerContainers) { Assert.state(!this.listenerContainers.containsKey(id), "Another endpoint is already registered with id '" + id + "'"); MessageListenerContainer container = createListenerContainer(endpoint, factory); this.listenerContainers.put(id, container); if (StringUtils.hasText(endpoint.getGroup()) && this.applicationContext != null) { List<MessageListenerContainer> containerGroup; if (this.applicationContext.containsBean(endpoint.getGroup())) { containerGroup = this.applicationContext.getBean(endpoint.getGroup(), List.class); } else { containerGroup = new ArrayList<MessageListenerContainer>(); this.applicationContext.getBeanFactory().registerSingleton(endpoint.getGroup(), containerGroup); } containerGroup.add(container); } if (startImmediately) { startIfNecessary(container); } } }