Interface EventActionHandler
-
public interface EventActionHandler
An interface to be implemented as a event action handler, which runs on the server. When an operation is performed on an object with a subscription, and that operation is one of the subscribed events for that subscription, the event handler will be invoked. Note that for theGetContentEvent
, theRetrievalEventActionHandler
interface must be used.When implementing an event action handler, consider the following points:
- You can configure an event action handler (through the
Subscription
object) to run synchronously or asynchronously. - If a synchronous event action handler fails, an exception will return to the client and the transaction will be rolled back.
If an asynchronous event action handler fails, an exception will be logged to the server, and the asynchronous action will remain in the
QueueItem
and retried as often as set in the RetryCount property. - An asynchronous event action handler can update a source object, but it must first fetch the persisted instance of the source object before updating it.
Do not update the source object passed to the asynchronous handler.
A synchronous event action handler cannot update a source object. It is not supported.
- You can implement an event action handler as a Java or JavaScript component.
You can check in a Java event action handler as a
CodeModule
object, or you can specify a Java event action handler in the classpath of the application server where the Content Engine is running.If a Java event handler is intended to work with both
ObjectChangeEvent
andGetContentEvent
, it must implement both interfaces. For example:
public class NewEventHandler implements EventActionHandler, RetrievalEventActionHandler
.Because JavaScript is loosely typed, you do not specify the event type in the
onEvent
method signature. Therefore, you need only a singleOnEvent
method for a JavaScript event handler to work with bothObjectChangeEvent
andGetContentEvent
.
- You can configure an event action handler (through the
-
-
Method Summary
Methods Modifier and Type Method and Description void
onEvent(ObjectChangeEvent event, Id subscriptionId)
Invoked when an operation on an object triggers a subscribed event, or when a publish or republish operation is configured to trigger an event action.
-
-
-
Method Detail
-
onEvent
void onEvent(ObjectChangeEvent event, Id subscriptionId) throws EngineRuntimeException
Invoked when an operation on an object triggers a subscribed event, or when a publish or republish operation is configured to trigger an event action. Implement this method with the actions to be taken when the event is triggered.- Parameters:
event
- An event of typeObjectChangeEvent
.subscriptionId
- An Id value that represents the GUID of the subscription that defines the triggered event. You can use this value to retrieve theSubscription
object with which this handler is associated. For a publish or republish operation, the Id value isnull
.- Throws:
EngineRuntimeException
-
-