I have an aggregator that is supposed to take all messages with a certain correlation key (in the example below I hardcoded this to 10, because the corresponding Splitter generates 10 messages).
I can see many messages via logging, and all 10 messages generated, but never 10 being received by the aggregator. Here is the code for the aggregator:
@MessageEndpoint
public class MyAggregator {
@ReleaseStrategy
public boolean releaseStrategy( final List< Map< String, String > > msgs )
{
System.out.println( "Aggregator.releaseStrategy: received " + msgs.size() + " messages " );
if( msgs.size() == 10 ) {
System.out.println( "releasing the fragments!" );
return true;
}
return false;
}
@CorrelationStrategy
public String correlationStrategy( final Map< String, String > msg )
{
return msg.get( "job.oid" );
}
@Aggregator( inputChannel = "input",
outputChannel = "output" )
public Map< String, String > aggregate( final List< Map< String, String > > msgs ) {
System.out.println( "received all fragments of a job! Number of fragments: " + msgs.size() );
Map< String, String > msg = new HashMap< String, String >();
String jobOid = "";
if( !msgs.isEmpty()) {
jobOid = msgs.get( 0 ).get( "job.oid" );
}
msg.put( "job.oid", jobOid );
msg.put( "job.numberOfFragments", ""+msgs.size() );
return msg;
}
}
Could it be that multiple instances of the aggregator are consuming the messages, so that neither will receive all 10 belonging to one correlation group?
How can I fix this, since the aggregator I am writing is supposed to take ALL correlated messages and produce a new message from this.