Man*_*ark 2 rabbitmq spring-amqp
使用SpringBoot。
我创建了一个 TopicExchange,它接受消息并根据消息中存在的routingKey 将它们定向到两个队列。
消息通过以下方式发送:
rabbitTemplate.convertAndSend('in-out-topic', 'inbound.queue.route.key', payload)
Run Code Online (Sandbox Code Playgroud)
收到消息:
@RabbitListener(queues = "inbound-queue")
def onInboundMessage(def message) {
try {
log.debug("Received inbound message: ${message.messageId} on inbound queue listener", message)
} catch (Exception ex) {
log.error("Inbound message exception: ${ex.getMessage()}")
return;
}
return message.payload
}
Run Code Online (Sandbox Code Playgroud)
但是当我的侦听器(消费者)收到消息时,我收到以下异常:
org.springframework.amqp.AmqpException: Cannot determine ReplyTo message property value: Request message does not contain reply-to property, and no default response Exchange was set.
Run Code Online (Sandbox Code Playgroud)
我只是希望消息在被消息侦听器使用时从相应的队列中删除。
Your problem is in the end of method, here:
\n\nreturn message.payload\nRun Code Online (Sandbox Code Playgroud)\n\n如果您确实不打算发送回复,并且我们确实通过预期看到了这一点convertAndSend(),那么您不应该\xe2\x80\x99t 从@RabbitListener。否则,正如您所经历的那样,此类方法的返回将被视为尝试发送回复。
请参阅参考手册中的更多信息:https://docs.spring.io/spring-amqp/docs/2.0.3.RELEASE/reference/html/_reference.html#async-annotation-driven。注意Reply Management paragraph.
| 归档时间: |
|
| 查看次数: |
3836 次 |
| 最近记录: |