Question & Answer
Question
Prevent multiple reprocessing of events by removing copies built up in EventQueue.
Cause
In situations where the EventReader can build up a backlog of events (for example: heavy load) there is the potential for the EventReader to recapture the same event multiple times. These are held in the EventReader EventQueue and can lead to unwanted multiple reprocessing of the same event.
Answer
The UpdateEventQueue() function of Impact Policy Language can assist in handling this situation.
The most common action is to use this function to remove any copies of the event currently being processed from the EventQueue. This is achieved by identifying the EventQueue by the name of the EventReader and the event by a unique field value (for example: Identifier) or combination of field values and setting the IsDelete Boolean parameter to True. For example:
- WP = "RemoveDuplicates";
Log(2,ID+WP);
EventReaderName = "OMNIbusEventReader";
Filter = "Identifier = '"+ @Identifier +"'";
IsDelete = True;
NumDeletedEvents = UpdateEventQueue(EventReaderName, Filter, NULL, IsDelete);
Log(3,ID+WP+" Number of duplicate events deleted from EventQueue: "+NumDeletedEvents);
The above example employs a style of logging espoused in the TechNote "Structured logging in Policies" [link below].
When utilised with a flag field to indicate that an event is currently being processed, this tool can prevent the majority of situations that lead to unwanted multiple reprocessing of events. For example:
- ID = "ID_"+ @Serial +"_"+ @StateChange +": ";
WP = "Start";
Log(1,ID+WP);
WP = "RemoveDuplicates";
Log(2,ID+WP);
EventReaderName = "OMNIbusEventReader";
Filter = "Identifier = '"+ @Identifier +"'";
IsDelete = True;
NumDeletedEvents = UpdateEventQueue(EventReaderName, Filter, NULL, IsDelete);
Log(3,ID+WP+" Number of duplicate events deleted from EventQueue: "+NumDeletedEvents);
WP = "MarkEventImpacting";
Log(2,ID+WP);
@ImpactFlag = 2;
Log(3,ID+WP+": @ImpactFlag"+@ImpactFlag);
Please see the TechNotes "Event flagging" [link below] and "Avoiding unwanted event reprocessing" [link below].
Please also see the TechNotes "Event Flagging with Go_NoGo checking" [link below] and "Using EventLocking to help prevent multiple event reprocessing" [link below].
Related Information
Was this topic helpful?
Document Information
Modified date:
17 June 2018
UID
swg21675016