Class FileAggregator
java.lang.Object
org.springframework.integration.file.aggregator.FileAggregator
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,CorrelationStrategy
,GroupConditionProvider
,MessageGroupProcessor
,ReleaseStrategy
public class FileAggregator extends Object implements CorrelationStrategy, ReleaseStrategy, GroupConditionProvider, MessageGroupProcessor, BeanFactoryAware
A convenient component to utilize
a
FileSplitter.FileMarker
-based aggregation logic.
Implements all three CorrelationStrategy
, ReleaseStrategy
and MessageGroupProcessor
for runtime optimization.
Delegates to HeaderAttributeCorrelationStrategy
with FileHeaders.FILENAME
attribute,
FileMarkerReleaseStrategy
and FileAggregatingMessageGroupProcessor
, respectively.
The default FileSplitter
behavior
with markers enabled is about do not provide a sequence details
headers, therefore correlation in this aggregator implementation is done by the FileHeaders.FILENAME
header which is still populated by the FileSplitter
for each line emitted, including FileSplitter.FileMarker
messages.
If default behavior of this component does not satisfy the target logic, it is recommended to configure an aggregator with individual strategies.
- Since:
- 5.5
- Author:
- Artem Bilan
-
Constructor Summary
Constructors Constructor Description FileAggregator()
-
Method Summary
Modifier and Type Method Description boolean
canRelease(MessageGroup group)
Object
getCorrelationKey(Message<?> message)
Find the correlation key for the given message.BiFunction<Message<?>,String,String>
getGroupConditionSupplier()
Object
processMessageGroup(MessageGroup group)
Process the given MessageGroup.void
setBeanFactory(BeanFactory beanFactory)
-
Constructor Details
-
FileAggregator
public FileAggregator()
-
-
Method Details
-
setBeanFactory
- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Throws:
BeansException
-
getCorrelationKey
Description copied from interface:CorrelationStrategy
Find the correlation key for the given message. If no key can be determined the strategy should not returnnull
, but throw an exception.- Specified by:
getCorrelationKey
in interfaceCorrelationStrategy
- Parameters:
message
- The message.- Returns:
- The correlation key.
-
canRelease
- Specified by:
canRelease
in interfaceReleaseStrategy
-
getGroupConditionSupplier
- Specified by:
getGroupConditionSupplier
in interfaceGroupConditionProvider
-
processMessageGroup
Description copied from interface:MessageGroupProcessor
Process the given MessageGroup. Implementations are free to return as few or as many messages based on the invocation as needed. For example an aggregating processor will return only a single message representing the group, while a resequencing processor will return all messages whose preceding sequence has been satisfied.If a multiple messages are returned the return value must be a Collection<Message>.
- Specified by:
processMessageGroup
in interfaceMessageGroupProcessor
- Parameters:
group
- The message group.- Returns:
- The result of processing the group.
-