我们正在尝试使用Spring AMQP在RabbitMQ中进行异步调用,有没有人可以告诉我如何使用spring amqp配置replyqueue,correlationId,(properties)?
String corrId = java.util.UUID.randomUUID().toString();
BasicProperties props = new BasicProperties
.Builder()
.correlationId(corrId)
.replyTo(replyQueueName)
.build();
channel.basicPublish("", requestQueueName, props, message.getBytes());
答案 0 :(得分:1)
我假设你需要使用RabbitTemplate
:
rabbitTemplate.convertAndSend(requestQueueName, myObj, new MessagePostProcessor() {
Message postProcessMessage(Message message) throws AmqpException {
message.getMessageProperties().setReplyTo(replyQueueName);
return message;
}
}, new CorrelationData(corrId));
HTH