- All Known Implementing Classes:
- SampleEmailListener
public interface EmailListener
A service writer who wishes to receive responses to an EmailRequest#send()
operation will need to implement this interface.
This is accomplished by calling the EmailRequest#setListener(EmailListener)
method with the implementation.
Use Of the Email API in an Enterprise Java Bean
When the email API is used in an Enterprise Java Bean (EJB), responses destined for the EmailListener may be delayed in their arrival
and/or appear to be "stuck" when certain coding patterns are used. An example of this type of coding pattern is the following:
A method on the EJB called "sendMyEmail" creates an EmailRequest and then invokes "EmailRequest.send()". The sendMyEmail method then
waits for a response to arrive at the EmailListener before returning control to the invoking software.
With this coding pattern the response may not be delivered to the listener as long as control remains in the sendMyEmail method. This
condition is a result of the EJB framework attempting to enforce a transaction. Since the email API makes use of the Collaboration Bus,
it is necessary to disable transaction processing when a coding pattern is used that leads to this condition. To disable transaction
processing, the following annotation can be added at the class level to the definition of the EJB:
@TransactionAttribute(value = TransactionAttributeType.NOT_SUPPORTED)