Skip to content

Commit

Permalink
hardened amqp consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
johannbarbie committed Aug 12, 2014
1 parent 1cda3b7 commit f78c26d
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -41,9 +41,11 @@ public void run() {
while (isActive){
Connection connection = null;
QueueingConsumer consumer = null;
Channel channel = null;
try {
factory.setAutomaticRecoveryEnabled(true);
connection = factory.newConnection();
Channel channel = connection.createChannel();
channel = connection.createChannel();
consumer = new QueueingConsumer(channel);
channel.basicConsume(queueName, true, consumer);
} catch (IOException e) {
Expand Down Expand Up @@ -76,12 +78,15 @@ public void run() {
}else{
System.out.println("undigested message: "+om.writeValueAsString(e));
}
} catch (ShutdownSignalException | ConsumerCancelledException| InterruptedException | IOException e) {
} catch (ShutdownSignalException | ConsumerCancelledException| IOException e) {
e.printStackTrace();
} catch (InterruptedException e2){
e2.printStackTrace();
isActive = false;
} finally{
if (null!=connection){
try {
channel.close();
connection.close();
} catch (IOException e) {
}
Expand Down

0 comments on commit f78c26d

Please sign in to comment.