Could you provide any example for routing messages in Spring Integration?. Filter by payload message, header or something like the following:
<int:payload-type-router input-channel="routingChannel">
<int:mapping type="java.lang.String" channel="channel1" />
<int:mapping type="java.lang.Integer" channel="channel2" />
</int:payload-type-router>
How the response works? I mean, if I send:
channel -> router -> transformer -> gateway
Simple but I am looking something similar to this example:
<int:router input-channel="inChannel" expression="payload.paymentType">
<int:mapping value="CASH" channel="cashPaymentChannel"/>
<int:mapping value="CREDIT" channel="authorizePaymentChannel"/>
<int:mapping value="DEBIT" channel="authorizePaymentChannel"/>
</int:router>
When my gateway receives a message and sends the response to reply channel. How can I inform in my router what is the correct reply channel?
@Router
methods simply return the channel(s) or channel name(s) to which the message will be routed.For your second question, you need to show more of your flow; what is "upstream" of
channel
?You can omit the
reply-channel
from the gateway (or omit theoutput-channel
from other types of, ultimate reply-producing consumer) and the reply will be sent to the channel that's in the message'sreply-channel
header; framework components that start request/reply scenarios (inbound gateways, messaging gateways,sendAndReceive
methods in theMessagingTemplate
) set up this header automatically so there's nothing for you to do; it just works.