2017-04-25 82 views
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

+0

这些都是调试日志,有助于确定RabbitMQ的问题,如果有任何故障或您想了解配置的详细信息....这通常被用来向人们证明,该监听线程是停留在他们的代码 - 如果您没有看到这些日志,那么就有错误。将日志设置更改为INFO或WARN或ERROR。 – VelNaga

+0

我遇到了一个我认为与您的问题类似的问题。你能获得更多信息吗? – derickson82

+0

@ derickson82检查弹簧配置并打开spring的调试程序,您可能会发现该问题与RabbitMq无关。 GL – Aalkhodiry

回答

0

运行这个春天引导1.4.1.RELEASE延迟的应用程序启动超过300+

由于您只显示2毫秒的日志,并且它们都不与容器启动有关,所以很难说。

使用外部任务执行不应该有任何区别,只要它可以提供足够的线程来满足容器的并发(除了其他任何使用执行人)。出现此行为

编辑你的问题,显示的确切配置(包括容器和执行人)。