private synchronized void removeBinding(final SimpleString clusterName) throws Exception { RemoteQueueBinding binding = bindings.remove(clusterName); if (binding == null) { throw new IllegalStateException("Cannot find binding for queue " + clusterName); } postOffice.removeBinding(binding.getUniqueName(), null); }
private synchronized void doConsumerCreated(final ClientMessage message) throws Exception { if (HornetQServerLogger.LOGGER.isTraceEnabled()) { HornetQServerLogger.LOGGER.trace( ClusterConnectionImpl.this + " Consumer created " + message); } if (!message.containsProperty(ManagementHelper.HDR_DISTANCE)) { throw new IllegalStateException("distance is null"); } if (!message.containsProperty(ManagementHelper.HDR_CLUSTER_NAME)) { throw new IllegalStateException("clusterName is null"); } Integer distance = message.getIntProperty(ManagementHelper.HDR_DISTANCE); SimpleString clusterName = message.getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME); message.putIntProperty(ManagementHelper.HDR_DISTANCE, distance + 1); SimpleString filterString = message.getSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING); RemoteQueueBinding binding = bindings.get(clusterName); if (binding == null) { throw new IllegalStateException( "Cannot find binding for " + clusterName + " on " + ClusterConnectionImpl.this); } binding.addConsumer(filterString); // Need to propagate the consumer add TypedProperties props = new TypedProperties(); props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress()); props.putSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME, clusterName); props.putSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName()); props.putIntProperty(ManagementHelper.HDR_DISTANCE, distance + 1); Queue theQueue = (Queue) binding.getBindable(); props.putIntProperty(ManagementHelper.HDR_CONSUMER_COUNT, theQueue.getConsumerCount()); if (filterString != null) { props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, filterString); } Notification notification = new Notification(null, CONSUMER_CREATED, props); managementService.sendNotification(notification); }
private synchronized void clearBindings() throws Exception { HornetQServerLogger.LOGGER.debug(ClusterConnectionImpl.this + " clearing bindings"); for (RemoteQueueBinding binding : new HashSet<RemoteQueueBinding>(bindings.values())) { removeBinding(binding.getClusterName()); } }