{
boolean stateChanged = running.compareAndSet(false, true);
if (!stateChanged)
- throw new RuntimeException("Consumer instance " + id + " is already running!");
+ throw new IllegalStateException("Consumer instance " + id + " is already running!");
log.info("{} - Starting - consumed {} messages before", id, consumed);
future = executor.submit(this);
{
boolean stateChanged = running.compareAndSet(true, false);
if (!stateChanged)
- throw new RuntimeException("Consumer instance " + id + " is not running!");
+ throw new IllegalStateException("Consumer instance " + id + " is not running!");
log.info("{} - Stopping", id);
consumer.wakeup();
{
log.info("{} - Was already stopped", id);
}
+ catch (Exception e)
+ {
+ log.error("{} - Unexpected exception while trying to stop the consumer", id, e);
+ }
finally
{
log.info("{}: Consumed {} messages in total, exiting!", id, consumed);