Reputation: 321
i'm new in spring integration. In my configuration of spring integration i have :
<int:chain input-channel="channel1_2" output-channel="channel1_3">
<int:service-activator>
<bean class="com.csv.CSVEntreprise"/>
</int:service-activator>
</int:chain>
<int:channel id="channel1_3"/>
<int:recipient-list-router id="id-entreprise" input-channel="channel1_3">
<int:recipient channel="channel1_3TRUE" />
<int:recipient channel="channel1_3FALSE"/>
</int:recipient-list-router>
<int:channel id="channel1_3TRUE"/>
<int:channel id="channel1_3FALSE"/>
In the class CSVEntreprise i definied method with Boolean return, i want when it's return true use the channel channel1_3TRUE and when it's return false use the channel channel1_3FALSE ?
Upvotes: 2
Views: 3305
Reputation: 1889
You might want to consider using a header value router (http://docs.spring.io/spring-integration/reference/html/messaging-routing-chapter.html).
You use your CSVEnterprise bean to set the Boolean value in the MessageHeaders.
Your @ServiceActivator
should set the value of your header:
return MessageBuilder.withPayload(message)
.setHeader("MY_HEADER", Boolean.FALSE).copyHeadersIfAbsent(headers).build();
Then, use a header value router to determine which channel to route the order.
<int:header-value-router input-channel="channel1_3" header-name="MY_HEADER" id="headerValueRouter">
<int:mapping value="true" channel="channel1_3TRUE"/>
<int:mapping value="false" channel="channel1_3FALSE" />
</int:header-value-router>
Upvotes: 3