File Processing Channels

Messaging is the foundational pattern of the Spring Integration library. File processing channels provide endpoints that accept a message, perform some processing on it, and then pass the processed message to the next channel. Message attributes dictate how information flows through the processing channels.

After synchronization and sorting, the Spring Integration creates one message per file or ZIP folder. The headers of the message contain the file name and the time of the last modification. The file name is used to route the message to the appropriate message channel. The last modified time is used for monitoring. The message is routed using a HeaderValueRouter and the custom class PatternMatchingDestinationResolver.

Base Class/Interface Extension Class/Interface Explanation
org.springframework.messaging.core.DestinationResolver cloudcommons PatternMatchingDestinationResolver Attempts to locate a destination by checking if any pattern matches the required name. Otherwise, it delegates to another DestinationResolver implementation as a fallback mechanism.

The route through file processing channels is demonstrated in the following image.

Default File Processing Channels

By default, the Cloud Hot Folder adapter attempts to import any file with a name that doesn’t start with ignore. Once the file is copied from the Blob store to the 'leader' processing node, the adapter uses a configuration map to decide which hot folder flow to use to process the file. You can add entries to this configuration map to instruct the adapter to deliver files to custom flows.

There are three default channels that route files for Cloud Hot Folders:
  • Default Mapping Channel (batchFileCloudHotFolderDefaultProc)
  • Unzip Channel (cloudHotFolderUnzipChannel)
  • Unmapped Channel (unmappedHotFolderChannel)
You can add more channels, if needed. Use the file name patterns to map to a channel. The file name mapping strategy uses regular expressions to determine where a file is processed.
  • Default Mapping Channel: ^(customer|product|url_media)-\\d+.*
  • Unzip Channel: ^(?:.*)\.(?i)(zip)$

Mappings are controlled through a Spring Map bean. The bean includes a key (Pattern) and value (MessageChannel). Since this isn’t Azure-specific, the Spring configuration resides within the Cloud Hot Folder extension, where the routing and file processing configuration is split across three Spring configuration files within <HYBRIS_BIN_DIR>/ext-cloud/cloudhotfolder/resources/cloudhotfolder/integration/.

Configuration File Source Important Beans
hot-folder-file-routing-spring.xml
Beans concerned with:
  • Resolving channels based on file name
  • Header enriching
  • hotfolderInboundFileNameHeaderEnricherChannel: Channel/header-enricher that adds filename and last modified time to the message
  • hotfolderInboundMessageRouter: Router that tells Spring which input channel to accept messages from and the HeaderValueRouter class
  • hotfolderFIleNameHeaderValueRouter: The Spring HeaderValueRouter that uses the header name to look up a channel
  • hotfolderInboundFilePatternMatchingChannelResolver: An instance of our custom class PatternMatchingDestinationResolver that takes a list of channel mappings in the form key: Pattern and value: MessageChannel and resolves the channels
  • hotfolderInboundFileChannelMappings: The map of Pattern to MessageChannel provided to the above Spring bean.
  • unmappedHotFolderChannel: An instance of the custom class UnmappedHotFolderChannel that extends the Spring NullChannel.
hot-folder-default-mapping.xml

Beans concerned with supporting the standard SAP Commerce Cloud data import

batchFilesCloudHotFolderDefaultProc: The channel mapped to pattern ${cloud.hotfolder.default.mapping.file.name.pattern}.

Added to hot-folder-file-routingspring.xml → hotfolderInboundFIleChannelMappings

Provides the entry point for the standard SAP Commerce Cloud data import flow

hot-folder-zip-mapping.xml

Beans concerned with supporting the new zip folder data import flow.

cloudHotFolderUnzipChannel: The channel mapping to pattern ^(?:.*)\.(?i)(zip)$.

Added to hot-folder-file-routingspring.xml → hotfolderInboundFIleChannelMappings

Provides the entry point for the new ZIP folder data import flow

unZipTransformer: An instance of the custom class CloudUnZipTransfromer that unzips a synchronized ZIP folder.

Unmapped Channel

If no match is found for a channel, then the file is passed to an "unmapped" MessageChannel, which moves the file into the directory ${acceleratorservices.batch.impex.basefolder}/${tenantId}/unmapped.

There is a property that controls this behavior when you want unmapped files to stop the processing of other files.

File Location Configuration Items
project.properties <HYBRIS_BIN_DIR>/ext-cloud/cloudhotfolder cloud.hotfolder.storage.header.router.resolution.required: a boolean flag that specifies whether each file requires a mapped channel. If set to 'false', an unmapped file causes an exception, preventing other files from processing.

Default: false