Handling various events of Adapter

Tags:

Updated:

1 minute read

APPSeCONNECT provides a number of events which you as a developer can hook into, to write code specially when the execution stops at a particular event. Let us take a look at some of the events which appseconnect adapter development environment provides :

EventName EventDescription Used from
TaskStarted The event will allow the adapter to track each individual integration start method Initialize block
TaskCompleted The event will be generated when any integration task is completed Initialize block
WorkflowStarted The event is raised when a dependency workflow is triggered Initialize block
WorkflowCompleted The event is raised when a dependency workflow is complete Initialize block
TransformEventHandler The event is raised after transformation Initialize block
RealtimeProcessingStarted The event is raised when Realtime engine gets a request for processing Initialize block
RealtimeProcessingEnd The event is raised when a realtime engine executed a request Initialize block

The events are raised whenever the special event occurs during execution of an integration.

To implement the event, it is recommended to use the Initialize method of IAdapter interface, if not otherwise, so as to ensure the event is not hooked more than once.


public void Initialize(ApplicationContext context)
{
    this._context = context;
    this._resource = new AppResource(context);

    context.TaskCompleted += Context_TaskCompleted;
}

private void Context_TaskCompleted(IAdapter sourceAdapter, IAdapter destinationAdapter, ExecutionSettings currentExecutionObject)
{
    // your code goes here connecting both the adapters.
}

Here in the Initialize method of IAdapter interface, we have hooked the event TaskCompleted, the method will automatically get executed after the execution is completed. By completion, we mean that the data transferred correctly from Source to Target application.

Generally we store the data late when we are not sure whether the data is available beforehand.