I have a spring integration splitter with the following method signature:
@Splitter
public List<Message<String[]>> splitCsvIntoSeperateMessages(Message<List<String[]>> message)
The message payload is an ArrayList of String[]. The splitter reads each row in the List, Creates a new Message setting the payload to the data item in the List, adds a CorrelationId, SequenceNumber and SequenceSize to the header and finally returns an ArrayList of Messages.
The problem is that when each individual message is sent to the next channel, the CorrelationId, SequenceNumber and SequenceSize are all overwritten with new values. Is that expected behavior or am I missing something?
Code Snippet Below:
@Splitter
public List<Message<String[]>> splitCsvIntoSeperateMessages(Message<List<String[]>> message) {
List<Message<String[]>> returnVal = new ArrayList<Message<String[]>>();
String headerId = null;
int sequenceSize = 0;
int sequenceNumber = 0;
for(String[] payload : message.getPayload()){
if(payload[0].equals("HEAD")){
headerId = UUID.randomUUID().toString();
sequenceSize = Integer.parseInt(payload[payload.length-1]);
sequenceNumber=0;
}
sequenceNumber++;
Message<String[]> msg =
MessageBuilder
.withPayload(payload)
.setCorrelationId(headerId)
.setSequenceSize(sequenceSize)
.setSequenceNumber(sequenceNumber)
.build();
returnVal.add(msg);
}
return returnVal;
}
Using Spring Integration 2.0 M6