Reputation: 103
here is my problem I have splitter class as below:
public class MySplitterBean {
public List<Message> splitMessage(Message m) {
List<Message> answer = new ArrayList<Message>();
for (int i=0; i<3; i++) {
DefaultMessage message = new DefaultMessage();
message.setHeaders(m.getHeaders());
message.setBody(m.getBody());
answer.add(message);
}
return answer;
}
}
And in route:
<split strategyRef="someClassStrategy">
<method ref="mySplitterBean" method="splitMessage" />
<choice>
<when>
<simple>${property.CamelSplitIndex} == 0</simple>
<!-- 1. calculate something and store result in header, for example set header test=12345 -->
</when>
<otherwise>
<!-- 2. now how can I retrieve "test" header from above exchange (from splitIndex 0) -->
</otherwise>
</choice>
</split>
In otherwise block I have message object copied by MySplitterBean, but I want to somehow get "test" header that was created after split (while processing splint index 0). So my question is if its possible, and how to make it work ?
Upvotes: 0
Views: 341
Reputation: 363
You can set a property value with a dummy object before the split operation. Each exchange object can access this object via call by reference. Depending on the value it can be, that you need an additional container like a list to guarantee that you can access the same object.
Upvotes: 1
Reputation: 507
Otherwise block is not accessible if split index is zero, "test" header cannot be retrieved from same exchange in this case. It can be accessed outside choice block.
Upvotes: 0