Quantcast

RabbiMQ Pub/Sub recover from lost connection

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RabbiMQ Pub/Sub recover from lost connection

Benet
This post has NOT been accepted by the mailing list yet.
Can someone help me figure out how to recover from lost connection. My consumer does not recover.

ConnectionFactory factory = new ConnectionFactory();
                factory.setHost(ip);
                factory.setUsername("user");
                factory.setPassword("pas");
                factory.setRequestedHeartbeat(10000);
                factory.setConnectionTimeout(10000);
                factory.setAutomaticRecoveryEnabled(true);
                factory.setTopologyRecoveryEnabled(true);
                factory.setNetworkRecoveryInterval(5000);

My connection recovers, also my channel recoveres.

How am I supposed to handle this when the connection sets back in?
And this is the part that I am interested in :


@Override
                public void run() {
                        while (isRunning) {

                                try {
                                        delivery = consumer.nextDelivery();
                                        LogUtil.hecsLog("xxxxx", delivery.getBody().toString());
                                        channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);

                                } catch (ShutdownSignalException | ConsumerCancelledException |                InterruptedException | IOException e) {
                                       
                                        isRunning = false;
                                }
                        }
                }
Loading...