I have a spring integration splitter with the following method signature:
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.Code:@Splitter public List<Message<String[]>> splitCsvIntoSeperateMessages(Message<List<String[]>> message)
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:@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; }


Reply With Quote
