Skip to content

Commit

Permalink
Issue #318: fix bug in RabbitMQActor that was caused by multiple sour…
Browse files Browse the repository at this point in the history
…ce addresses of which a not-last-one was not existent

Signed-off-by: Florian Fendt <Florian.Fendt@bosch-si.com>
  • Loading branch information
ffendt committed May 17, 2019
1 parent 4c31858 commit 75a612c
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import com.newmotion.akka.rabbitmq.ChannelCreated;
import com.newmotion.akka.rabbitmq.CreateChannel;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.AlreadyClosedException;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.DefaultConsumer;
Expand Down Expand Up @@ -385,6 +386,17 @@ private void ensureQueuesExist(final Channel channel) {
} catch (final IOException e) {
missingQueues.add(address);
log.warning("The queue <{}> does not exist.", address);
} catch (final AlreadyClosedException e) {
if (!missingQueues.isEmpty()) {
// Our client will automatically close the connection if a queue does not exists. This will
// cause an AlreadyClosedException for the following queue (e.g. ['existing1', 'notExisting', -->'existing2'])
// That's why we will ignore this error if the missingQueues list isn't empty.
log.warning("Received exception of type {} when trying to declare queue {}. This happens when a previous " +
"queue was missing and thus the connection got closed.", e.getClass().getName(), address);
} else {
log.error("Exception while declaring queue {}", address, e);
throw e;
}
}
})
);
Expand Down

0 comments on commit 75a612c

Please sign in to comment.