Spring Integration Aggregator is not working properly.

I have the following structure.

<int:publish-subscribe-channel id="updateProjectRequest" />
<int:channel id="aggregate-project"/>

<int:service-activator input-channel="updateProjectRequest" output-channel="aggregate-project" ref="updateProjectResponseHandler" method="createFolder"/>
<int:service-activator input-channel="updateProjectRequest" output-channel="aggregate-project" ref="updateProjectResponseHandler" method="createRepo"/>

<int:aggregator input-channel="aggregate-project"  ref="projectAggregator">

Below is my Aggregator class.

@Component("projectAggregator")
public class ProjectAggregator {

@Aggregator
public boolean aggregatingMethod(List<Map<String, List<Project>>> items) {
//////// CODE //////
}

@ReleaseStrategy
public boolean releaseChecker(List<Message<?>> messages) {
//////CODE/////
}

@CorrelationStrategy
public Map<String, List<Project>> correlateBy(Map<String, List<Project>> item) {
    return item;
}

The problem is that I print the message length in the @ReleaseStrategy method, it always remains 1. According to my information, it should increase. Can you please help me in detecting errors with the above code.

+4
source share
1 answer

You need to set apply-sequenceto trueif you later want to combine the messages sent to the pub / subchannel subscribers.

When this is true, correlationIdsequence information is added to the message headers .

<xsd:attribute name="apply-sequence" type="xsd:string" default="false">
    <xsd:annotation>
        <xsd:documentation>
            Specify whether the sequence size, sequence number, and correlation id
            headers should be set on
            Messages that are sent through this channel.
        </xsd:documentation>
    </xsd:annotation>
</xsd:attribute>
+1
source

Source: https://habr.com/ru/post/1650280/


All Articles