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 Type
    Method
    Description
    void
    Registers a state observer.
    <T extends OutboundSyncEvent>
    void
    applyEvent(T event)
    Applies an event and recalculates state of the context outbound sync job.
    Retrieves the current state of the context job.
    default @NotNull OutboundSyncState
    Retrieves state of the context job after the last event was applied.
    default @NotNull PK
    Retrieves identifier of this outbound sync job.
    default void
    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

      @NotNull default @NotNull PK getId()
      Retrieves identifier of this outbound sync job. The default implementation in this interface always returns PK.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

      <T extends OutboundSyncEvent> void applyEvent(@NotNull T event)
      Applies an event and recalculates state of the context outbound sync job.
      Parameters:
      event - a job state changing event.
    • getCurrentState

      @NotNull @NotNull OutboundSyncState getCurrentState()
      Retrieves the current state of the context job.
      Returns:
      current state of the context outbound sync job.
    • addStateObserver

      void addStateObserver(@NotNull @NotNull OutboundSyncStateObserver observer)
      Registers a state observer.
      Parameters:
      observer - an observer that is going to be notified whenever the job state changes.
    • getFinalState

      @NotNull default @NotNull OutboundSyncState 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's PerformResult

      Default implementation in this interface does nothing, meaning the job won't be stopped by default. Implementations of this interface must implement the stop() logic.