connection.getConnectionId(), subscriptions.size());
}
} else {
// just abort each consumer
for (Subscription subscription : subscriptions) {
final Subscription subToClose = subscription;
LOG.info("aborting slow consumer: {} for destination:{}",
subscription.getConsumerInfo().getConsumerId(),
subscription.getActiveMQDestination());
// tell the remote consumer to close
try {
ConsumerControl stopConsumer = new ConsumerControl();
stopConsumer.setConsumerId(subscription.getConsumerInfo().getConsumerId());
stopConsumer.setClose(true);
connection.dispatchAsync(stopConsumer);
} catch (Exception e) {
LOG.info("exception on aborting slow consumer: {}", subscription.getConsumerInfo().getConsumerId(), e);
}
// force a local remove in case remote is unresponsive
try {
scheduler.executeAfterDelay(new Runnable() {
@Override
public void run() {
try {
RemoveInfo removeCommand = subToClose.getConsumerInfo().createRemoveCommand();
if (connection instanceof CommandVisitor) {
// avoid service exception handling and logging
removeCommand.visit((CommandVisitor) connection);
} else {
connection.service(removeCommand);
}
} catch (IllegalStateException ignoredAsRemoteHasDoneTheJob) {
} catch (Exception e) {
LOG.info("exception on local remove of slow consumer: {}", subToClose.getConsumerInfo().getConsumerId(), e);
}
}}, 1000l);
} catch (Exception e) {
LOG.info("exception on local remove of slow consumer: {}", subscription.getConsumerInfo().getConsumerId(), e);