我有一个bean来配置SimpleRabbitListenerContainerFactory
但是当我使用factory.setTaskExecutor(taskScheduler);
时,我得到了这个日志,这会延迟应用启动超过300秒。但如果我评论这个 TaskExecutor ,一切正常。
日志:
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://localuser@localhost:5672/vh,4), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,7), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,2), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,9), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,4), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,8), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,6), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,3), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,5), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,7), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,4), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,2), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,9), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,7), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,8), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,2), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,6), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,3), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,7), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,8), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,2), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,6), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,3), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,5), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,9), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,8), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,6), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,3), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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://localuser@localhost:5672/vh,5), conn: Proxy@14aa069c Shared Rabbit Connection: SimpleConnection@4f8c20a2 [delegate=amqp://localuser@localhost: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上运行的Spring Boot 1.4.1.RELEASE
答案 0 :(得分:0)
延迟应用启动超过300 +
由于您只显示2毫秒的日志,而且没有一个与容器启动有关,因此很难说。
使用外部任务执行程序不应该有任何区别,只要它可以提供足够的线程来满足容器的并发性(除了使用执行程序的其他任何东西)。
编辑您的问题以显示出现此行为的确切配置(包括容器和执行程序)。