0
我有一個bean配置SimpleRabbitListenerContainerFactory
但是當我使用factory.setTaskExecutor(taskScheduler);
我得到這個日誌,其延遲應用程序啓動時超過300+秒。但如果我評論這TaskExecutor一切工作正常。正確配置SimpleRabbitListenerContainerFactory
登錄上調試級別:
2017-04-24 15:48:45.449 DEBUG 28550 --- [ JWorkers-4] o.s.a.r.t.RabbitTransactionManager : Initiating transaction commit
2017-04-24 15:48:45.449 DEBUG 28550 --- [ JWorkers-7] o.s.a.r.t.RabbitTransactionManager : Initiating transaction commit
2017-04-24 15:48:45.449 DEBUG 28550 --- [ JWorkers-1] o.s.a.r.t.RabbitTransactionManager : Initiating transaction commit
2017-04-24 15:48:45.449 DEBUG 28550 --- [ JWorkers-2] o.s.a.r.t.RabbitTransactionManager : Initiating transaction commit
2017-04-24 15:48:45.449 DEBUG 28550 --- [ JWorkers-6] o.s.a.r.t.RabbitTransactionManager : Initiating transaction commit
2017-04-24 15:48:45.449 DEBUG 28550 --- [ JWorkers-3] o.s.a.r.t.RabbitTransactionManager : Initiating transaction commit
2017-04-24 15:48:45.449 DEBUG 28550 --- [ JWorkers-8] o.s.a.r.t.RabbitTransactionManager : Initiating transaction commit
2017-04-24 15:48:45.449 DEBUG 28550 --- [ JWorkers-5] o.s.a.r.t.RabbitTransactionManager : Initiating transaction commit
2017-04-24 15:48:45.450 DEBUG 28550 --- [ JWorkers-4] o.s.a.r.connection.RabbitResourceHolder : Skipping close of consumer channel: Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,4), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]
2017-04-24 15:48:45.450 DEBUG 28550 --- [ JWorkers-7] o.s.a.r.connection.RabbitResourceHolder : Skipping close of consumer channel: Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,7), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]
2017-04-24 15:48:45.450 DEBUG 28550 --- [ JWorkers-4] o.s.a.r.t.RabbitTransactionManager : Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2017-04-24 15:48:45.450 DEBUG 28550 --- [ JWorkers-2] o.s.a.r.connection.RabbitResourceHolder : Skipping close of consumer channel: Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,2), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]
2017-04-24 15:48:45.450 DEBUG 28550 --- [ JWorkers-8] o.s.a.r.connection.RabbitResourceHolder : Skipping close of consumer channel: Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,9), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]
2017-04-24 15:48:45.450 DEBUG 28550 --- [ JWorkers-7] o.s.a.r.t.RabbitTransactionManager : Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2017-04-24 15:48:45.450 DEBUG 28550 --- [ JWorkers-4] o.s.a.r.t.RabbitTransactionManager : Created AMQP transaction on channel [Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,4), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]]
2017-04-24 15:48:45.450 DEBUG 28550 --- [ JWorkers-1] o.s.a.r.connection.RabbitResourceHolder : Skipping close of consumer channel: Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,8), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]
2017-04-24 15:48:45.450 DEBUG 28550 --- [ JWorkers-2] o.s.a.r.t.RabbitTransactionManager : Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2017-04-24 15:48:45.450 DEBUG 28550 --- [ JWorkers-6] o.s.a.r.connection.RabbitResourceHolder : Skipping close of consumer channel: Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,6), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]
2017-04-24 15:48:45.450 DEBUG 28550 --- [ JWorkers-3] o.s.a.r.connection.RabbitResourceHolder : Skipping close of consumer channel: Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,3), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]
2017-04-24 15:48:45.450 DEBUG 28550 --- [ JWorkers-5] o.s.a.r.connection.RabbitResourceHolder : Skipping close of consumer channel: Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,5), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-8] o.s.a.r.t.RabbitTransactionManager : Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-7] o.s.a.r.t.RabbitTransactionManager : Created AMQP transaction on channel [Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,7), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]]
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-4] o.s.a.r.listener.BlockingQueueConsumer : Retrieving delivery for Consumer: tags=[{amq.ctag-WNpoLguXQUuqvsfU0XWgbg=accepted-queue}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,4), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106], acknowledgeMode=AUTO local queue size=0
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-1] o.s.a.r.t.RabbitTransactionManager : Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-2] o.s.a.r.t.RabbitTransactionManager : Created AMQP transaction on channel [Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,2), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]]
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-6] o.s.a.r.t.RabbitTransactionManager : Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-3] o.s.a.r.t.RabbitTransactionManager : Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-5] o.s.a.r.t.RabbitTransactionManager : Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-8] o.s.a.r.t.RabbitTransactionManager : Created AMQP transaction on channel [Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,9), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]lhost:5672/vh, localPort= 40106]]
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-7] o.s.a.r.listener.BlockingQueueConsumer : Retrieving delivery for Consumer: tags=[{amq.ctag-4-uSG6VKO__RhZW7e1Eqhg=queue-wait}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,7), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106], acknowledgeMode=AUTO local queue size=0
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-1] o.s.a.r.t.RabbitTransactionManager : Created AMQP transaction on channel [Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,8), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]]
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-2] o.s.a.r.listener.BlockingQueueConsumer : Retrieving delivery for Consumer: tags=[{amq.ctag-gNKSZWts2YmsHyIflgFBRw=exceptions-queue}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,2), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106], acknowledgeMode=AUTO local queue size=0
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-6] o.s.a.r.t.RabbitTransactionManager : Created AMQP transaction on channel [Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,6), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]]
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-3] o.s.a.r.t.RabbitTransactionManager : Created AMQP transaction on channel [Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,3), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]]
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-7] o.s.a.r.listener.BlockingQueueConsumer : Retrieving delivery for Consumer: tags=[{amq.ctag-4-uSG6VKO__RhZW7e1Eqhg=queue-wait}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,7), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106], acknowledgeMode=AUTO local queue size=0
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-1] o.s.a.r.t.RabbitTransactionManager : Created AMQP transaction on channel [Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,8), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]]
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-2] o.s.a.r.listener.BlockingQueueConsumer : Retrieving delivery for Consumer: tags=[{amq.ctag-gNKSZWts2YmsHyIflgFBRw=exceptions-queue}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,2), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106], acknowledgeMode=AUTO local queue size=0
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-6] o.s.a.r.t.RabbitTransactionManager : Created AMQP transaction on channel [Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,6), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]]
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-3] o.s.a.r.t.RabbitTransactionManager : Created AMQP transaction on channel [Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,3), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]]
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-5] o.s.a.r.t.RabbitTransactionManager : Created AMQP transaction on channel [Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,5), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106]]
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-8] o.s.a.r.listener.BlockingQueueConsumer : Retrieving delivery for Consumer: tags=[{amq.ctag-uAZX6E7qZilTn7YVzc9Gfw=cr-queue}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,9), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106], acknowledgeMode=AUTO local queue size=0
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-1] o.s.a.r.listener.BlockingQueueConsumer : Retrieving delivery for Consumer: tags=[{amq.ctag--wz2ymgmywlECrSmcXvAhg=cr-queue}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,8), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106], acknowledgeMode=AUTO local queue size=0
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-6] o.s.a.r.listener.BlockingQueueConsumer : Retrieving delivery for Consumer: tags=[{amq.ctag-mWHmcoeXhWAd_z89yBQ22A=queue-wait}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,6), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]lhost:5672/vh, localPort= 40106], acknowledgeMode=AUTO local queue size=0
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-3] o.s.a.r.listener.BlockingQueueConsumer : Retrieving delivery for Consumer: tags=[{amq.ctag-U2_lfDwU_B3WS_2epRAspw=exceptions-queue}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,3), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106], acknowledgeMode=AUTO local queue size=0
2017-04-24 15:48:45.451 DEBUG 28550 --- [ JWorkers-5] o.s.a.r.listener.BlockingQueueConsumer : Retrieving delivery for Consumer: tags=[{amq.ctag-0wfRlvj-gh96FFeDqNhCzQ=accepted-queue}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/vh,5), conn: [email protected] Shared Rabbit Connection: [email protected] [delegate=amqp://[email protected]:5672/vh, localPort= 40106], acknowledgeMode=AUTO local queue size=0
2017-04-24 15:48:46.451 DEBUG 28550 --- [ JWorkers-4] o.s.a.r.t.RabbitTransactionManager : Initiating transaction commit
2017-04-24 15:48:46.451 DEBUG 28550 --- [ JWorkers-7] o.s.a.r.t.RabbitTransactionManager : Initiating transaction commit
2017-04-24 15:48:46.451 DEBUG 28550 --- [ JWorkers-2] o.s.a.r.t.RabbitTransactionManager : Initiating transaction commit
我的配置:
@Autowired
private CachingConnectionFactory cachingConnectionFactory;
/**
* To configure @RabbitListener
*
* @return
*/
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConcurrentTaskScheduler taskScheduler) {
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
factory.setTaskExecutor(taskScheduler); // When commenting this everything is fine
factory.setConnectionFactory(cachingConnectionFactory);
factory.setMessageConverter(jsonMessageConverter());
factory.setConcurrentConsumers(2);
factory.setMaxConcurrentConsumers(6);
factory.setTransactionManager(rabbitTransactionManager());
// use a non-transactional template for the DLQ
RabbitTemplate dlqTemplate = new RabbitTemplate(this.cachingConnectionFactory);
// When retries reach the maximum number that massage is dead-lettered to exceptions-exchange
Interceptor retryInterceptor = RetryInterceptorBuilder.stateless()
.maxAttempts(5)
.recoverer(new RepublishMessageRecoverer(dlqTemplate, DLQueue.EXCEPTION_EXCHANGE))
.build();
factory.setAdviceChain(retryInterceptor);
return factory;
}
public RabbitTransactionManager rabbitTransactionManager() {
return new RabbitTransactionManager(cachingConnectionFactory);
}
在Tomcat 8.0
這些都是調試日誌,有助於確定RabbitMQ的問題,如果有任何故障或您想了解配置的詳細信息....這通常被用來向人們證明,該監聽線程是停留在他們的代碼 - 如果您沒有看到這些日誌,那麼就有錯誤。將日誌設置更改爲INFO或WARN或ERROR。 – VelNaga
我遇到了一個我認爲與您的問題類似的問題。你能獲得更多信息嗎? – derickson82
@ derickson82檢查彈簧配置並打開spring的調試程序,您可能會發現該問題與RabbitMq無關。 GL – Aalkhodiry