在运行RabbitMQ(3.5.3)时,消费者应用程序偶尔会进入挂起状态约30秒至60秒。 (您可以从下面随附的消费者应用日志中看到2018-07-23 15:02:04.898和2018-07-23 15:03:05.891之间没有日志。)
毕竟,来自RabbitMQ的所有消息都是由消费者应用处理的。也就是说,没有MQ邮件被盗或消失。
我不知道此问题的原因。谁能告诉我如何解决此问题?
消费者应用程序使用的是springframework的amqp兔子。
以下是一些消费者应用程序的来源。
$ElementType<Obj, KEY>
应用程序的日志。
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
@Bean
@Qualifier("jobConnectionFactory")
public ConnectionFactory connectionFactory(){
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
connectionFactory.setAddresses(addressesString);
connectionFactory.setUsername(rabbitUser);
connectionFactory.setPassword(rabbitPassword);
connectionFactory.setVirtualHost(rabbitVirtualHost);
connectionFactory.setRequestedHeartBeat(heartbeatSeconds);
connectionFactory.setConnectionTimeout(timeoutSeconds);
return connectionFactory;
}
@Bean
@Qualifier("rabbitReportTemplate")
public RabbitTemplate rabbitTemplate() {
RabbitTemplate template = new RabbitTemplate(connectionFactory());
template.setMessageConverter(new Jackson2JsonMessageConverter());
template.setExchange(AmqpConstants.SIMPLE_JOB_EXCHANGE_NAME);
template.setQueue(AmqpConstants.SIMPLE_JOB_QUEUE_NAME);
return template;
}
@Bean
public SimpleMessageListenerContainer sdpJobListenerContainer() {
SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer();
listenerContainer.setConnectionFactory(connectionFactory);
listenerContainer.setQueues(oidcSdpJobQueue());
listenerContainer.setConcurrentConsumers(10);
listenerContainer.setDefaultRequeueRejected(false);
return listenerContainer;
}
@Bean
public IntegrationFlow sdpJobInboundFlow() {
return IntegrationFlows.from(Amqp.inboundAdapter(sdpJobListenerContainer()))
.transform(Transformers.fromJson(SdpJobCommand.class))
.handle(oidcSdpMessageHandler , c -> c.advice(retryAdvice))
.get();
}