/** Subscriptions for these destinations are always created */ @Override protected void setupStaticDestinations() { super.setupStaticDestinations(); ActiveMQDestination[] dests = configuration.isDynamicOnly() ? null : durableDestinations; if (dests != null) { for (ActiveMQDestination dest : dests) { if (isPermissableDestination(dest) && !doesConsumerExist(dest)) { try { // Filtering by non-empty subscriptions, see AMQ-5875 if (dest.isTopic()) { RegionBroker regionBroker = (RegionBroker) brokerService.getRegionBroker(); TopicRegion topicRegion = (TopicRegion) regionBroker.getTopicRegion(); String candidateSubName = getSubscriberName(dest); for (Subscription subscription : topicRegion.getDurableSubscriptions().values()) { String subName = subscription.getConsumerInfo().getSubscriptionName(); if (subName != null && subName.equals(candidateSubName)) { DemandSubscription sub = createDemandSubscription(dest, subName); sub.getLocalInfo().setSubscriptionName(getSubscriberName(dest)); sub.setStaticallyIncluded(true); addSubscription(sub); break; } } } } catch (IOException e) { LOG.error("Failed to add static destination {}", dest, e); } LOG.trace("Forwarding messages for durable destination: {}", dest); } else if (configuration.isSyncDurableSubs() && !isPermissableDestination(dest)) { if (dest.isTopic()) { RegionBroker regionBroker = (RegionBroker) brokerService.getRegionBroker(); TopicRegion topicRegion = (TopicRegion) regionBroker.getTopicRegion(); String candidateSubName = getSubscriberName(dest); for (Subscription subscription : topicRegion.getDurableSubscriptions().values()) { String subName = subscription.getConsumerInfo().getSubscriptionName(); if (subName != null && subName.equals(candidateSubName)) { try { // remove the NC subscription as it is no longer for a permissable dest RemoveSubscriptionInfo sending = new RemoveSubscriptionInfo(); sending.setClientId(localClientId); sending.setSubscriptionName(subName); sending.setConnectionId(this.localConnectionInfo.getConnectionId()); localBroker.oneway(sending); } catch (IOException e) { LOG.debug("Exception removing NC durable subscription: {}", subName, e); serviceRemoteException(e); } break; } } } } } } }
@Override protected void populateObject(Object object) throws Exception { super.populateObject(object); RemoveSubscriptionInfo info = (RemoveSubscriptionInfo) object; info.setConnectionId(createConnectionId("ConnectionId:1")); info.setSubcriptionName("SubcriptionName:2"); info.setClientId("ClientId:3"); }