Class EventLogService

java.lang.Object
org.imixs.workflow.engine.EventLogService

@DeclareRoles({"org.imixs.ACCESSLEVEL.NOACCESS","org.imixs.ACCESSLEVEL.READERACCESS","org.imixs.ACCESSLEVEL.AUTHORACCESS","org.imixs.ACCESSLEVEL.EDITORACCESS","org.imixs.ACCESSLEVEL.MANAGERACCESS"}) @RolesAllowed({"org.imixs.ACCESSLEVEL.NOACCESS","org.imixs.ACCESSLEVEL.READERACCESS","org.imixs.ACCESSLEVEL.AUTHORACCESS","org.imixs.ACCESSLEVEL.EDITORACCESS","org.imixs.ACCESSLEVEL.MANAGERACCESS"}) public class EventLogService extends Object
The EventLogService is a service to create and access an event log .

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
Author:
rsoika
See Also:
  • Field Details

  • Constructor Details

    • EventLogService

      public EventLogService()
  • Method Details

    • createEvent

      public EventLog createEvent(String topic, String refID)
      Creates/updates a new event log entry.
      Parameters:
      refID - - uniqueid of the document to be assigned to the event
      topic - - the topic of the event.
      Returns:
      - generated event log entry
    • createEvent

      public EventLog createEvent(String topic, String refID, Calendar timeout)
      Creates/updates a new event log entry.
      Parameters:
      refID - - uniqueid of the document to be assigned to the event
      topic - - the topic of the event.
      timeout - - optional timeout calendar object
      Returns:
      - generated event log entry
    • createEvent

      public EventLog createEvent(String topic, String refID, ItemCollection document)
      Creates/updates a new event log entry.
      Parameters:
      refID - - uniqueId of the document to be assigned to the event
      topic - - the topic of the event.
      document - - optional document providing a data map
      Returns:
      - generated event log entry
    • createEvent

      public EventLog createEvent(String topic, String refID, ItemCollection document, Calendar timeout)
      Creates/updates a new event log entry.
      Parameters:
      refID - - uniqueId of the document to be assigned to the event
      topic - - the topic of the event.
      document - - optional document providing a data map
      timeout - - optional timeout calendar object
      Returns:
      - 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.
      Parameters:
      refID - - uniqueId of the document to be assigned to the event
      topic - - the topic of the event.
      data - - optional data map
      Returns:
      - generated event log entry
    • findEventsByTopic

      public List<EventLog> findEventsByTopic(int maxCount, String... topic)
      Finds events for one or many given topics
      Parameters:
      maxCount - - maximum count of events to be returned
      topic - - list of topics
      Returns:
      - list of eventLogEntries
    • findEventsByTimeout

      public List<EventLog> findEventsByTimeout(int maxCount, String... topic)
      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.

      Parameters:
      maxCount - - maximum count of events to be returned
      topic - - list of topics
      Returns:
      - list of eventLogEntries
    • findEventsByRef

      public List<EventLog> findEventsByRef(int maxCount, String ref, String... topic)
      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,
      Parameters:
      maxCount - - maximum count of events to be returned
      ref - - a reference ID for an assigned Document or Workitem instance
      topic - - list of topics
      Returns:
      - list of eventLogEntries
    • findAllEvents

      public List<EventLog> findAllEvents(int firstResult, int maxResult)
      Returns all event log entries
      Parameters:
      firstResult - - first result
      maxResult - - maximum count of events to be returned
      Returns:
      - list of eventLogEntries
    • removeEvent

      public void removeEvent(EventLog _eventLog)
      Deletes an existing eventLog. The method catches jakarta.persistence.OptimisticLockException as this may occur during parallel requests.
      Parameters:
      eventLog -
    • removeEvent

      public void removeEvent(String id)
      Deletes an existing eventLog by its id. The method catches jakarta.persistence.OptimisticLockException as this may occur during parallel requests.
      Parameters:
      eventLog -
    • getEvent

      public EventLog getEvent(String id)
      Returns an detached event log entry by its ID.
      Parameters:
      id - - id of the eventLog Entry
      Returns:
      detached eventLog entry or null if not found
    • lock

      public boolean lock(EventLog _eventLogEntry)
      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.

      Parameters:
      eventLogEntry -
      Returns:
      - true if lock was successful
    • unlock

      public boolean unlock(EventLog _eventLogEntry)
      This method unlocks an eventLog entry. The topic suffix '.lock' will be removed.
      Parameters:
      eventLogEntry -
      Returns:
      - true if unlock was successful
    • releaseDeadLocks

      public void releaseDeadLocks(long deadLockInterval, String... topic)
      This method unlocks eventlog entries which are older than 1 minute. We assume that these events are deadlocks.