String destinationName = (String) headers.get(Stomp.Headers.Unsubscribe.DESTINATION);
String subscriptionId = (String) headers.get(Stomp.Headers.Unsubscribe.ID);
if (subscriptionId == null) {
if (destinationName == null) {
throw new ProtocolException("Must specify the subscriptionId or the destination you are unsubscribing from");
}
subscriptionId = createSubscriptionId(headers);
}
StompSubscription subscription = (StompSubscription) subscriptions.remove(subscriptionId);
if (subscription == null) {
throw new ProtocolException("Cannot unsubscribe as mo subscription exists for id: " + subscriptionId);
}
subscription.close();
sendResponse(command);
}