Please let me know if there is way to define @ReleaseStrategy with MessageGroup and associate it with @Aggregator.
I have POJO defined as below but not sure how would I associate a @Aggregator to it
public class FooReleaseStrategy {
@ReleaseStrategy
public boolean canRelease(MessageGroup group) {
return group.isComplete();
}
}
I have @Aggregator and @CorrelationStratgy defined part of configuration.
@Aggregator(inputChannel="sftpChannel" outputChannel="aggregateChannel")
public List<Message<?>> aggregateFiles(List<Message<?>> messages) {
return messages;
}
@CorrelationStrategy based on filename.
Would be very helpful if someone can shed some light on @ReleaseStrategy association with example if possible.
Based on the comments, I am planning on the create a aggregator factory bean to see if works for my use-case
@Bean
@ServiceActivator(inputChannel = "sftpChannel")
public FactoryBean<MessageHandler> aggregatorFactoryBean( ) {
AggregatorFactoryBean aggregatorBean = new AggregatorFactoryBean();
aggregatorBean.setProcessorBean(new CustomAggregator());
aggregatorBean.setMethodName("aggregate");
aggregatorBean.setMessageStore(new SimpleMessageStore());
aggregatorBean.setReleaseStrategy(messageGroup -> {
return messageGroup.isComplete();
});
aggregatorBean.setOutputChannel(aggregatorFileChannel());
aggregatorBean.setExpireGroupsUponTimeout(true);
aggregatorBean.setGroupTimeoutExpression(new ValueExpression<>(1000L));
aggregatorBean.setSendPartialResultOnExpiry(false);
aggregatorBean.setExpireGroupsUponCompletion(true);
return aggregatorBean;
}