Klasse EventLogService
An event that occurs during an update or a processing function within a transaction becomes a fact when the transaction completes successfully. The EventLogService can be used to store this kind of "Change Data Capture" events in a log. An example is the LuceneUpdateService, which should update the index of a document only if the document was successfully written to the database.
The service is bound to the current PersistenceContext and stores a EventLog entity directly in the database to represent an event. These types of events can be queried by clients through the service.
The EventLogService provides a lock/unlock mechanism. An eventLog entry can optional be locked for processing. The topic of the event will be suffixed with '.lock' to indicate that this topic is locked by a running process. If a lock is successful a client can exclusive process this eventLog entry.
The method releaseDeadLocks unlocks eventlog entries which are older than 1 minute. We assume that these events are deadlocks.
- Version:
- 1.0
- Autor:
- rsoika
- Siehe auch:
-
Feldübersicht
Felder -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungcreateEvent(String topic, String refID) Creates/updates a new event log entry.createEvent(String topic, String refID, Calendar timeout) Creates/updates a new event log entry.Creates/updates a new event log entry.createEvent(String topic, String refID, ItemCollection document) Creates/updates a new event log entry.createEvent(String topic, String refID, ItemCollection document, Calendar timeout) Creates/updates a new event log entry.findAllEvents(int firstResult, int maxResult) Returns all event log entriesfindEventsByRef(int maxCount, String ref, String... topic) Finds events for one or many given topics assigned to a given document reference ($uniqueId).findEventsByTimeout(int maxCount, String... topic) Finds events for one or many given topics within the current timeout.findEventsByTopic(int maxCount, String... topic) Finds events for one or many given topicsReturns an detached event log entry by its ID.booleanThis method locks an eventLog entry for processing.voidreleaseDeadLocks(long deadLockInterval, String... topic) This method unlocks eventlog entries which are older than 1 minute.voidremoveEvent(String id) Deletes an existing eventLog by its id.voidremoveEvent(EventLog _eventLog) Deletes an existing eventLog.booleanThis method unlocks an eventLog entry.
-
Felddetails
-
EVENTLOG_LOCK_DATE
- Siehe auch:
-
-
Konstruktordetails
-
EventLogService
public EventLogService()
-
-
Methodendetails
-
createEvent
Creates/updates a new event log entry.- Parameter:
topic- - the topic of the event.refID- - uniqueid of the document to be assigned to the event- Gibt zurück:
- - generated event log entry
-
createEvent
Creates/updates a new event log entry.- Parameter:
topic- - the topic of the event.refID- - uniqueid of the document to be assigned to the eventtimeout- - optional timeout calendar object- Gibt zurück:
- - generated event log entry
-
createEvent
Creates/updates a new event log entry.- Parameter:
topic- - the topic of the event.refID- - uniqueId of the document to be assigned to the eventdocument- - optional document providing a data map- Gibt zurück:
- - generated event log entry
-
createEvent
Creates/updates a new event log entry.- Parameter:
topic- - the topic of the event.refID- - uniqueId of the document to be assigned to the eventdocument- - optional document providing a data maptimeout- - optional timeout calendar object- Gibt zurück:
- - generated event log entry
-
createEvent
public EventLog createEvent(String topic, String refID, Map<String, List<Object>> data, Calendar timeout) Creates/updates a new event log entry.- Parameter:
topic- - the topic of the event.refID- - uniqueId of the document to be assigned to the eventdata- - optional data map- Gibt zurück:
- - generated event log entry
-
findEventsByTopic
Finds events for one or many given topics- Parameter:
maxCount- - maximum count of events to be returnedtopic- - list of topics- Gibt zurück:
- - list of eventLogEntries
-
findEventsByTimeout
Finds events for one or many given topics within the current timeout.The attribute 'timeout' is optional. If the timeout is set to a future point of time, the event will be ignored by this method.
- Parameter:
maxCount- - maximum count of events to be returnedtopic- - list of topics- Gibt zurück:
- - list of eventLogEntries
-
findEventsByRef
Finds events for one or many given topics assigned to a given document reference ($uniqueId). The method returns an empty list if no event log entries exist of the given refId,- Parameter:
maxCount- - maximum count of events to be returnedref- - a reference ID for an assigned Document or Workitem instancetopic- - list of topics- Gibt zurück:
- - list of eventLogEntries
-
findAllEvents
Returns all event log entries- Parameter:
firstResult- - first resultmaxResult- - maximum count of events to be returned- Gibt zurück:
- - list of eventLogEntries
-
removeEvent
Deletes an existing eventLog. The method catches jakarta.persistence.OptimisticLockException as this may occur during parallel requests.- Parameter:
eventLog-
-
removeEvent
Deletes an existing eventLog by its id. The method catches jakarta.persistence.OptimisticLockException as this may occur during parallel requests.- Parameter:
eventLog-
-
getEvent
Returns an detached event log entry by its ID.- Parameter:
id- - id of the eventLog Entry- Gibt zurück:
- detached eventLog entry or null if not found
-
lock
This method locks an eventLog entry for processing. The topic will be suffixed with '.lock' to indicate that this topic is locked by a process. If a lock is successful a client can exclusive process this eventLog entry.The method adds a item 'eventlog.lock.date' with a timestamp. This timestamp is used by the method 'autoUnlock' to release locked entries.
- Parameter:
eventLogEntry-- Gibt zurück:
- - true if lock was successful
-
unlock
This method unlocks an eventLog entry. The topic suffix '.lock' will be removed.- Parameter:
eventLogEntry-- Gibt zurück:
- - true if unlock was successful
-
releaseDeadLocks
This method unlocks eventlog entries which are older than 1 minute. We assume that these events are deadlocks.
-