The EventListener allows a snap-in to be informed of events. The snap-in must implement a class adorned with the annotations @
TheEventListener
and @Stateless; it must
not be adorned with the annotation @LocalBean.
Most settable bean parameters are incompatible with this listener.
Important Notes
- Only a single class is allowed to implement the
TheEventListener
annotation.
- The detection of the implemented listener class is initiated the first time a subscription is made. It is a common mistake to
implement an event listener class and then look for evidence that it has been scanned by the Eventing Framework before a subscription has
been created. If your attempts to receive events through your event listener do not seem to be working, please double-check that you have
subscribed in an area of code that is actually getting executed. Since attempts to subscribe are commonly placed in the initialization
code of some object in a snap-in, the nuances of the life cycle of Enterprise Java Beans can sometimes lead to unexpected initialization
behavior.
- When either the Collaboration Bus, Email, or SMS API is used in the EventListener, there are certain coding patterns that might be
used where the receipt of an expected response from one of these APIs will arrive only after many seconds of delay or not at all. This
behavior is the result of using these APIs from an Enterprise Java Bean (EJB) like the EventListener. Additional information about why
these APIs exhibit this behavior in an EJB can be found here:
Collaboration Bus - MessageReceiver
Email - EmailListener
SMS - SmsListener
To correct this behavior, transaction processing within the EventListener needs to be disabled. The following annotation can be added at
the class level of the EventListener to disable this transaction processing:
@TransactionAttribute(value = TransactionAttributeType.NOT_SUPPORTED)