Symptom
How the Spring Integration Message Channel Interceptor work for the Cloud Hot Folder:
Channel Adapter
In OOTB Commerce Cloud extensions, a "channel adapter" is configured for the hot folder inbound channel "cloudHotfolderInboundFileHeaderEnricherChannel".
The code resides in /azurecloudhotfolder/resources/azurecloudhotfolder-spring.xml :
<int:inbound-channel-adapter id="azureInboundChannelAdapter" auto-startup="false" role="${cloud.hotfolder.storage.services.role}" phase="50" ref="azureBlobSynchronizingMessageSource" channel="cloudHotfolderInboundFileHeaderEnricherChannel"> <int:poller fixed-rate="${azure.hotfolder.storage.polling.fixed.rate}" task-executor="azureChannelAdapterTaskExecutor" max-messages-per-poll="${azure.hotfolder.storage.polling.fetch.batch-size}"/> </int:inbound-channel-adapter>
|
Channel Interceptors
In all the recent SAP Commerce Cloud extension versions this channel interceptors were introduced to provide similar functionality of the poller transaction
s (transactional-synchronization-factory & Tx manager) which was the "old design" to handle the "error" and "archive" blob items. Channel interceptors are non invasive and performs better than the previous Tx Manager.
The configuration can be found in /azurecloudhotfolder/resources/azurecloudhotfolder-spring.xml:
<!--A channel interceptor against the header used in the azure messaging flow for supporting archive and error functionality--> <int:channel id="cloudHotfolderInboundFileHeaderEnricherChannel"> <int:interceptors> <ref bean="azureHotFolderRoutingChannelInterceptor"/> </int:interceptors> </int:channel>
<bean id="azureHotFolderRoutingChannelInterceptor" class="de.hybris.platform.cloud.hotfolder.interceptor.HotFolderRouterChannelInterceptor"> <property name="successChannel" ref="azureArchiveOutboundChannelAdapter"/> <property name="failureChannel" ref="azureErrorOutboundChannelAdapter"/> </bean>
|
In the bean class "de.hybris.platform.cloud.hotfolder.interceptor.HotFolderRouterChannelInterceptor", below method will be invoked after the Channel send() and receive() calls, regardless of any exception that is raised. It allows us to direct to Message on to a success or failure channel.
/* * @param message the message * @param interceptedMessageChannel the channel we've intercepted * @param sent whether the message was successfully sent on channel interceptedMessageChannel * @param ex any exceptions */ @Override public void afterSendCompletion(final Message<?> message, final MessageChannel interceptedMessageChannel, final boolean sent, final Exception ex) { if (ex == null) { this.messagingTemplate.send(this.successChannel, message); LOG.debug("Message [{}] sent to successChannel [{}]", message, successChannel); } else { LOG.error("An exception occurred during downstream file processing for message [{}]. Exception [{}].", message, ex); this.messagingTemplate.send(this.failureChannel, message); LOG.debug("Message [{}] sent to failureChannel [{}]", message, failureChannel); } }
|
Backwards Compatible
Below configuration provides a backwards compatible synchronization factory, routing existing configuration using transaction manager supported archive and error functionality, to the null channel.
This avoids duplication of items in the archive and error folders which are now supported througha channel interceptor on the poller configured output channel - the cloud header enricher
/azurecloudhotfolder/resources/azurecloudhotfolder-spring.xml:
<int:transaction-synchronization-factory id="defaultAzureSynchronizationFactory"> <int:after-commit channel="nullChannel"/> <int:after-rollback channel="nullChannel"/> </int:transaction-synchronization-factory>
|
/cloudhotfolder/integration/hot-folder-file-routing-spring.xml:
<!--Provide a header to support the new and preferred way of providing archive and error functionality using channel interceptors.--> <int:header-enricher id="cloudHotfolderInboundFileNameHeaderEnricherChannel" input-channel="cloudHotfolderInboundFileHeaderEnricherChannel" output-channel="hotfolderInboundFileChannel"> <int:header name="#{fileNameHeaderKey}" expression="payload.getName()"/> <int:header name="#{fileLastModifiedHeaderKey}" expression="payload.lastModified()"/> </int:header-enricher>
|
Read more...
Environment
Product
SAP Commerce Cloud all versions
Keywords
Cloud Hot folder, channel, channel interceptor , KBA , CEC-SCC-CLA-ENV-CST , Cloud Storage , How To
About this page
This is a preview of a SAP Knowledge Base Article. Click
more to access the full version on SAP for Me (Login
required).
Search for additional results
Visit SAP Support Portal's SAP Notes and KBA Search.