Sun POJO Service Engine User's Guide

Consuming Services Asynchronously

Consuming services in asynchronous mode can make using resources such as threads more efficient. Consuming services asynchronously in the POJO SE does not block the threads; instead, the control returns to the POJO code. This allows the POJO SE to execute more POJO services using fewer thread resources. Asynchronous service consumption is supported using annotated callback methods. Each of the callback methods are annotated in POJO using one of the following annotations: @OnReply, @OnError, @OnFault, or @OnDone.

The POJO SE calls the OnReply annotated method when the InOut message exchange pattern service is consumed asynchronously. This method takes two parameters. The first is of the type ServiceEndpoint and the second is one of the following types: String, Source, Node, NormalizedMessage, or MessageExchange.

The POJO SE calls the OnFault annotated method when the InOut message exchange pattern service is consumed asynchronously and the consumed service returns a fault message. This method also takes two parameters. The first is of the type ServiceEndpoint and second is of the type MessageExchange.

The POJO SE calls the OnError annotated method when the InOut message exchange pattern service is consumed asynchronously and the consumed service returns an error status. This method takes two parameters. The first one is of the type ServiceEndpoint and the second is of the type MessageExchange.

The POJO SE executes the OnDone annotated method when all the responses from asynchronously consumed services are received. Whenever POJO throws FaultMessage, ErrorMessage, or Exception back to the POJO SE, the POJO SE returns the fault message or error status back to the POJO service consumer. Further execution of callback and OnDone methods are aborted and outstanding responses from asynchronously consumed services by this POJO instance are ignored. Where possible, the error status is returned.