/** * This method is called from a messaging adapter to handle the delivery of messages to one or * more clients. If you pass in the <code>sendToAllSubscribers</code> parameter as <code>true * </code>, the message is routed to all clients who are subscribed to receive messages from this * destination. When you use this method, the selector expressions for all subscribing clients are * not evaluated. If you want the selector expressions to be evaluated, use a combination of the * <code>pushMessageToClients</code> method and the <code>sendPushMessageFromPeer</code> methods. * * @param message The <code>Message</code> to send. * @param sendToAllSubscribers If <code>true</code>, send this message to all clients subscribed * to the destination of this message. If <code>false</code>, send the message only to the * clientId specified in the message. */ public void serviceMessageFromAdapter(Message message, boolean sendToAllSubscribers) { // Update management metrics. if (managed) { 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. destinationControl.incrementServiceMessageFromAdapterCount(); } } // in this service's case, this invocation occurs when an adapter has asynchronously // received a message from one of its adapters acting as a consumer if (sendToAllSubscribers) { pushMessageToClients(message, false); sendPushMessageFromPeer(message, false); } else { // TODO - need to do something here to locate the proper qualified client. // the adapter has already processed the subscribers Set subscriberIds = new TreeSet(); subscriberIds.add(message.getClientId()); pushMessageToClients(subscriberIds, message, false); } }
/** * 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) { if (managed) // Update management metrics. { 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(); } } } }