Rabbit给单独的消息设置超时

/**
* 发送消息
* @param user
*/
@RequestMapping(value = prefix+"/setRabbitMessage", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void setMessage(@RequestBody User user) {

rabbitTemplate.convertSendAndReceive(env.getProperty("mq.exchange.order.exchange"), env.getProperty("mq.exchange.order.routing.key"), user, new MessagePostProcessor() {
@Override
public Message postProcessMessage(Message message) throws AmqpException {
MessageProperties properties = message.getMessageProperties();
properties.setDeliveryMode(MessageDeliveryMode.PERSISTENT);
properties.setMessageId(UUID.randomUUID()+"");
return message;
}
});
posted @ 2019-07-12 10:28  雷神约  阅读(306)  评论(0编辑  收藏  举报