/** * Send the passed message to clients connected to other server peer nodes in the cluster. * If you are using broadcast cluster-messaging-routing mode, the message is broadcast * through the cluster. If you are using the server-to-server mode, the message is sent only * to servers from which we have received a matching subscription request. * * @param message The <code>Message</code> to push to peer server nodes in the cluster. * @param evalSelector <code>true</code> to evaluate each remote subscriber's selector * before pushing the message to them; <code>false</code> to skip selector evaluation. */ public void sendPushMessageFromPeer(Message message, boolean evalSelector) { sendPushMessageFromPeer(message, (MessageDestination)getDestination(message), evalSelector); }
/** * Send the passed message to clients connected to other server peer nodes in the cluster. * If you are using broadcast cluster-messaging-routing mode, the message is broadcast * through the cluster. If you are using the server-to-server mode, the message is sent only * to servers from which we have received a matching subscription request. * * @param message The <code>Message</code> to push to peer server nodes in the cluster. * @param evalSelector <code>true</code> to evaluate each remote subscriber's selector * before pushing the message to them; <code>false</code> to skip selector evaluation. */ public void sendPushMessageFromPeer(Message message, boolean evalSelector) { sendPushMessageFromPeer(message, (MessageDestination)getDestination(message), evalSelector); }
/** * This method is not invoked across a cluster, it is always locally invoked. * The passed message will be pushed to the subscribers in the passed set, conditionally depending * upon the execution of their selector expressions. * * @param subscriberIds The set of subscribers to push the message to. * * @param message The <code>Message</code> to push. * * @param evalSelector <code>true</code> to evaluate each subscriber's selector before pushing * the message to them; <code>false</code> to skip selector evaluation. */ public void pushMessageToClients(Set subscriberIds, Message message, boolean evalSelector) { MessageDestination destination = (MessageDestination)getDestination(message); pushMessageToClients(destination, subscriberIds, message, evalSelector); }
/** * This method is not invoked across a cluster, it is always locally invoked. * The passed message will be pushed to the subscribers in the passed set, conditionally depending * upon the execution of their selector expressions. * * @param subscriberIds The set of subscribers to push the message to. * * @param message The <code>Message</code> to push. * * @param evalSelector <code>true</code> to evaluate each subscriber's selector before pushing * the message to them; <code>false</code> to skip selector evaluation. */ public void pushMessageToClients(Set subscriberIds, Message message, boolean evalSelector) { MessageDestination destination = (MessageDestination)getDestination(message); pushMessageToClients(destination, subscriberIds, message, evalSelector); }
/** * This method is not invoked across a cluster, it is always locally invoked. * The passed message will be pushed to the subscribers in the passed set, conditionally depending * upon the execution of their selector expressions. * * @param subscriberIds The set of subscribers to push the message to. * * @param message The <code>Message</code> to push. * * @param evalSelector <code>true</code> to evaluate each subscriber's selector before pushing * the message to them; <code>false</code> to skip selector evaluation. */ public void pushMessageToClients(Set subscriberIds, Message message, boolean evalSelector) { MessageDestination destination = (MessageDestination)getDestination(message); pushMessageToClients(destination, subscriberIds, message, evalSelector); }
/** * Returns the set of subscribers for the specified destination, subtopic/subtopic pattern * and message headers. The message headers can be null. If specified, they are used * to match against any selector patterns that were used for subscribers. */ public Set getSubscriberIds(String destinationId, String subtopicPattern, Map messageHeaders) { MessageDestination destination = (MessageDestination) getDestination(destinationId); SubscriptionManager subscriptionManager = destination.getSubscriptionManager(); return subscriptionManager.getSubscriberIds(subtopicPattern, messageHeaders); }
/** * Returns the set of subscribers for the specified destination, subtopic/subtopic pattern * and message headers. The message headers can be null. If specified, they are used * to match against any selector patterns that were used for subscribers. * @param destinationId the destination ID * @param subtopicPattern the subtopic pattern * @param messsageHeaders the map of the message headers * @return Set the set of the subscriber's IDs */ public Set getSubscriberIds(String destinationId, String subtopicPattern, Map messageHeaders) { MessageDestination destination = (MessageDestination) getDestination(destinationId); SubscriptionManager subscriptionManager = destination.getSubscriptionManager(); return subscriptionManager.getSubscriberIds(subtopicPattern, messageHeaders); }
/** * Returns the set of subscribers for the specified destination, subtopic/subtopic pattern * and message headers. The message headers can be null. If specified, they are used * to match against any selector patterns that were used for subscribers. * @param destinationId the destination ID * @param subtopicPattern the subtopic pattern * @param messsageHeaders the map of the message headers * @return Set the set of the subscriber's IDs */ public Set getSubscriberIds(String destinationId, String subtopicPattern, Map messageHeaders) { MessageDestination destination = (MessageDestination) getDestination(destinationId); SubscriptionManager subscriptionManager = destination.getSubscriptionManager(); return subscriptionManager.getSubscriberIds(subtopicPattern, messageHeaders); }
/** * Issue messages to request the remote subscription table from each server in the cluster (except this one). */ public void initRemoteSubscriptions(String destinationId) { ClusterManager clm = getMessageBroker().getClusterManager(); String serviceType = getClass().getName(); MessageDestination dest = (MessageDestination) getDestination(destinationId); Cluster cluster = clm.getCluster(serviceType, destinationId); if (cluster != null) cluster.addRemoveNodeListener(dest.getRemoteSubscriptionManager()); List members = clm.getClusterMemberAddresses(serviceType, destinationId); for (int i = 0; i < members.size(); i++) { Object addr = members.get(i); if (!clm.getLocalAddress(serviceType, destinationId).equals(addr)) requestSubscriptions(destinationId, addr); } }
/** * Issue messages to request the remote subscription table from each server in the cluster (except this one). * @param destinationId the destination ID */ public void initRemoteSubscriptions(String destinationId) { ClusterManager clm = getMessageBroker().getClusterManager(); String serviceType = getClass().getName(); MessageDestination dest = (MessageDestination) getDestination(destinationId); Cluster cluster = clm.getCluster(serviceType, destinationId); if (cluster != null) cluster.addRemoveNodeListener(dest.getRemoteSubscriptionManager()); List members = clm.getClusterMemberAddresses(serviceType, destinationId); for (int i = 0; i < members.size(); i++) { Object addr = members.get(i); if (!clm.getLocalAddress(serviceType, destinationId).equals(addr)) requestSubscriptions(destinationId, addr); } }
/** * Issue messages to request the remote subscription table from each server in the cluster (except this one). * @param destinationId the destination ID */ public void initRemoteSubscriptions(String destinationId) { ClusterManager clm = getMessageBroker().getClusterManager(); String serviceType = getClass().getName(); MessageDestination dest = (MessageDestination) getDestination(destinationId); Cluster cluster = clm.getCluster(serviceType, destinationId); if (cluster != null) cluster.addRemoveNodeListener(dest.getRemoteSubscriptionManager()); List members = clm.getClusterMemberAddresses(serviceType, destinationId); for (int i = 0; i < members.size(); i++) { Object addr = members.get(i); if (!clm.getLocalAddress(serviceType, destinationId).equals(addr)) requestSubscriptions(destinationId, addr); } }
/** * Pushes a message to all clients that are subscribed to the destination targeted by this message. * * @param message The <code>Message</code> to push to the destination's subscribers. * * @param evalSelector <code>true</code> to evaluate each subscriber's selector before pushing * the message to them; <code>false</code> to skip selector evaluation. */ public void pushMessageToClients(Message message, boolean evalSelector) { MessageDestination destination = (MessageDestination)getDestination(message); SubscriptionManager subscriptionManager = destination.getSubscriptionManager(); Set subscriberIds = subscriptionManager.getSubscriberIds(message, evalSelector); if (debug) Log.getLogger(LOG_CATEGORY).debug("Sending message: " + message + StringUtils.NEWLINE + " to subscribed clientIds: " + subscriberIds); if ((subscriberIds != null) && !subscriberIds.isEmpty()) { /* We have already filtered based on the selector and so pass false below */ pushMessageToClients(destination, subscriberIds, message, false); } }
/** * Pushes a message to all clients that are subscribed to the destination targeted by this message. * * @param message The <code>Message</code> to push to the destination's subscribers. * * @param evalSelector <code>true</code> to evaluate each subscriber's selector before pushing * the message to them; <code>false</code> to skip selector evaluation. */ public void pushMessageToClients(Message message, boolean evalSelector) { MessageDestination destination = (MessageDestination)getDestination(message); SubscriptionManager subscriptionManager = destination.getSubscriptionManager(); Set subscriberIds = subscriptionManager.getSubscriberIds(message, evalSelector); if (debug) Log.getLogger(LOG_CATEGORY).debug("Sending message: " + message + StringUtils.NEWLINE + " to subscribed clientIds: " + subscriberIds); if ((subscriberIds != null) && !subscriberIds.isEmpty()) { /* We have already filtered based on the selector and so pass false below */ pushMessageToClients(destination, subscriberIds, message, false); } }
/** * Pushes a message to all clients that are subscribed to the destination targeted by this message. * * @param message The <code>Message</code> to push to the destination's subscribers. * * @param evalSelector <code>true</code> to evaluate each subscriber's selector before pushing * the message to them; <code>false</code> to skip selector evaluation. */ public void pushMessageToClients(Message message, boolean evalSelector) { MessageDestination destination = (MessageDestination)getDestination(message); SubscriptionManager subscriptionManager = destination.getSubscriptionManager(); Set subscriberIds = subscriptionManager.getSubscriberIds(message, evalSelector); if (Log.isDebug()) Log.getLogger(LOG_CATEGORY).debug("Sending message: " + message + StringUtils.NEWLINE + " to subscribed clientIds: " + subscriberIds); if ((subscriberIds != null) && !subscriberIds.isEmpty()) { /* We have already filtered based on the selector and so pass false below */ pushMessageToClients(destination, subscriberIds, message, false); } }
/** * This method is provided for a cluster peer broadcast, it is not invoked locally. It is used * by remote clients to send their subscription table to this server. * * */ public void receiveSubscriptions(String destinationId, Object subscriptions, Object senderAddress) { Destination destination = getDestination(destinationId); if (destination instanceof MessageDestination) ((MessageDestination) destination).getRemoteSubscriptionManager().setSubscriptionState(subscriptions, senderAddress); else if (subscriptions != null && Log.isError()) Log.getLogger(LOG_CATEGORY).error("receiveSubscriptions called with non-null value but destination: " + destinationId + " is not a MessageDestination"); }
/** * This method is provided for a cluster peer broadcast, it is not invoked locally. It is used * by remote clients to send their subscription table to this server. * * */ public void receiveSubscriptions(String destinationId, Object subscriptions, Object senderAddress) { Destination destination = getDestination(destinationId); if (destination instanceof MessageDestination) ((MessageDestination) destination).getRemoteSubscriptionManager().setSubscriptionState(subscriptions, senderAddress); else if (subscriptions != null && Log.isError()) Log.getLogger(LOG_CATEGORY).error("receiveSubscriptions called with non-null value but destination: " + destinationId + " is not a MessageDestination"); }
/** * This method is provided for a cluster peer broadcast, it is not invoked locally. It is used * by remote clients to send their subscription table to this server. * * @exclude */ public void receiveSubscriptions(String destinationId, Object subscriptions, Object senderAddress) { Destination destination = getDestination(destinationId); if (destination instanceof MessageDestination) { ((MessageDestination) destination).getRemoteSubscriptionManager().setSubscriptionState(subscriptions, senderAddress); } else if (subscriptions != null) { if (Log.isError()) Log.getLogger(LOG_CATEGORY).error("receiveSubscriptions called with non-null value but destination: " + destinationId + " is not a MessageDestination"); } }
/** * This is called remotely from other cluster members when a new remote subscription is identified. * * We add or remove a remote subscription... */ public void subscribeFromPeer(String destinationId, Boolean subscribe, String selector, String subtopic, Object remoteAddress) { Destination destination = getDestination(destinationId); RemoteSubscriptionManager subMgr = ((MessageDestination) destination).getRemoteSubscriptionManager(); if (destination instanceof MessageDestination) { if (Log.isDebug()) Log.getLogger(MessageService.LOG_CATEGORY).debug("Received subscription from peer: " + remoteAddress + " subscribe? " + subscribe + " selector: " + selector + " subtopic: " + subtopic); if (subscribe.booleanValue()) subMgr.addSubscriber(remoteAddress, selector, subtopic, null); else subMgr.removeSubscriber(remoteAddress, selector, subtopic, null); } else if (Log.isError()) Log.getLogger(LOG_CATEGORY).error("subscribeFromPeer called with destination: " + destinationId + " that is not a MessageDestination"); }
/** * Used to increment the message count metric for the <code>MessageService</code>. This value is * stored in the corresponding MBean. The <code>MessageService</code> already invokes this method * in its <code>serviceMessage()</code> and <code>serviceCommand()</code> implementations, but if * a subclass overrides these methods completely it should invoke this method appropriately as * it processes messages. * * @param commandMessage Pass <code>true</code> if the message being processed is a <code>CommandMessage</code>; * otherwise <code>false</code>. */ protected void incrementMessageCount(boolean commandMessage, Message message) { // Update management metrics. if (isManaged()) { MessageDestination destination = (MessageDestination)getDestination(message.getDestination()); if (destination != null && destination.isManaged()) { MessageDestinationControl destinationControl = (MessageDestinationControl)destination.getControl(); if (destinationControl != null) // Should not happen but just in case. { if (commandMessage) destinationControl.incrementServiceCommandCount(); else destinationControl.incrementServiceMessageCount(); } } } }
/** * This is called remotely from other cluster members when a new remote subscription is identified. * * We add or remove a remote subscription... * @param destinationId the destination ID * @param subscribe whehter it is a subscribe or unsubscribe * @param selector the selector string * @param subtopc the subtopic string * @param remoteAddress the remote node address in the cluster */ public void subscribeFromPeer(String destinationId, Boolean subscribe, String selector, String subtopic, Object remoteAddress) { Destination destination = getDestination(destinationId); RemoteSubscriptionManager subMgr = ((MessageDestination) destination).getRemoteSubscriptionManager(); if (destination instanceof MessageDestination) { if (debug) Log.getLogger(MessageService.LOG_CATEGORY).debug("Received subscription from peer: " + remoteAddress + " subscribe? " + subscribe + " selector: " + selector + " subtopic: " + subtopic); if (subscribe) subMgr.addSubscriber(remoteAddress, selector, subtopic, null); else subMgr.removeSubscriber(remoteAddress, selector, subtopic, null); } else if (Log.isError()) Log.getLogger(LOG_CATEGORY).error("subscribeFromPeer called with destination: " + destinationId + " that is not a MessageDestination"); }