[rabbitmq-discuss] How to code the handleCancel call back service in an event of the consumer cancel notification occur

cw storm cwstorm at gmail.com
Mon Feb 10 15:12:57 GMT 2014


I'm having trouble understanding how to properly code the "handleCancel"
call back service in case of an event of a consumer cancel notification
occurs.  I'm using Java client.  First, I have a service that invokes the
structure below.  I have several services that invokes the below service
based on how many queues I have setup on the broker.  In my understanding,
the "handleCancel" service will be invoke when the master node fails.  I'm
trying to understand what I need to code in the "handleCancel" service.  In
the "handleCancel" service, I only have the "consumerTag" information.  How
will I know the queue that it's associated with so that I can pass this
information to the invoking service that'll "re-subscribe" to the queue.

try {

        ConnectionFactory factory = new ConnectionFactory();
factory.setUri(strFactoryURI);
Connection conn = factory.newConnection();
Channel channel = conn.createChannel();

channel.queueDeclare(strQueueName, true, false, false, null);



                //Callback to handle unexpected issue with the Broker

                Consumer consumer = new QueueingConsumer(channel)

                {

                    @Override public void handleCancel(String consumerTag)
throws IOException

                    {

                        // how to handle unexpected cancellation from broker

                    }

                };



                // Dispatch the message

                channel.basicConsume(strQueueName, false,

                                new DefaultConsumer(channel) {

                                                @Override public void
handleDelivery(String consumerTag,


Envelope envelope,


AMQP.BasicProperties props,


byte[] body)

                                                throws IOException

                                                {    // execute code to
invoke service on 1.0 to persiste the message }

                                });


}


thanks,

Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140210/29c8891a/attachment.html>


More information about the rabbitmq-discuss mailing list