RabbitMQ #2 持久化
return new Queue("testQueue",true,false,false,map); return new DirectExchange("testExchange",true,false); MessagePostProcessor messagePostProcessor = message -> { message.getMessageProperties().setDeliveryMode(MessageDeliveryMode.PERSISTENT); return message; }; rabbitTemplate.convertAndSend("testExchange","testRoutingKey", msg, messagePostProcessor);
消息似乎默认是持久化的
public static int toInt(MessageDeliveryMode mode) { switch(mode) { case NON_PERSISTENT: return 1; case PERSISTENT: return 2; default: return -1; } }