Simple implementation and base class for batch templates implementing RepeatOperations. Provides a framework including interceptors and policies. Subclasses just need to provide a method that gets the next result and one that waits for all the results to be returned from concurrent processes or threads. More...
Public Member Functions | |
void | SetListeners (IRepeatListener[] listeners) |
Registers array of listeners. More... | |
void | RegisterListener (IRepeatListener listener) |
Registers given listener. More... | |
RepeatStatus | Iterate (RepeatCallback callback) |
Execute the batch callback until the completion policy decides that we are finished. Wait for the whole batch to finish before returning even if the task executor is asynchronous. More... | |
Protected Member Functions | |
IRepeatContext | Start () |
Delegates the start to the Completion policy. More... | |
bool | CanContinue (RepeatStatus value) |
Check return value from batch operation. More... | |
virtual IRepeatInternalState | CreateInternalState (IRepeatContext context) |
Create an internal state object that is used to store data needed internally in the scope of an iteration. Used by subclasses to manage the queueing and retrieval of asynchronous results. The default just provides an accumulation of exceptions instances for processing at the end of the batch. More... | |
void | Update (IRepeatContext context) |
Delegates to the completion policy. More... | |
virtual RepeatStatus | GetNextResult (IRepeatContext context, RepeatCallback callback, IRepeatInternalState state) |
Get the next completed result, possibly executing several callbacks until one finally finishes. Normally a subclass would have to override both this method and CreateInternalState because the implementation of this method would rely on the details of the internal state. More... | |
virtual bool | WaitForResults (IRepeatInternalState state) |
If necessary, wait for results to come back from remote or concurrent processes. By default does nothing and returns true. More... | |
void | ExecuteAfterInterceptors (IRepeatContext context, RepeatStatus value) |
Convenience method to execute after interceptors on a callback result. More... | |
bool | IsComplete (IRepeatContext context, RepeatStatus result) |
Delegates to the Completion policy. More... | |
bool | IsComplete (IRepeatContext context) |
Delegates to the Completion policy. More... | |
Static Protected Attributes | |
static readonly Logger | Logger = LogManager.GetCurrentClassLogger() |
Logger More... | |
Properties | |
ICompletionPolicy | CompletionPolicy [set] |
Completion policy property. More... | |
IExceptionHandler | ExceptionHandler [set] |
Exception handler property. More... | |
Detailed Description
Simple implementation and base class for batch templates implementing RepeatOperations. Provides a framework including interceptors and policies. Subclasses just need to provide a method that gets the next result and one that waits for all the results to be returned from concurrent processes or threads.
N.B. the template accumulates thrown exceptions during the iteration, and they are all processed together when the main loop ends (i.e. finished processing the items). Clients that do not want to stop execution when an exception is thrown can use a specific ICompletionPolicy that does not finish when exceptions are received. This is not the default behaviour. Clients that want to take some business action when an exception is thrown by the IRepeatCallback can consider using a custom IRepeatListener instead of trying to customise the ICompletionPolicy. This is generally a friendlier interface to implement, and the IRepeatListener::After(RepeatContext, RepeatStatus) method is passed in the result of the callback, which would be an instance of Exception if the business processing had thrown an exception. If the exception is not to be propagated to the caller, then a non-default ICompletionPolicy needs to be provided as well, but that could be off the shelf, with the business action implemented only in the interceptor.
Member Function Documentation
|
protected |
Check return value from batch operation.
- Parameters
-
value
- Returns
|
protectedvirtual |
Create an internal state object that is used to store data needed internally in the scope of an iteration. Used by subclasses to manage the queueing and retrieval of asynchronous results. The default just provides an accumulation of exceptions instances for processing at the end of the batch.
- Parameters
-
context
- Returns
Reimplemented in Summer.Batch.Infrastructure.Repeat.Support.TaskExecutorRepeatTemplate.
|
protected |
Convenience method to execute after interceptors on a callback result.
- Parameters
-
context value
|
protectedvirtual |
Get the next completed result, possibly executing several callbacks until one finally finishes. Normally a subclass would have to override both this method and CreateInternalState because the implementation of this method would rely on the details of the internal state.
- Parameters
-
context callback state
- Returns
- Exceptions
-
Exception
Reimplemented in Summer.Batch.Infrastructure.Repeat.Support.TaskExecutorRepeatTemplate.
|
protected |
Delegates to the Completion policy.
- Parameters
-
context result
- Returns
|
protected |
Delegates to the Completion policy.
- Parameters
-
context
- Returns
RepeatStatus Summer.Batch.Infrastructure.Repeat.Support.RepeatTemplate.Iterate | ( | RepeatCallback | callback | ) |
Execute the batch callback until the completion policy decides that we are finished. Wait for the whole batch to finish before returning even if the task executor is asynchronous.
- Parameters
-
callback
- Returns
Implements Summer.Batch.Infrastructure.Repeat.IRepeatOperations.
void Summer.Batch.Infrastructure.Repeat.Support.RepeatTemplate.RegisterListener | ( | IRepeatListener | listener | ) |
Registers given listener.
- Parameters
-
listener
void Summer.Batch.Infrastructure.Repeat.Support.RepeatTemplate.SetListeners | ( | IRepeatListener[] | listeners | ) |
Registers array of listeners.
- Parameters
-
listeners
|
protected |
Delegates the start to the Completion policy.
- Returns
|
protected |
Delegates to the completion policy.
- Parameters
-
context
|
protectedvirtual |
If necessary, wait for results to come back from remote or concurrent processes. By default does nothing and returns true.
- Parameters
-
state
- Returns
Reimplemented in Summer.Batch.Infrastructure.Repeat.Support.TaskExecutorRepeatTemplate.
Member Data Documentation
|
staticprotected |
Logger
Property Documentation
|
set |
Completion policy property.
|
set |
Exception handler property.
The documentation for this class was generated from the following file:
- Summer.Batch.Infrastructure/Repeat/Support/RepeatTemplate.cs