//If the delivery was obtained via a connection consumer we need to cancel via that
//otherwise we just use this session
SessionDelegate sessionToUse = connectionConsumerSession != null ? connectionConsumerSession : sess;
sessionToUse.cancelDelivery(new DefaultCancel(delivery.getDeliveryID(),
delivery.getMessageProxy().getDeliveryCount(), false, false));
}
}