if (subscriberIds != null)
{
try
{
// Place notifier in thread-local scope.
MessageRoutedNotifier routingNotifier = new MessageRoutedNotifier(message);
FlexContext.setMessageRoutedNotifier(routingNotifier);
// Throttle outgoing at the destination level
ThrottleResult throttleResult = destination.getThrottleManager().throttleOutgoingMessage(message, null);
int throttleResultCode = throttleResult.getResultCode();
MessageException me = throttleResult.getException();
if (throttleResultCode == ThrottleResult.RESULT_ERROR)
{
throw me;
}
else if (throttleResultCode == ThrottleResult.RESULT_IGNORE)
{
if (Log.isDebug())
Log.getLogger(LOG_CATEGORY).debug(me.getMessage(), me);
}
else
{
SubscriptionManager subscriptionManager = destination.getSubscriptionManager();
for (Iterator clientIter = subscriberIds.iterator(); clientIter.hasNext();)
{
Object clientId = clientIter.next();
MessageClient client = (MessageClient)subscriptionManager.getSubscriber(clientId);
// Skip if the client is null or invalidated.
if (client == null || !client.isValid())
{
if (Log.isDebug())
Log.getLogger(MessageService.LOG_CATEGORY).debug("Warning: could not find MessageClient for clientId in pushMessageToClients: " + clientId + " for destination: " + destination.getId());
continue;
}
pushMessageToClient(client, destination, message, evalSelector, throttleResult);
}
}
// Done with the push, notify any listeners.
routingNotifier.notifyMessageRouted();
}
finally
{
// Unset the notifier for this message.
FlexContext.setMessageRoutedNotifier(null);