private synchronized void disconnectBinding(final SimpleString clusterName) throws Exception { RemoteQueueBinding binding = bindings.get(clusterName); if (binding == null) { throw new IllegalStateException("Cannot find binding for queue " + clusterName); } binding.disconnect(); }
private synchronized void clearDisconnectedBindings() throws Exception { logger.debug(ClusterConnectionImpl.this + " reset bindings"); for (RemoteQueueBinding binding : new HashSet<>(bindings.values())) { if (!binding.isConnected()) { removeBinding(binding.getClusterName()); } } }
binding.addConsumer(filterString); props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress()); props.putSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName()); Queue theQueue = (Queue) binding.getBindable();
binding.removeConsumer(filterString); props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress()); props.putSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName()); Queue theQueue = (Queue) binding.getBindable();
if (oldQueueID == remoteQueueBinding.getRemoteQueueID()) { SimpleString oldQueueName = remoteQueueBinding.getRoutingName(); String temp = remoteQueueBinding.getQueue().getName().toString(); targetNodeID = temp.substring(temp.lastIndexOf(".") + 1); logger.debug("Message formerly destined for " + oldQueueName + " with ID: " + oldQueueID + " on address " + copyMessage.getAddressSimpleString() + " on node " + targetNodeID); temp = remoteQueueBinding.getQueue().getName().toString(); targetNodeID = temp.substring(temp.lastIndexOf(".") + 1); if (oldQueueName.equals(remoteQueueBinding.getRoutingName()) && targetNodeID.equals(queueSuffix.toString())) { targetBinding = remoteQueueBinding; if (logger.isDebugEnabled()) { logger.debug("Message now destined for " + remoteQueueBinding.getRoutingName() + " with ID: " + remoteQueueBinding.getRemoteQueueID() + " on address " + copyMessage.getAddress() + " on node " + targetNodeID);
if (!existingBinding.isConnected()) { existingBinding.connect(); return;
if (entry.getValue() instanceof RemoteQueueBinding) { RemoteQueueBinding remoteQueueBinding = (RemoteQueueBinding) entry.getValue(); if (remoteQueueBinding.getRemoteQueueID() == id) { message.putExtraBytesProperty(Message.HDR_ROUTE_TO_IDS, ByteBuffer.allocate(8).putLong(remoteQueueBinding.getID()).array());
private synchronized void clearBindings() throws Exception { logger.debug(ClusterConnectionImpl.this + " clearing bindings"); for (RemoteQueueBinding binding : new HashSet<>(bindings.values())) { removeBinding(binding.getClusterName()); } }
private void closeConsumerAndConnectionConcurrently(int targetNode, int remoteNode) throws Exception { String targetUri = getServerUri(targetNode); System.out.println("uri is " + targetUri); ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(targetUri); Connection conn = null; CountDownLatch active = new CountDownLatch(1); try { conn = factory.createConnection(); conn.start(); Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination dest = ActiveMQDestination.createDestination("queue0", ActiveMQDestination.QUEUE_TYPE); ConsumerThread consumer = new ConsumerThread(session, dest); consumer.setMessageCount(0); consumer.setFinished(active); consumer.start(); assertTrue("consumer takes too long to finish!", active.await(5, TimeUnit.SECONDS)); } finally { conn.close(); } Wait.waitFor(() -> getRemoteQueueBinding(servers[remoteNode]) != null); //check remote server's consumer count RemoteQueueBinding remoteBinding = getRemoteQueueBinding(servers[remoteNode]); assertNotNull(remoteBinding); Wait.waitFor(() -> remoteBinding.consumerCount() >= 0); int count = remoteBinding.consumerCount(); assertTrue("consumer count should never be negative " + count, count >= 0); }
private synchronized void resetBindings() throws Exception { logger.debug(ClusterConnectionImpl.this + " reset bindings"); for (RemoteQueueBinding binding : new HashSet<>(bindings.values())) { resetBinding(binding.getClusterName()); } }
@Override public synchronized void disconnectBindings() throws Exception { logger.debug(ClusterConnectionImpl.this + " disconnect bindings"); reset = false; for (RemoteQueueBinding binding : new HashSet<>(bindings.values())) { disconnectBinding(binding.getClusterName()); } }