// If this is a consumer of a non durable subscription then we want to unbind the
// subscription and delete all its data.
if (destination.isTopic())
{
PostOffice postOffice = sessionEndpoint.getConnectionEndpoint().getServerPeer().getPostOfficeInstance();
ServerPeer sp = sessionEndpoint.getConnectionEndpoint().getServerPeer();
Binding binding = postOffice.getBindingForQueueName(queueName);
//https://jira.jboss.org/jira/browse/JBMESSAGING-1801
if (binding == null) return;
Queue queue = binding.queue;
ManagedDestination mDest = sp.getDestinationManager().getDestination(destination.getName(), false);
if (!queue.isRecoverable())
{
postOffice.removeBinding(queueName, false);
if (!mDest.isTemporary())
{
String counterName = TopicService.SUBSCRIPTION_MESSAGECOUNTER_PREFIX + queueName;
MessageCounter counter = sp.getMessageCounterManager().unregisterMessageCounter(counterName);
if (counter == null)
{
throw new IllegalStateException("Cannot find counter to remove " + counterName);
}
}
}
else
{
//Durable sub consumer
if (queue.isClustered() && postOffice.isClustered())
{
//Clustered durable sub consumer created - we need to remove this info from the replicator
Replicator rep = (Replicator)postOffice;