您的位置:首页 > 产品设计 > UI/UE

rabbitmq-queueDelete

2015-11-30 13:53 716 查看

当客户端channel把消费者和queue绑定,然后channel再把queue删掉时,这个事件是可以监听到的:

  private final String queue = "cancel_notification_queue";

    public void testConsumerCancellationNotification() throws IOException,
            InterruptedException {
        final BlockingQueue<Boolean> result = new ArrayBlockingQueue<Boolean>(1);

        channel.queueDeclare(queue, false, true, false, null);
        Consumer consumer = new QueueingConsumer(channel) {
            @Override
            public void handleCancel(String consumerTag) throws IOException {
                try {
                    result.put(true);
                } catch (InterruptedException e) {
                    fail();
                }
            }
        };
        channel.basicConsume(queue, consumer);
        channel.queueDelete(queue);//删除queue
        assertTrue(result.take());
    }

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: