Java Code Examples for org.apache.activemq.artemis.api.core.client.ClientMessage#containsProperty()

The following examples show how to use org.apache.activemq.artemis.api.core.client.ClientMessage#containsProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClusterConnectionImpl.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void onMessage(final ClientMessage message) {
   if (logger.isDebugEnabled()) {
      logger.debug("ClusterCommunication::Flow record on " + clusterConnector + " Receiving message " + message);
   }
   try {
      // Reset the bindings
      if (message.containsProperty(PostOfficeImpl.HDR_RESET_QUEUE_DATA)) {
         reset = true;

         return;
      } else if (message.containsProperty(PostOfficeImpl.HDR_RESET_QUEUE_DATA_COMPLETE)) {
         clearDisconnectedBindings();
         return;
      }

      if (!reset) {
         logger.debug("Notification being ignored since first reset wasn't received yet: " + message);
         return;
      }

      handleNotificationMessage(message);
   } catch (Exception e) {
      ActiveMQServerLogger.LOGGER.errorHandlingMessage(e);
   }
}
 
Example 2
Source File: ClusterConnectionImpl.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private synchronized void doProposalReceived(final ClientMessage message) throws Exception {
   if (!message.containsProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID)) {
      throw new IllegalStateException("proposal type is null");
   }

   SimpleString type = message.getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID);

   SimpleString val = message.getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE);

   Integer hops = message.getIntProperty(ManagementHelper.HDR_DISTANCE);

   if (server.getGroupingHandler() == null) {
      throw new IllegalStateException("grouping handler is null");
   }

   Response response = server.getGroupingHandler().receive(new Proposal(type, val), hops + 1);

   if (response != null) {
      server.getGroupingHandler().sendProposalResponse(response, 0);
   }
}
 
Example 3
Source File: ClusterConnectionImpl.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private synchronized void doProposalResponseReceived(final ClientMessage message) throws Exception {
   if (!message.containsProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID)) {
      throw new IllegalStateException("proposal type is null");
   }

   SimpleString type = message.getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID);
   SimpleString val = message.getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE);
   SimpleString alt = message.getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_ALT_VALUE);
   Integer hops = message.getIntProperty(ManagementHelper.HDR_DISTANCE);
   Response response = new Response(type, val, alt);

   if (server.getGroupingHandler() == null) {
      throw new IllegalStateException("grouping handler is null while sending response " + response);
   }

   server.getGroupingHandler().proposed(response);
   server.getGroupingHandler().sendProposalResponse(response, hops + 1);
}
 
Example 4
Source File: ClusterConnectionImpl.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void doBindingRemoved(final ClientMessage message) throws Exception {
   if (logger.isTraceEnabled()) {
      logger.trace(ClusterConnectionImpl.this + " Removing binding " + message);
   }
   if (!message.containsProperty(ManagementHelper.HDR_CLUSTER_NAME)) {
      throw new IllegalStateException("clusterName is null");
   }

   SimpleString clusterName = message.getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME);

   removeBinding(clusterName);
}
 
Example 5
Source File: ClusterConnectionImpl.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
private synchronized void doUnProposalReceived(final ClientMessage message) throws Exception {
   if (!message.containsProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID)) {
      throw new IllegalStateException("proposal type is null");
   }

   SimpleString groupId = message.getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID);

   SimpleString clusterName = message.getSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE);

   Integer hops = message.getIntProperty(ManagementHelper.HDR_DISTANCE);

   if (server.getGroupingHandler() == null) {
      throw new IllegalStateException("grouping handler is null");
   }

   server.getGroupingHandler().remove(groupId, clusterName, hops + 1);

}
 
Example 6
Source File: ClusterConnectionImpl.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
private synchronized void doBindingAdded(final ClientMessage message) throws Exception {
   if (logger.isTraceEnabled()) {
      logger.trace(ClusterConnectionImpl.this + " Adding binding " + message);
   }
   if (!message.containsProperty(ManagementHelper.HDR_DISTANCE)) {
      throw new IllegalStateException("distance is null");
   }

   if (!message.containsProperty(ManagementHelper.HDR_ADDRESS)) {
      throw new IllegalStateException("queueAddress is null");
   }

   if (!message.containsProperty(ManagementHelper.HDR_CLUSTER_NAME)) {
      throw new IllegalStateException("clusterName is null");
   }

   if (!message.containsProperty(ManagementHelper.HDR_ROUTING_NAME)) {
      throw new IllegalStateException("routingName is null");
   }

   if (!message.containsProperty(ManagementHelper.HDR_BINDING_ID)) {
      throw new IllegalStateException("queueID is null");
   }

   Integer distance = message.getIntProperty(ManagementHelper.HDR_DISTANCE);

   SimpleString queueAddress = message.getSimpleStringProperty(ManagementHelper.HDR_ADDRESS);

   SimpleString clusterName = message.getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME);

   SimpleString routingName = message.getSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME);

   SimpleString filterString = message.getSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING);

   Long queueID = message.getLongProperty(ManagementHelper.HDR_BINDING_ID);

   RemoteQueueBinding existingBinding = (RemoteQueueBinding) postOffice.getBinding(clusterName);

   if (existingBinding != null) {
      if (!existingBinding.isConnected()) {
         existingBinding.connect();
         return;
      }
      // Sanity check - this means the binding has already been added via another bridge, probably max
      // hops is too high
      // or there are multiple cluster connections for the same address

      ActiveMQServerLogger.LOGGER.remoteQueueAlreadyBoundOnClusterConnection(this, clusterName);

      return;
   }

   RemoteQueueBinding binding = new RemoteQueueBindingImpl(server.getStorageManager().generateID(), queueAddress, clusterName, routingName, queueID, filterString, queue, bridge.getName(), distance + 1, messageLoadBalancingType);

   if (logger.isTraceEnabled()) {
      logger.trace("Adding binding " + clusterName + " into " + ClusterConnectionImpl.this);
   }

   bindings.put(clusterName, binding);

   try {
      postOffice.addBinding(binding);
   } catch (Exception ignore) {
   }

   try {
      postOffice.updateMessageLoadBalancingTypeForAddress(queueAddress, messageLoadBalancingType);
   } catch (Exception e) {
      if (logger.isTraceEnabled()) {
         logger.trace(e.getLocalizedMessage(), e);
      }
   }

}
 
Example 7
Source File: ClusterConnectionImpl.java    From activemq-artemis with Apache License 2.0 2 votes vote down vote up
private synchronized void doConsumerCreated(final ClientMessage message) throws Exception {
   if (logger.isTraceEnabled()) {
      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, CoreNotificationType.CONSUMER_CREATED, props);

   managementService.sendNotification(notification);
}
 
Example 8
Source File: ClusterConnectionImpl.java    From activemq-artemis with Apache License 2.0 2 votes vote down vote up
private synchronized void doConsumerClosed(final ClientMessage message) throws Exception {
   if (logger.isTraceEnabled()) {
      logger.trace(ClusterConnectionImpl.this + " Consumer closed " + 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);
   }

   binding.removeConsumer(filterString);

   // Need to propagate the consumer close
   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, CoreNotificationType.CONSUMER_CLOSED, props);

   managementService.sendNotification(notification);
}