Tuesday, February 21, 2017

Hotfolder Data Importing in Hybris

The following property values refers to the import and export directories

acceleratorservices.batch.impex.basefolder=${HYBRIS_DATA_DIR}/acceleratorservices/import
acceleratorservices.export.basefolder=${HYBRIS_DATA_DIR}/acceleratorservices/export

The following are the default file name conventions(--.csv

base_product-.csv(base_product-en-1.csv,base_product-en-2.csv etc..)
stock-.csv
price-.csv
merchandise-.csv
media-.csv
customer-.csv
external_tax- .csv

Deconstructing the electronics store hot folder configuration
The hot folder configurations are there in the files hot-folder-store-electronics-spring.xml and hot-folder-spring.xml files.

  1. First step to configure the hot folder details are there(hot-folder-store-electronics-spring.xml) in the inbound-channel-adapter(with id batchFilesElectronics) and that contains the polling interval and the file pattern.
  2. The second step(hot-folder-store-electronics-spring.xml) is to define the outbound-gateway with request channel as the inbound channel adapter id from pervious step (batchFilesElectronics)
  3. The third step(hot-folder-store-electronics-spring.xml) is to configure the service-activator with input channel that is defined in the outbound-gateway's reply-channel(batchFilesElectronicsProc) and output-channel as the batchFilesHeaderInit which is defined in the hot-folder-spring.xml file. Check the hot-folder-spring.xml file for other sequences. Each steps output will be the input for the next step

<file:inbound-channel-adapter id="batchFilesElectronics" directory="#{baseDirectoryElectronics}"
filename-regex="^(.*)-(\d+)\.csv" comparator="fileOrderComparator">
<int:poller fixed-rate="1000" />
</file:inbound-channel-adapter>

<file:outbound-gateway request-channel="batchFilesElectronics" reply-channel="batchFilesElectronicsProc"
directory="#{baseDirectoryElectronics}/processing" delete-source-files="true" />
<int:service-activator input-channel="batchFilesElectronicsProc" output-channel="batchFilesHeaderInit"
ref="electronicsHeaderSetupTask" method="execute" />
<bean id="electronicsHeaderSetupTask" class="de.hybris.platform.acceleratorservices.dataimport.batch.task.HeaderSetupTask">
<property name="catalog" value="electronicsProductCatalog" />
<property name="net" value="false" />
<property name="storeBaseDirectory" ref="baseDirectoryElectronics" />
</bean>

<int:service-activator input-channel="batchFilesHeaderInit" output-channel="batchFilesHeader" ref="headerInitTask"
method="execute" />
<bean id="headerInitTask" class="de.hybris.platform.acceleratorservices.dataimport.batch.task.HeaderInitTask">
<property name="sequenceIdParser" ref="batchSequenceIdParser"/>
<property name="languageParser" ref="batchLanguageParser"/>
<property name="fallbackLanguage" value="en" />
</bean>
<int:service-activator input-channel="batchFilesHeader" output-channel="batchFilesTran" ref="batchTransformerTask"
method="execute" />
<bean id="batchTransformerTask"
class="de.hybris.platform.acceleratorservices.dataimport.batch.task.ImpexTransformerTask"
init-method="initConvertersMap">
<property name="fieldSeparator" value="," />
<property name="encoding" value="UTF-8" />
<property name="linesToSkip" value="0"/>
<property name="cleanupHelper" ref="cleanupHelper" />
</bean>
<int:service-activator input-channel="batchFilesTran" output-channel="batchFilesImp" ref="batchRunnerTask"
method="execute" />
<bean id="batchRunnerTask" class="de.hybris.platform.acceleratorservices.dataimport.batch.task.AbstractImpexRunnerTask">
<property name="sessionService" ref="sessionService" />
<property name="importService" ref="importService" />
<lookup-method name="getImportConfig" bean="importConfig" />
</bean>
<int:service-activator input-channel="batchFilesImp" ref="batchCleanupTask" method="execute" />
<bean id="batchCleanupTask" class="de.hybris.platform.acceleratorservices.dataimport.batch.task.CleanupTask">
<property name="cleanupHelper" ref="cleanupHelper" />
</bean>


The inbound-channel-adapter represents the org.springframework.integration.file.FileReadingMessageSource class. Each 1000 milliseconds the receive() method will be called and the following sequence will be called in the following sequence

file:inbound-channel-adapter id="batchFilesElectronics"
file:outbound-gateway request-channel="batchFilesElectronics" reply- channel="batchFilesElectronicsProc"
int:service-activator input-channel="batchFilesElectronicsProc" output-channel="batchFilesHeaderInit"
int:service-activator input-channel="batchFilesHeaderInit" output-channel="batchFilesHeader"
int:service-activator input-channel="batchFilesHeader" output-channel="batchFilesTran"
int:service-activator input-channel="batchFilesTran" output-channel="batchFilesImp"
int:service-activator input-channel="batchFilesImp" ref="batchCleanupTask"

No comments:

Post a Comment