Events detected by the passage of time

When using the time-based detection process, Event Manager selects all business objects with a next process date that is set to the current date or earlier.

As part of processing the business object, Event Detector returns two items:
  • A list of events that have occurred.
  • The date of the next closest possible event. This date is persisted and is called the next process date.
    The diagram shows the sequence of events as Event Manager detects and triggers events based on the passage of time

Event Manager executes the business rules to determine the events have happened and the ones that are pending. Events that are currently due are processed, and events that are pending are used to determine the next process date. If there are no events pending, a date in the future is selected, based on the system settings. This date is called the event horizon. You can control how often the business rules are reevaluated by changing the value of the event horizon. The next process date is stored in the PROCESSACTION table.

The PROCESSACTION table contains the records for business objects that Event Manager monitors, by types of event categories. For example, for a business object, there may be one PROCESSACTION record corresponding to the life events category and another record corresponding to the monthly events category. Other information about the business object, such as the unique identifier, is stored in the PROCESSCONTROL table.

The EventDetectionScheduleController invokes the ProcessControllerInternal bean to check if there are any business objects in the PROCESSACTION table that are due for processing. The ProcessControllerInternal bean picks up all the records from the PROCESSACTION table with a next process date of today or earlier and a status of 3 (which indicates that the record is done), or a status of 2 or 4 (which indicates dead records that have passed certain time), for the type of event category that the EventDetectionScheduleController is invoking. If the record has a status of 2, it is considered to be in process, meaning some other thread is already executing business rules for it. If the record has a status of 5, it is considered to be excluded from processing. If the record has a status of 4, this means that the record considered to be in process and a new request for processing was received by Event Manager via the API, while some other thread was already executing business rules for the same entity ID and rules category

The ProcessControllerInternal bean does not do actual event detection. Rather, it places a task object into the JMS queue. The EventDetectorMDB (the message-driven bean) picks up the tasks from the queue and starts processing. Processing the task includes these actions:

  • Calling the business system using an adapter to retrieve the most recent data on the business object
  • Invoking business rules to analyze the data
  • Persisting occurred events
  • Sending notification
  • Resetting the next process date in the PROCESSACTION table.

The new next process date value depends on the result of the business rules. If the rules detect that the business object will have a new event occurring in the near future, one that occurs between now and event horizon, then the new next process date is set to the date of the upcoming event. If multiple events are detected by the rules as future pending events, the date with the nearest future event is selected. If no new events are planned, next process date is set to the event horizon. This way, the future events are never pre-scheduled; rather, the processing of all business rules are rescheduled for the next process date, presuming the future event is going to happen. If the rule is deleted or changed, you do not have to delete pre-scheduled occurrences; that is, no additional maintenance actions are necessary. If the rule has changed or a new rule is added, and there is a possibility that some business objects should be processed sooner than scheduled, the next process date should be reset to today's date to trigger the processing of the newly changed rule. The next process date is determined differently if the status of the record in PROCESSACTION table is 4. This means somebody submitted request for rule detection for this record while the rule was already running. Event Manager will reset the status of the record to 3 and will keep the next process date in the past instead of resetting it to the value requested by business rule or event horizon to make sure the event detection happens again next time you run Event Manager scheduler with this event category.