4

I recently moved to Spring boot and started converting all the XMLs to Java Configs. The @Aggregate annotation does not have expireGroupUponCompletion and persistenceStore as the input. Is there any other way we can specify these things?

Nikhil
  • 83
  • 6

2 Answers2

1

Is there any other way we can specify these things?

Using Spring Integration Java DSL:

.aggregate(a -> a.expireGroupsUponCompletion(true)
                 .sendPartialResultOnExpiry(true)
                 .messageStore(messageStore(), null)

The second null param means that we aren't interested in some endpoint customization and just rely on the defaul state. We left that syntax to avoid the explicit type for Lambda argument:

.aggregate((AggregatorSpec a) -> a.expireGroupsUponCompletion(true)
                 .sendPartialResultOnExpiry(true)
                 .messageStore(messageStore())
Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
1

Thanks Artem.I am able to solve the problem with the following configuration.

    @Bean
public IntegrationFlow pollingFlow() {
    return IntegrationFlows.from(splitSegment())
                           .aggregate( a -> a
                                     .expireGroupsUponCompletion(true)
                                     .messageStore(persistenceMessageStore())
                                     .sendPartialResultOnExpiry(true)
                                     .discardChannel(aggregateSegments())
                                     .correlationStrategy(m -> m.getPayload())
                                     .releaseStrategy(g ->  g.getMessages().size() > 5)
                                     .outputProcessor(g -> {
                                                               CountDB ag = new CountDB();
                                                               ag.setId((Long) g.getOne().getPayload());
                                                               ag.setActiveUsers((long)g.getMessages().size());
                                                               return ag;
                                                            })
                                    ,
                                     null)
                           .channel(aggregateSegments())
                           .get();
Nikhil
  • 83
  • 6