1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
@Configuration public class DelayQueueRabbitConfig {
public static final String MALL_ORDER_DELAY_QUEUE="mall.order.delay.queue";
public static final String MALL_ORDER_DELAY_EXCHANGE="mall.order.delay.exchange";
public static final String MALL_ORDER_DELAY_ROUTING_KEY="mall.order.delay.routing.key";
@Bean public Queue orderQueue(){ Map<String,Object> params = new HashMap<>(); params.put("x-dead-letter-exchange", DelayQueueDlxRabbitConfig.MALL_ORDER_DLX_EXCHANGE); params.put("x-dead-letter-routing-key", DelayQueueDlxRabbitConfig.MALL_ORDER_DLX_ROUTING_KEY); return new Queue(MALL_ORDER_DELAY_QUEUE, true, false, false, params); }
@Bean public DirectExchange orderExchange(){ return new DirectExchange(MALL_ORDER_DELAY_EXCHANGE,true,false); }
@Bean public Binding orderBinding(){ return BindingBuilder .bind(orderQueue()) .to(orderExchange()) .with(MALL_ORDER_DELAY_ROUTING_KEY); }
}
|