Class DefaultOutboundSyncService

java.lang.Object
de.hybris.platform.outboundsync.activator.impl.DefaultOutboundSyncService
All Implemented Interfaces:
OutboundSyncService

public class DefaultOutboundSyncService extends Object implements OutboundSyncService
Default implementation of OutboundSyncService that uses OutboundServiceFacade for sending changes to the destinations.
  • Constructor Details

  • Method Details

    • sync

      public void sync(Collection<OutboundItemDTO> outboundItemDTOs)
      Description copied from interface: OutboundSyncService
      Consumes a DTO with the item changed information and handles the message based on the change type.
      Specified by:
      sync in interface OutboundSyncService
      Parameters:
      outboundItemDTOs - A collection of DTOs with the information about the changes in the item.
    • syncBatch

      public void syncBatch(Collection<OutboundItemDTOGroup> outboundItemDTOGroups)
      Description copied from interface: OutboundSyncService
      Consumes all DTOs and handles the message for each item based on the change type.
      Specified by:
      syncBatch in interface OutboundSyncService
      Parameters:
      outboundItemDTOGroups - An entity holding information about the changed items for a single batch request
    • handleError

      protected void handleError(OutboundItemDTOGroup outboundItemDTOGroup)
    • handleResponse

      protected void handleResponse(org.springframework.http.ResponseEntity<Map> responseEntity, OutboundItemDTOGroup outboundItemDTOGroup)
    • handleSuccessfulSync

      protected void handleSuccessfulSync(OutboundItemDTOGroup outboundItemDTOGroup)
    • getOutboundServiceFacade

      public OutboundServiceFacade getOutboundServiceFacade()
      Retrieves implementation of the OutboundServiceFacade being used by this service.
      Returns:
      implementation of the outbound facade being used to send items to an external system.
    • setOutboundServiceFacade

      public void setOutboundServiceFacade(@NotNull @NotNull OutboundServiceFacade facade)
      Injects an outbound service facade to be used for sending the items to an external system.
      Parameters:
      facade - facade implementation to use.
    • setSyncRetryService

      public void setSyncRetryService(@NotNull @NotNull SyncRetryService service)
      Injects implementation of the retry service to manage retries when outbound sync was not successful.
      Parameters:
      service - an implementation of the service to use.
    • syncInternal

      protected void syncInternal(PK cronJobPk, Collection<OutboundItemDTOGroup> groups, de.hybris.platform.outboundsync.activator.impl.BaseOutboundSyncService.Synchronizer synchronizer)
      This method checks the cronjob is in the appropriate state before calling the BaseOutboundSyncService.Synchronizer.

      Here are the rules:

      • If the job is aborting, an abort event is published. No synchronization will occur.
      • If the job is in system error state, an system error event is published. No synchronization will occur.
      • If the job is not aborted and not in system error state, synchronization will occur.
      Parameters:
      cronJobPk - PK of the cronjob being executed
      groups - collection of groups of items being synchronized
      synchronizer - Synchronizer to execute when the cronjob is in the appropriate state
    • syncInternal

      protected void syncInternal(PK cronJobPk, OutboundItemDTOGroup group, de.hybris.platform.outboundsync.activator.impl.BaseOutboundSyncService.Synchronizer synchronizer)
    • publishSystemErrorEvent

      protected void publishSystemErrorEvent(PK cronJobPk, OutboundItemDTOGroup group)
      Publish then SystemErrorOutboundSyncEvent if a system error occurs
      Parameters:
      cronJobPk - PK of the cronjob being executed
      group - group of the items, for which were not processed because of a systemic problem with the outbound sync.
    • publishSystemErrorEvent

      protected void publishSystemErrorEvent(PK cronJobPk, Collection<OutboundItemDTOGroup> groups)
    • publishSuccessfulCompletedEvent

      protected void publishSuccessfulCompletedEvent(OutboundItemDTOGroup group)
      Publish the CompletedOutboundSyncEvent with success set to true when the synchronization is done
      Parameters:
      group - a group of items successfully synchronized
    • publishUnSuccessfulCompletedEvent

      protected void publishUnSuccessfulCompletedEvent(Collection<OutboundItemDTOGroup> groups)
      Publish the CompletedOutboundSyncEvent with success set to false when the synchronization is done
      Parameters:
      groups - a group of items that failed to be synchronized
    • publishUnSuccessfulCompletedEvent

      protected void publishUnSuccessfulCompletedEvent(OutboundItemDTOGroup group)
    • findItemByPk

      protected <T extends ItemModel> Optional<T> findItemByPk(PK pk)
    • asItemGroup

      protected OutboundItemDTOGroup asItemGroup(OutboundItemDTO item)
    • asItemGroup

      protected OutboundItemDTOGroup asItemGroup(Collection<OutboundItemDTO> items)
    • consumeChanges

      protected void consumeChanges(OutboundItemDTOGroup outboundItemDTOGroup)
    • consumeChange

      protected void consumeChange(OutboundItemDTO item)
    • setOutboundItemFactory

      @Deprecated(since="2205", forRemoval=true) public void setOutboundItemFactory(@NotNull @NotNull OutboundItemFactory factory)
      Deprecated, for removal: This API element is subject to removal in a future version.
      not preferred anymore. If the dependency is needed it should be injected into the concrete service class.
      Injects implementation of the OutboundItemFactory to be passed into the OutboundItemDTOGroup created by this service.
      Parameters:
      factory - an implementation of the outbound item factory to be used in this service
    • getOutboundItemConsumer

      public OutboundItemConsumer getOutboundItemConsumer()
      Retrieves the change consumer used to clear changes in the delta detect module when the change is successfully synchronized or should be ignored.
      Returns:
      changes consumer user by this service
    • setOutboundItemConsumer

      public void setOutboundItemConsumer(OutboundItemConsumer consumer)
      Injects a change consumer, which clears changes in the delta detect module when the change is successfully synchronized or should be ignored. If item consumer is not injected, the changes won't be consumed and therefore custom implementation need to manage delta detect changes themselves.
      Parameters:
      consumer - an implementation of the change consumer to use.
    • setEventService

      public void setEventService(EventService service)
      Injects implementation of the EventService to use for publishing outbound sync job events. If the event services is not injected, the outbound sync events won't be fired. Although, this dependency is optional, current implementation of the outbound sync heavily relies on the outbound sync events being fired. If a customization, decides not to inject this service, it has to manage events delivery to OutboundSyncJobStateAggregator in a customer way to maintain correct functionality.
      Parameters:
      service - a service to use for publishing events
    • setItemModelSearchService

      @Deprecated(since="2205", forRemoval=true) public void setItemModelSearchService(@NotNull @NotNull ItemModelSearchService service)
      Deprecated, for removal: This API element is subject to removal in a future version.
      not preferred anymore. Inject the ItemModelSearchService through constructor
      Injects implementation of the ItemModelSearchService to be used for searching model instances by PK. If this method is not called then, ItemModelSearchService configured in "itemModelSearchService" Spring bean will be used by default.
      Parameters:
      service - an implementation to use.
    • setJobRegister

      @Deprecated(since="2205", forRemoval=true) public void setJobRegister(@NotNull @NotNull OutboundSyncJobRegister register)
      Deprecated, for removal: This API element is subject to removal in a future version.
      not preferred anymore. Inject the OutboundSyncJobRegister through constructor
      Injects specific OutboundSyncJobRegister implementation.
      Parameters:
      register - an implementation to use