Class AddSourceRunnable
- java.lang.Object
-
- de.aristaflow.adept2.core.eventmanager.common.AddSourceRunnable
-
- All Implemented Interfaces:
Runnable
public class AddSourceRunnable extends Object implements Runnable
ARunnable
for adding an event source for a specific worklist item. Since problems when adding an event source are rather common, thisAddSourceRunnable
reschedules itself for retrying several times.
The number of retries as well as the time between retries can be configured per activity. If an activity configuration does not provide a corresponding value, the defaults configured for the event manager will be used. If all retries have been unsuccessful, the activity will be failed.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
currentRun
The number of times the event source has been tried to add.static long
EVENT_SOURCE_ADDING_FAILED_CODE
Code for adding the event source failed finally.static String
EVENT_SOURCE_ADDING_FAILED_STATE
State for adding the event source failed finally.protected AbstractEventManager
eventManager
The event manager which to use for starting and selecting the activity as well as eventually adding the event source.protected ScheduledObjectOneWorkExecutor<WorklistItem>
executor
The executor for rescheduling event source adders in case adding the event source fails (again).protected de.aristaflow.adept2.core.automaticclient.AbstractWorklistHandler
handler
The worklist handler for re-retrieving the worklist item.protected Logger
logger
The logger of this runnable.protected int
retries
The maximum number of tries to add the event source before the corresponding activity will be failed.protected long
retryDelay
The time in milliseconds before retrying to add the event source.protected Map<EBPInstanceReference,Triple<String,String,String>>
runningItems
The activities currently being added and the ones currently being polled.protected ClientWorklistItem
worklistItem
The worklist item for which to add an event source.
-
Constructor Summary
Constructors Constructor Description AddSourceRunnable(ClientWorklistItem item, int retries, long retryDelay, de.aristaflow.adept2.core.automaticclient.AbstractWorklistHandler handler, Map<EBPInstanceReference,Triple<String,String,String>> runningItems, ScheduledObjectOneWorkExecutor<WorklistItem> executor, AbstractEventManager eventManager, LogService logService)
Creates a newAddSourceRunnable
for adding event sources for specific worklist items.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Triple<Throwable,Integer,Long>
addEventSource(WorklistItem item)
Adds an event source for the designated worklist item, that is the session context of the activity is retrieved by starting or resuming the item, an event source is created by the appropriate event manager and the event handler is initialised and added.void
run()
-
-
-
Field Detail
-
EVENT_SOURCE_ADDING_FAILED_STATE
public static final String EVENT_SOURCE_ADDING_FAILED_STATE
State for adding the event source failed finally.- See Also:
- Constant Field Values
-
EVENT_SOURCE_ADDING_FAILED_CODE
public static final long EVENT_SOURCE_ADDING_FAILED_CODE
Code for adding the event source failed finally.- See Also:
- Constant Field Values
-
logger
protected final Logger logger
The logger of this runnable.
-
worklistItem
protected final ClientWorklistItem worklistItem
The worklist item for which to add an event source.
-
handler
protected final de.aristaflow.adept2.core.automaticclient.AbstractWorklistHandler handler
The worklist handler for re-retrieving the worklist item.
-
runningItems
protected final Map<EBPInstanceReference,Triple<String,String,String>> runningItems
The activities currently being added and the ones currently being polled. The EBP instance references are mapped to the corresponding execution session. The execution session will benull
while the event source is being added for the corresponding activity.
-
executor
protected final ScheduledObjectOneWorkExecutor<WorklistItem> executor
The executor for rescheduling event source adders in case adding the event source fails (again).
-
eventManager
protected final AbstractEventManager eventManager
The event manager which to use for starting and selecting the activity as well as eventually adding the event source.
-
retryDelay
protected long retryDelay
The time in milliseconds before retrying to add the event source.
This will be set to the value configured for the event manager until the activity configuration is available. Afterwards it will use the value from the activity configuration if this provides a value.
-
currentRun
protected int currentRun
The number of times the event source has been tried to add. This is incremented before a try to add the event source.
-
retries
protected int retries
The maximum number of tries to add the event source before the corresponding activity will be failed.
This will be set to the value configured for the event manager until the activity configuration is available. Afterwards it will use the value from the activity configuration if this provides a value.
-
-
Constructor Detail
-
AddSourceRunnable
public AddSourceRunnable(ClientWorklistItem item, int retries, long retryDelay, de.aristaflow.adept2.core.automaticclient.AbstractWorklistHandler handler, Map<EBPInstanceReference,Triple<String,String,String>> runningItems, ScheduledObjectOneWorkExecutor<WorklistItem> executor, AbstractEventManager eventManager, LogService logService)
Creates a newAddSourceRunnable
for adding event sources for specific worklist items.- Parameters:
item
- The worklist item for which to add an event source.retries
- The maximum number of tries to add the event source before the corresponding activity will be failed.retryDelay
- The time in milliseconds before retrying to add the event source.handler
- The worklist handler for re-retrieving the worklist item.runningItems
- The activities currently having an event source or of which the event source is currently being added.executor
- The poll service for rescheduling event source adders in case adding the event source fails (again).eventManager
- The event manager which to use for starting and selecting the activity as well as eventually adding the event source.logService
- The log service to retrieve the logger from.
-
-
Method Detail
-
addEventSource
protected Triple<Throwable,Integer,Long> addEventSource(WorklistItem item)
Adds an event source for the designated worklist item, that is the session context of the activity is retrieved by starting or resuming the item, an event source is created by the appropriate event manager and the event handler is initialised and added.
If there is already a source for a specific worklist item, this method will just returnnull
. In case of an exception, the exception is logged and returned. Additionally, if the activity configuration provides values for retrying to add the event source, these values will also be returned.- Parameters:
item
- The worklist item for which to add an event source.- Returns:
- The throwable that occurred while adding the event source and configuration values for
the retry count and the retry delay if present. The retry configuration values are only
required in case adding fails and we have a throwable. However, they will be
null
if they are not provided by the activity configuration.
If the worklist item already has an event source,null
will be returned.
-
-