Class JMSResourceEventListener<T extends AbstractResourceEvent<?>>
- java.lang.Object
-
- org.silverpeas.core.notification.system.AbstractResourceEventListener<T>
-
- org.silverpeas.core.notification.system.JMSResourceEventListener<T>
-
- All Implemented Interfaces:
javax.jms.MessageListener
,ResourceEventListener<T>
public abstract class JMSResourceEventListener<T extends AbstractResourceEvent<?>> extends AbstractResourceEventListener<T> implements javax.jms.MessageListener
An asynchronous event listener. Asynchronous events are carried by JMS and are collected by this abstract class. It is dedicated to notify asynchronously external or remote software components; the asynchronous notification between Silverpeas inner components shouldn't use this mechanism.All concrete listeners have just to extend this abstract class and to implement first the
org.silverpeas.core.notification.system.JMSResourceEventListener#getResourceEventClass()
method to specify the class of the events to receive and then some of the following methods to transparently receive the events on which they are interested:org.silverpeas.core.notification.system.ResourceEventListener#onCreation(ResourceEvent
to receive events about the creation of a resource,org.silverpeas.core.notification.system.ResourceEventListener#onUpdate(ResourceEvent
to receive events about the update of a resource,org.silverpeas.core.notification.system.ResourceEventListener#onRemoving(ResourceEvent
to receive events about the removing of a resource,org.silverpeas.core.notification.system.ResourceEventListener#onDeletion(ResourceEvent
to receive events about the deletion of a resource,
With JMS, when an exception is thrown, a retry mechanism will replay the event delivery. You can refine this mechanism by overridden the
org.silverpeas.core.notification.system.JMSResourceEventListener#retryAtFailure()
method; by default this method returns false, indicating to not to replay the event delivery at exception raising.- Author:
- mmoquillon
-
-
Constructor Summary
Constructors Constructor Description JMSResourceEventListener()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Class<T>
getResourceEventClass()
Gets the class of the resource events listened by this listener.void
onMessage(javax.jms.Message message)
Listens for events related to a resource managed in Silverpeas.protected boolean
retryAtFailure()
Should JMS retry to replay the message to the listener at failure?-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.notification.system.ResourceEventListener
dispatchEvent, isEnabled, onCreation, onDeletion, onMove, onRecovery, onRemoving, onUnlock, onUpdate
-
-
-
-
Method Detail
-
getResourceEventClass
protected abstract Class<T> getResourceEventClass()
Gets the class of the resource events listened by this listener.- Returns:
- the class of the supported
org.silverpeas.core.notification.system.ResourceEvent
.
-
retryAtFailure
protected boolean retryAtFailure()
Should JMS retry to replay the message to the listener at failure? By default returns false.If true, a RuntimeException exception will be thrown if an exception is catched from the message consummation, provoking JMS to replay the message to this listener. If false, only an error level log will output.
- Returns:
- true if the message should be replay by JMS to this listener, false otherwise.
-
onMessage
public void onMessage(javax.jms.Message message)
Listens for events related to a resource managed in Silverpeas.The event is decoded from the specified message and according to the type of the event, the adequate method is then invoked:
- Specified by:
onMessage
in interfacejavax.jms.MessageListener
- Parameters:
message
- the notification message in which is encoded the event. The event should be serialized within the receivedjavax.jms.Message
object.- Throws:
RuntimeException
- if an error occurs while treating the event.- See Also:
ResourceEventListener.dispatchEvent(ResourceEvent)
-
-