Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.soa.esb.client
Class ServiceInvoker

    java.lang.Object
      org.jboss.soa.esb.client.ServiceInvoker

    public class ServiceInvoker

extends java.lang.Object

Invoker class for managing `Message` delivery to a specified Service.

Manages loading of `EPRs`, `Courier` selection and message delivery. Provides a unified/simplified interface for message delivery. The ServiceInvoker will cache entries from the registry for the relevant service. This cache will be refreshed under the following conditions: (i) all of the entries fail on a delivery attempt. (ii) the cache times out (see property org.jboss.soa.esb.registry.cache.life): default is 60 seconds.

Author:
  tom.fennelly@jboss.com

Field Summary
`static java.lang.String` | `DEAD_LETTER_SERVICE_NAME`
`static java.lang.String` | `DELIVER_TO`
`static Service` | `dlqService` Dead letter Service
`static java.lang.String` | `INTERNAL_SERVICE_CATEGORY`

Constructor Summary
`ServiceInvoker(Service service)` Public constructor.
`ServiceInvoker(Service service, java.util.List<PortReference.Extension> extensions)` Public constructor.
`ServiceInvoker(java.lang.String serviceCategory, java.lang.String serviceName)` Public constructor.

Method Summary
`void` | `deliverAsync(Message message)` Asynchronously deliver the supplied message to the target service associated with this invoker instance.
`Message` | `deliverSync(Message message, long timeoutMillis)` Synchronously deliver the supplied message to the target service associated with this invoker instance.
`protected static void` | `deliverToDeadLetterService(Message message)` Deliver a message to the Dead Letter Channel Service.
`protected TwoWayCourier` | `getCourier(EPR epr)` Get a `Courier` for the supplied EPR.
`protected EPR` | `getReplyToAddress(EPR toEpr)` Get the reply to address for synchronous delivery.
`Service` | `getService()` Get the details of Service to which this invoker instance is delivering messages.
`java.lang.String` | `getServiceCategory()` Get the Service category name for the Service for which this instance is delivering messages.
`java.lang.String` | `getServiceName()` Get the Service name for the Service for which this instance is delivering messages.
`void` | `loadServiceClusterInfo()` Loads the EPRs fresh from the Registry.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### INTERNAL_SERVICE_CATEGORY

    public static final java.lang.String INTERNAL_SERVICE_CATEGORY

See Also:
  Constant Field Values

### DEAD_LETTER_SERVICE_NAME

    public static final java.lang.String DEAD_LETTER_SERVICE_NAME

See Also:
  Constant Field Values

### DELIVER_TO

    public static final java.lang.String DELIVER_TO

See Also:
  Constant Field Values

### dlqService

    public static final Service dlqService

  Dead letter Service

Constructor Detail

### ServiceInvoker

    public ServiceInvoker(Service service)
                   throws MessageDeliverException

  Public constructor.

  Parameters:
    `service` - The Service to which this instance will deliver messages.
  Throws:
    `MessageDeliverException` - Failed to deliver message to endpoint.

### ServiceInvoker

    public ServiceInvoker(Service service,
                          java.util.List<PortReference.Extension> extensions)
                   throws MessageDeliverException

  Public constructor.

  Parameters:
    `service` - The Service to which this instance will deliver messages.
    `extensions` - The extensions to be added to the target service.
  Throws:
    `MessageDeliverException` - Failed to deliver message to endpoint.

### ServiceInvoker

    public ServiceInvoker(java.lang.String serviceCategory,
                          java.lang.String serviceName)
                   throws MessageDeliverException

  Public constructor.

  Parameters:
    `serviceCategory` - The category name of the Service to which this instance will deliver messages.
    `serviceName` - The name of the Service to which this instance will deliver messages.
  Throws:
    `MessageDeliverException` - Failed to deliver message to endpoint.

Method Detail

### deliverSync

    public Message deliverSync(Message message,
                               long timeoutMillis)
                        throws MessageDeliverException,
                               RegistryException,
                               FaultMessageException

  Synchronously deliver the supplied message to the target service associated with this invoker instance. If the To field of the Message is set, then it will be ignored in favour of the equivalent information obtained through the parameters provided during instance construction.

  Parameters:
    `message` - The message to be delivered.
    `timeoutMillis` - Number of milliseconds before synchronous reply pickup should timeout.
  Returns:
    Returns the reply message if the message was delivered without error, otherwise an exception is thrown.
  Throws:
    `RegistryException` - Failed to lookup Service endpoint.
    `MessageDeliverException` - Failed to deliver message to endpoint.
    `FaultMessageException`

### deliverAsync

    public void deliverAsync(Message message)
                      throws MessageDeliverException

  Asynchronously deliver the supplied message to the target service associated with this invoker instance. If the To field of the Message is set, then it will be ignored in favour of the equivalent information obtained through the parameters provided during instance construction.

  Parameters:
    `message` - The message to be delivered.
  Throws:
    `MessageDeliverException` - Failed to deliver message, after trying all available EPRs.

### deliverToDeadLetterService

    protected static void deliverToDeadLetterService(Message message)
                                              throws MessageDeliverException

  Deliver a message to the Dead Letter Channel Service.

  For internal package use only.

  Parameters:
    `message` - The message to be delivered to the dead letter chennel.
  Throws:
    `RegistryException` - Service endpoint lookup failure.
    `MessageDeliverException` - Message delivery failure.

### getService

    public Service getService()

  Get the details of Service to which this invoker instance is delivering messages.

  Returns:
    The Service details.

### getServiceCategory

    public java.lang.String getServiceCategory()

  Get the Service category name for the Service for which this instance is delivering messages.

  Returns:
    Service Category.

### getServiceName

    public java.lang.String getServiceName()

  Get the Service name for the Service for which this instance is delivering messages.

  Returns:
    Service name.

### getReplyToAddress

    protected EPR getReplyToAddress(EPR toEpr)
                             throws ConfigurationException

  Get the reply to address for synchronous delivery.

  Parameters:
    `toEpr` - The to address.
  Returns:
    The replyTo address.
  Throws:
    `ConfigurationException` - Unable to support synchronous reply on 'to' address.

### getCourier

    protected TwoWayCourier getCourier(EPR epr)
                                throws CourierException,
                                       MalformedEPRException

  Get a `Courier` for the supplied EPR.

  Parameters:
    `epr` - The EPR for which a `Courier` is being sought.
  Returns:
    The courier for the EPR.
  Throws:
    `CourierException` - A courier implementation cannot be created.
    `MalformedEPRException` - Bad EPR.

### loadServiceClusterInfo

    public void loadServiceClusterInfo()
                                throws MessageDeliverException

  Loads the EPRs fresh from the Registry. Right now we will do this every minute until we can expect to get updates from the registry. For now this should work just fine.

  Throws:
    `MessageDeliverException` - Registry lookup failure.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD