【发布时间】:2019-11-28 13:18:20
【问题描述】:
我们在发送消息的过程中遇到了网络问题,这导致所有线程都处于阻塞状态。我们使用org.springframework.cloud:spring-cloud-stream:2.0.1.RELEASE 和org.springframework:spring-messaging:5.0.8.RELEASE 向RabbitMQ 代理发送消息。绑定接口:
interface MessagingSource {
@Output("bindingTargetName")
fun messageChannelOutput(): MessageChannel
}
用法:
val isSent = messageSource.messageChannelOutput().send(message)
MessageChannel#send(Message, long) 方法的第二个参数也有超时时间(毫秒),但在 org.springframework.integration.channel.AbstractSubscribableChannel#doSend 方法:
@Override
protected boolean doSend(Message<?> message, long timeout) { // timeout is ignored in this method
try {
return getRequiredDispatcher().dispatch(message);
}
catch (MessageDispatchingException e) {
String description = e.getMessage() + " for channel '" + this.getFullChannelName() + "'.";
throw new MessageDeliveryException(message, description, e);
}
}
您能解释一下为什么忽略超时参数以及如何配置它以避免长时间阻塞状态吗?
谢谢!
【问题讨论】:
标签: java rabbitmq spring-integration amqp spring-cloud-stream