Class DefaultOutboundSyncService
java.lang.Object
de.hybris.platform.outboundsync.activator.impl.DefaultOutboundSyncService
- All Implemented Interfaces:
OutboundSyncService
Default implementation of
OutboundSyncService that uses OutboundServiceFacade for sending changes to the
destinations.-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.DefaultOutboundSyncService(@NotNull ItemModelSearchService searchService, @NotNull OutboundItemFactory factory, @NotNull OutboundSyncJobRegister register, @NotNull OutboundServiceFacade facade) Deprecated, for removal: This API element is subject to removal in a future version.UseDefaultOutboundSyncService(ItemModelSearchService, OutboundItemFactory, OutboundSyncJobRegister, OutboundServiceFacade, OutboundMultiPartResponseParser)to instantiates this outbound sync service.DefaultOutboundSyncService(@NotNull ItemModelSearchService searchService, @NotNull OutboundItemFactory factory, @NotNull OutboundSyncJobRegister register, @NotNull OutboundServiceFacade facade, @NotNull OutboundMultiPartResponseParser responseParser) Instantiates this outbound sync service. -
Method Summary
Modifier and TypeMethodDescriptionprotected OutboundItemDTOGroupasItemGroup(OutboundItemDTO item) protected OutboundItemDTOGroupasItemGroup(Collection<OutboundItemDTO> items) protected voidconsumeChange(OutboundItemDTO item) protected voidconsumeChanges(OutboundItemDTOGroup outboundItemDTOGroup) findItemByPk(PK pk) protected ModelServiceDeprecated, for removal: This API element is subject to removal in a future version.This method will be removed without alternativeRetrieves the change consumer used to clear changes in the delta detect module when the change is successfully synchronized or should be ignored.Retrieves implementation of theOutboundServiceFacadebeing used by this service.protected voidhandleError(OutboundItemDTOGroup outboundItemDTOGroup) protected voidhandleResponse(org.springframework.http.ResponseEntity<Map> responseEntity, OutboundItemDTOGroup outboundItemDTOGroup) protected voidhandleSuccessfulSync(OutboundItemDTOGroup outboundItemDTOGroup) protected voidPublish theCompletedOutboundSyncEventwith success set to true when the synchronization is doneprotected voidpublishSystemErrorEvent(PK cronJobPk, OutboundItemDTOGroup group) Publish thenSystemErrorOutboundSyncEventif a system error occursprotected voidpublishSystemErrorEvent(PK cronJobPk, Collection<OutboundItemDTOGroup> groups) protected voidprotected voidPublish theCompletedOutboundSyncEventwith success set to false when the synchronization is donevoidsetEventService(EventService service) Injects implementation of theEventServiceto use for publishing outbound sync job events.voidsetItemModelSearchService(@NotNull ItemModelSearchService service) Deprecated, for removal: This API element is subject to removal in a future version.not preferred anymore.voidsetJobRegister(@NotNull OutboundSyncJobRegister register) Deprecated, for removal: This API element is subject to removal in a future version.not preferred anymore.voidsetModelService(ModelService modelService) Deprecated, for removal: This API element is subject to removal in a future version.UseItemModelSearchServiceinstead and inject it through the constructorvoidsetOutboundItemConsumer(OutboundItemConsumer consumer) Injects a change consumer, which clears changes in the delta detect module when the change is successfully synchronized or should be ignored.voidsetOutboundItemFactory(@NotNull OutboundItemFactory factory) Deprecated, for removal: This API element is subject to removal in a future version.not preferred anymore.voidsetOutboundServiceFacade(@NotNull OutboundServiceFacade facade) Injects an outbound service facade to be used for sending the items to an external system.voidsetSyncRetryService(@NotNull SyncRetryService service) Injects implementation of the retry service to manage retries when outbound sync was not successful.voidsync(Collection<OutboundItemDTO> outboundItemDTOs) Consumes a DTO with the item changed information and handles the message based on the change type.voidsyncBatch(Collection<OutboundItemDTOGroup> outboundItemDTOGroups) Consumes all DTOs and handles the message for each item based on the change type.protected voidsyncInternal(PK cronJobPk, OutboundItemDTOGroup group, de.hybris.platform.outboundsync.activator.impl.BaseOutboundSyncService.Synchronizer synchronizer) protected voidsyncInternal(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 theBaseOutboundSyncService.Synchronizer.
-
Constructor Details
-
DefaultOutboundSyncService
Deprecated, for removal: This API element is subject to removal in a future version.Use the constructor with dependencies to inject parametersDefaultOutboundSyncService(ItemModelSearchService, OutboundItemFactory, OutboundSyncJobRegister, OutboundServiceFacade, OutboundMultiPartResponseParser)Instantiates this service. Uses default implementations available in the application context for the required dependencies. Not required dependencies will not be injected after this service is instantiated. They need to be injected separately by calling the correspondingset...()methods.- See Also:
-
BaseOutboundSyncService.setOutboundItemFactory(OutboundItemFactory)BaseOutboundSyncService.setItemModelSearchService(ItemModelSearchService)BaseOutboundSyncService.setEventService(EventService)BaseOutboundSyncService.setOutboundItemConsumer(OutboundItemConsumer)setOutboundServiceFacade(OutboundServiceFacade)setSyncRetryService(SyncRetryService)
-
DefaultOutboundSyncService
@Deprecated(since="2211", forRemoval=true) public DefaultOutboundSyncService(@NotNull @NotNull ItemModelSearchService searchService, @NotNull @NotNull OutboundItemFactory factory, @NotNull @NotNull OutboundSyncJobRegister register, @NotNull @NotNull OutboundServiceFacade facade) Deprecated, for removal: This API element is subject to removal in a future version.UseDefaultOutboundSyncService(ItemModelSearchService, OutboundItemFactory, OutboundSyncJobRegister, OutboundServiceFacade, OutboundMultiPartResponseParser)to instantiates this outbound sync service.- Parameters:
searchService- Service to search for item modelsfactory- A factory implementation to create instances ofOutboundItemregister- Service to use for inquirying about currently running outbound sync jobsfacade- An implementation of the facade to send changes through
-
DefaultOutboundSyncService
public DefaultOutboundSyncService(@NotNull @NotNull ItemModelSearchService searchService, @NotNull @NotNull OutboundItemFactory factory, @NotNull @NotNull OutboundSyncJobRegister register, @NotNull @NotNull OutboundServiceFacade facade, @NotNull @NotNull OutboundMultiPartResponseParser responseParser) Instantiates this outbound sync service.- Parameters:
searchService- Service to search for item modelsfactory- A factory implementation to create instances ofOutboundItemregister- Service to use for inquirying about currently running outbound sync jobsfacade- An implementation of the facade to send changes throughresponseParser- Batch response parser
-
-
Method Details
-
sync
Description copied from interface:OutboundSyncServiceConsumes a DTO with the item changed information and handles the message based on the change type.- Specified by:
syncin interfaceOutboundSyncService- Parameters:
outboundItemDTOs- A collection of DTOs with the information about the changes in the item.
-
syncBatch
Description copied from interface:OutboundSyncServiceConsumes all DTOs and handles the message for each item based on the change type.- Specified by:
syncBatchin interfaceOutboundSyncService- Parameters:
outboundItemDTOGroups- An entity holding information about the changed items for a single batch request
-
handleError
-
handleResponse
protected void handleResponse(org.springframework.http.ResponseEntity<Map> responseEntity, OutboundItemDTOGroup outboundItemDTOGroup) -
handleSuccessfulSync
-
getModelService
Deprecated, for removal: This API element is subject to removal in a future version.This method will be removed without alternative -
setModelService
Deprecated, for removal: This API element is subject to removal in a future version.UseItemModelSearchServiceinstead and inject it through the constructor -
getOutboundServiceFacade
Retrieves implementation of theOutboundServiceFacadebeing used by this service.- Returns:
- implementation of the outbound facade being used to send items to an external system.
-
setOutboundServiceFacade
Injects an outbound service facade to be used for sending the items to an external system.- Parameters:
facade- facade implementation to use.
-
setSyncRetryService
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 theBaseOutboundSyncService.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 executedgroups- collection of groups of items being synchronizedsynchronizer- 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
Publish thenSystemErrorOutboundSyncEventif a system error occurs- Parameters:
cronJobPk- PK of the cronjob being executedgroup- group of the items, for which were not processed because of a systemic problem with the outbound sync.
-
publishSystemErrorEvent
-
publishSuccessfulCompletedEvent
Publish theCompletedOutboundSyncEventwith success set to true when the synchronization is done- Parameters:
group- a group of items successfully synchronized
-
publishUnSuccessfulCompletedEvent
Publish theCompletedOutboundSyncEventwith success set to false when the synchronization is done- Parameters:
groups- a group of items that failed to be synchronized
-
publishUnSuccessfulCompletedEvent
-
findItemByPk
-
asItemGroup
-
asItemGroup
-
consumeChanges
-
consumeChange
-
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 theOutboundItemFactoryto be passed into theOutboundItemDTOGroupcreated by this service.- Parameters:
factory- an implementation of the outbound item factory to be used in this service
-
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
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
Injects implementation of theEventServiceto 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 toOutboundSyncJobStateAggregatorin 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 theItemModelSearchServicethrough constructorInjects implementation of theItemModelSearchServiceto be used for searching model instances by PK. If this method is not called then,ItemModelSearchServiceconfigured 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 theOutboundSyncJobRegisterthrough constructorInjects specificOutboundSyncJobRegisterimplementation.- Parameters:
register- an implementation to use
-
DefaultOutboundSyncService(ItemModelSearchService, OutboundItemFactory, OutboundSyncJobRegister, OutboundServiceFacade, OutboundMultiPartResponseParser)