If an application uses a sender bean to send a message, it can optionally retrieve a response to the message. The sender bean can either wait for the response or defer retrieval of the response. Sometimes a response is delayed within the messaging infrastructure, and therefore the application cannot receive the response. Extended messaging can retrieve such a response message (referred to as a late-response message) when it does arrive and pass it to a message-driven bean provided by the application to handle late responses. The message-driven bean used to handle the late response is a standard EJB 2.0 message-driven bean or a receiver bean deployed as a message-driven bean. The deployed message-driven bean can then perform its processing on the message.
Late responses should not be considered normal application behaviour.
For extended messaging to handle late responses for an application, the sender bean must be deployed with the Handle late responses option enabled.
Definition of a late response
A late response occurs when the application is no longer able to retrieve responses to messages that it has sent, as follows:
The application (enterprise bean) repeatedly tries to retrieve a response until it ends. When the application no longer wants to retry to get a response, it can register a request for extended messaging to handle the late response, by calling a registerLateResponse() method on the sender bean.
When the sender bean sends a message, it waits for the response. The result of this is that either the sender bean retrieves the response message or a timeout error occurs. If the system raises a timeout error, the application can no longer retrieve a response to the message. At this time the extended messaging service registers the the message for a late response.
Handling responses
Extended messaging handles responses in the following stages:
To request the system to handle late responses for a sender bean, you deploy the sender bean with the Handle late responses extension to the deployment Descriptor.
If selected, the Handle late responses option defines that extended messaging should pass the response, when it becomes available, to the message-driven bean provided by the application to handle late responses. When the sender bean is deployed a specialized listener port is associated with the bean. This listener port is known as a handle late response listener port.
If the option is not selected, then the system does not handle late responses, and it is the application's responsibility to handle any late responses.
The listener port must be defined with the following properties:
You cannot use a temporary destination for late responses.