org.jboss.soa.esb.client
Class MessageMulticaster

java.lang.Object
  extended by org.jboss.soa.esb.client.MessageMulticaster

public class MessageMulticaster
extends java.lang.Object

Message Multicaster.

Used to send a message to a recipient list, or a subset of that recipient list.

Caches a ServiceInvoker instance for each recipient.

Note: This doesn't "multicast" message delivery in the true IP sense of the word "multicast". It sends the message to all recipients in its recipient list, one at a time, in the order the recipients were added via the addRecipient(org.jboss.soa.esb.Service) method.

Author:
tom.fennelly@jboss.com

Constructor Summary
MessageMulticaster()
          Public default constructor.
MessageMulticaster(java.lang.String splitId)
          Public default constructor.
 
Method Summary
 void addRecipient(Service service)
          Add a message recipient Service.
 int getRecipientCount()
          Get the number ot recipients associated with this multicaster instance.
 boolean isRecipient(Service service)
          Is the specified service a recipient of this multicaster instance.
 void sendToAll(Message message)
          Send the message to all the recipients associated with this multicaster.
 void sendToSubset(Message message, java.util.List<Service> recipients)
          Send the message to all the recipients associated with this multicaster and also listed in the supplied recipient list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageMulticaster

public MessageMulticaster()
Public default constructor.


MessageMulticaster

public MessageMulticaster(java.lang.String splitId)
Public default constructor.

Parameters:
splitId - Split ID for this multicaster.
Method Detail

addRecipient

public void addRecipient(Service service)
                  throws RegistryException,
                         MessageDeliverException
Add a message recipient Service.

Parameters:
service - Recipient service for receipt of messages from this miltcaster instance.
Throws:
RegistryException - Failed to lookup Service endpoint.
MessageDeliverException - Failed to deliver message to endpoint.

isRecipient

public boolean isRecipient(Service service)
Is the specified service a recipient of this multicaster instance.

Parameters:
service - The service to check for.
Returns:
True if the supplied service is one of the recipients, otherwise false.

getRecipientCount

public int getRecipientCount()
Get the number ot recipients associated with this multicaster instance.

Returns:
The number of recipients.

sendToAll

public void sendToAll(Message message)
               throws RegistryException,
                      MessageDeliverException
Send the message to all the recipients associated with this multicaster.

Parameters:
message - The message.
Throws:
RegistryException - Failed to lookup Service endpoint.
MessageDeliverException - Failed to deliver message to endpoint.

sendToSubset

public void sendToSubset(Message message,
                         java.util.List<Service> recipients)
                  throws RegistryException,
                         MessageDeliverException
Send the message to all the recipients associated with this multicaster and also listed in the supplied recipient list.

The recipients supplied in the list must have been added through the addRecipient(org.jboss.soa.esb.Service) method, otherwise the message will be delivered to the Dead Letter Channel.

Parameters:
message - The message.
recipients - The recipient subset to which the supplied message is to be sent.
Throws:
RegistryException - Failed to lookup Service endpoint.
MessageDeliverException - Failed to deliver message to endpoint.