// Recover the durable subscription.
String clientId = subscription.getSubscriptionKey().getClientId();
String subscriptionName = subscription.getSubscriptionKey().getSubscriptionName();
String selector = subscription.getConsumerInfo().getSelector();
SubscriptionInfo info = topicStore.lookupSubscription(clientId, subscriptionName);
if (info != null) {
// Check to see if selector changed.
String s1 = info.getSelector();
if (s1 == null ^ selector == null || (s1 != null && !s1.equals(selector))) {
// Need to delete the subscription
topicStore.deleteSubscription(clientId, subscriptionName);
info = null;
} else {
synchronized (consumers) {
consumers.add(subscription);
}
}
}
// Do we need to create the subscription?
if (info == null) {
info = new SubscriptionInfo();
info.setClientId(clientId);
info.setSelector(selector);
info.setSubscriptionName(subscriptionName);
info.setDestination(getActiveMQDestination());
// This destination is an actual destination id.
info.setSubscribedDestination(subscription.getConsumerInfo().getDestination());
// This destination might be a pattern
synchronized (consumers) {
consumers.add(subscription);
topicStore.addSubsciption(info, subscription.getConsumerInfo().isRetroactive());
}