SAP Knowledge Base Article - Preview

3488101 - How the Spring Integration Message Channel Interceptors work for Cloud Hot Folder


This KBA explains how the Spring Integration Message Channel Interceptor work for the Cloud Hot folder in Commerce Cloud environment.

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"
<int:poller fixed-rate="${}"

Channel Interceptors
In all the recent Commerce Cloud extension versions (>1811) this channel interceptors were introduced to provide similar functionality of the poller transactions (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">
       <ref bean="azureHotFolderRoutingChannelInterceptor"/>
<bean id="azureHotFolderRoutingChannelInterceptor" class="">
    <property name="successChannel" ref="azureArchiveOutboundChannelAdapter"/>
    <property name="failureChannel" ref="azureErrorOutboundChannelAdapter"/>
In the bean class "", 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
    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);
            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


<int:transaction-synchronization-factory id="defaultAzureSynchronizationFactory">
<int:after-commit channel="nullChannel"/>
<int:after-rollback channel="nullChannel"/>


<!--Provide a header to support the new and preferred way of providing archive and error functionality using channel interceptors.-->
<int:header-enricher id="cloudHotfolderInboundFileNameHeaderEnricherChannel"
<int:header name="#{fileNameHeaderKey}" expression="payload.getName()"/>
<int:header name="#{fileLastModifiedHeaderKey}" expression="payload.lastModified()"/>



SAP Commerce Cloud


SAP Commerce Cloud all versions


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.