コード例 #1
0
 private SimpleMessageListenerContainer createContainer() throws Exception {
   // if (!messageDriven) TODO: no container attributes would apply if not message-driven
   SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
   if (this.acknowledgeMode != null) {
     container.setAcknowledgeMode(this.acknowledgeMode);
   }
   if (!ObjectUtils.isEmpty(this.adviceChain)) {
     container.setAdviceChain(this.adviceChain);
   }
   container.setAutoStartup(this.autoStartup);
   container.setChannelTransacted(this.channelTransacted);
   if (this.concurrentConsumers != null) {
     container.setConcurrentConsumers(this.concurrentConsumers);
   }
   container.setConnectionFactory(this.connectionFactory);
   if (this.errorHandler != null) {
     container.setErrorHandler(this.errorHandler);
   }
   if (this.exposeListenerChannel != null) {
     container.setExposeListenerChannel(this.exposeListenerChannel);
   }
   if (this.messagePropertiesConverter != null) {
     container.setMessagePropertiesConverter(this.messagePropertiesConverter);
   }
   if (this.phase != null) {
     container.setPhase(this.phase);
   }
   if (this.prefetchCount != null) {
     container.setPrefetchCount(this.prefetchCount);
   }
   if (this.receiveTimeout != null) {
     container.setReceiveTimeout(this.receiveTimeout);
   }
   if (this.recoveryInterval != null) {
     container.setRecoveryInterval(this.recoveryInterval);
   }
   if (this.shutdownTimeout != null) {
     container.setShutdownTimeout(this.shutdownTimeout);
   }
   if (this.taskExecutor != null) {
     container.setTaskExecutor(this.taskExecutor);
   }
   if (this.transactionAttribute != null) {
     container.setTransactionAttribute(this.transactionAttribute);
   }
   if (this.transactionManager != null) {
     container.setTransactionManager(this.transactionManager);
   }
   if (this.txSize != null) {
     container.setTxSize(this.txSize);
   }
   if (this.missingQueuesFatal != null) {
     container.setMissingQueuesFatal(this.missingQueuesFatal);
   }
   return container;
 }
 private SimpleMessageListenerContainer createContainer(Object listener) {
   SimpleMessageListenerContainer container =
       new SimpleMessageListenerContainer(template.getConnectionFactory());
   container.setMessageListener(listener);
   container.setQueueNames(queue.getName());
   container.setTxSize(txSize);
   container.setPrefetchCount(txSize);
   container.setConcurrentConsumers(concurrentConsumers);
   container.setChannelTransacted(transactional);
   container.setAcknowledgeMode(acknowledgeMode);
   // requires RabbitMQ 3.2.x
   //		container.setConsumerArguments(Collections. <String, Object> singletonMap("x-priority",
   // Integer.valueOf(10)));
   if (externalTransaction) {
     container.setTransactionManager(new TestTransactionManager());
   }
   container.afterPropertiesSet();
   container.start();
   return container;
 }