@Test @SneakyThrows public void process() { Thread.sleep(1 * 1000); Executors.newSingleThreadScheduledExecutor() .scheduleAtFixedRate( this::send, 0, 3, TimeUnit.SECONDS); Thread.sleep(12 * 1000); }
@RabbitListener( bindings = @QueueBinding( exchange = @Exchange(value = RabbitMQConstant.DIRECT_EXCHANGE, type = ExchangeTypes.TOPIC, durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT), value = @Queue(value = RabbitMQConstant.DIRECT_QUEUE, durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT), key = RabbitMQConstant.DIRECT_KEY ), containerFactory = "directRabbitListenerContainerFactory" ) public void process(ExampleEvent event) { log.info("direct container receive message:{} ", event); }
DirectConsumer { @RabbitListener( bindings = @QueueBinding( exchange = @Exchange(value = RabbitMQConstant.DIRECT_EXCHANGE, type = ExchangeTypes.TOPIC, durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT), value = @Queue(value = RabbitMQConstant.DIRECT_QUEUE, durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT), key = RabbitMQConstant.DIRECT_KEY ), containerFactory = "directRabbitListenerContainerFactory" ) public void process(ExampleEvent event) { log.info("direct container receive message:{} ", event); } }
DirectConsumer { @RabbitListener( bindings = @QueueBinding( exchange = @Exchange(value = RabbitMQConstant.DIRECT_EXCHANGE, type = ExchangeTypes.TOPIC, durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT), value = @Queue(value = RabbitMQConstant.DIRECT_QUEUE, durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT), key = RabbitMQConstant.DIRECT_KEY ), containerFactory = "directRabbitListenerContainerFactory" ) public void process(ExampleEvent event) { log.info("direct container receive message:{} ", event); }  }
DirectConsumer { @RabbitListener( bindings = @QueueBinding( exchange = @Exchange(value = RabbitMQConstant.DIRECT_EXCHANGE, type = ExchangeTypes.TOPIC, durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT), value = @Queue(value = RabbitMQConstant.DIRECT_QUEUE, durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT), key = RabbitMQConstant.DIRECT_KEY ), containerFactory = "directRabbitListenerContainerFactory" ) public void process(ExampleEvent event) { log.info("direct container receive message:{} ", event); }  @RabbitListener( bindings = @QueueBinding( exchange = @Exchange(value = RabbitMQConstant.DIRECT_EXCHANGE, type = ExchangeTypes.TOPIC, durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT), value = @Queue(value = RabbitMQConstant.DIRECT_QUEUE, durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT), key = RabbitMQConstant.DIRECT_KEY ), containerFactory = "directRabbitListenerContainerFactory" ) void process(ExampleEvent event); }
DirectConsumer { @RabbitListener( bindings = @QueueBinding( exchange = @Exchange(value = RabbitMQConstant.DIRECT_EXCHANGE, type = ExchangeTypes.TOPIC, durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT), value = @Queue(value = RabbitMQConstant.DIRECT_QUEUE, durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT), key = RabbitMQConstant.DIRECT_KEY ), containerFactory = "directRabbitListenerContainerFactory" ) public void process(ExampleEvent event) { log.info("direct container receive message:{} ", event); }  @RabbitListener( bindings = @QueueBinding( exchange = @Exchange(value = RabbitMQConstant.DIRECT_EXCHANGE, type = ExchangeTypes.TOPIC, durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT), value = @Queue(value = RabbitMQConstant.DIRECT_QUEUE, durable = RabbitMQConstant.FALSE_CONSTANT, autoDelete = RabbitMQConstant.TURE_CONSTANT), key = RabbitMQConstant.DIRECT_KEY ), containerFactory = "directRabbitListenerContainerFactory" ) void process(ExampleEvent event);  }