最近在读Spring的官方文档,在此记录下自己做的小实验。
这里主要是在生产者中声明和添加:
@Bean
Queue queue(){
Queue queue = new Queue(queueName, false);
queue.addArgument("x-message-ttl" , 30 * 1000);
return queue;
}
@Bean
TopicExchange exchange(){
return new TopicExchange(topicExchangeName);
}
@Bean
Binding binding(Queue queue, TopicExchange exchange){
return BindingBuilder.bind(queue).to(exchange).with("Hello.*");
}
使用Rabbitmq管理工具可以看到起有个TTL的小特征