Interface OutboundSyncJob
- All Known Implementing Classes:
OutboundSyncJobStateAggregator
public interface OutboundSyncJob
An object controlling and representing state of a single outbound sync job. Implementations make decisions about whether the
job is finished and what's the result of the job execution.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddStateObserver(@NotNull OutboundSyncStateObserver observer) Registers a state observer.<T extends OutboundSyncEvent>
voidapplyEvent(T event) Applies an event and recalculates state of the context outbound sync job.@NotNull OutboundSyncStateRetrieves the current state of the context job.default @NotNull OutboundSyncStateRetrieves state of the context job after the last event was applied.default @NotNull PKgetId()Retrieves identifier of this outbound sync job.default voidstop()Forces this job to stop, so that it changes its status to FINISHED, even if its state does not show that all expected items have been processed.
-
Method Details
-
getId
Retrieves identifier of this outbound sync job. The default implementation in this interface always returnsPK.fromLong(0), so this method must be overridden by the implementation to provide correct behavior.- Returns:
- identifier of this job, i.e. a value that differs one outbound sync job from the other: for example, a customer synchronization from product synchronization. Therefore, this ID should persist for different executions of the same job.
-
applyEvent
Applies an event and recalculates state of the context outbound sync job.- Parameters:
event- a job state changing event.
-
getCurrentState
Retrieves the current state of the context job.- Returns:
- current state of the context outbound sync job.
-
addStateObserver
Registers a state observer.- Parameters:
observer- an observer that is going to be notified whenever the job state changes.
-
getFinalState
Retrieves state of the context job after the last event was applied.- Returns:
- final state of the context outbound sync job.
-
stop
default void stop()Forces this job to stop, so that it changes its status to FINISHED, even if its state does not show that all expected items have been processed. This means that changes processed by this job may continue being synchronized, but result of their synchronization may be ignored and not reported in the job'sPerformResultDefault implementation in this interface does nothing, meaning the job won't be stopped by default. Implementations of this interface must implement the
stop()logic.
-