I did one simple DSL which retrieves the data from database and doing simple conversion in the service activator.
@Bean
public IntegrationFlow mainFlow() {
return IntegrationFlows.from("userChannel")
.channel("queryChannel")
.handle("sampleConvertor","convertUser")
.get();
queryChannel is a jdbc outbound gateway and sampleConverter is the service Activator.
<int-jdbc:outbound-gateway query="select * from employee where employee_id=:payload"
request-channel="queryChannel" data-source="dataSource"/>
The issue is after retrieving the data from database, the flow is not going to serviceActivator and it simply returns back the database response.
In xml configuration, I used to invoke gateway inside the chain like below.
<int:gateway id="query.gateway" request-channel="queryChannel"/>
Please suggest what I am doing wrong here. Thanks in advance.
That's a bit unusual to combine Java DSL and XML configuration, but they still work together.
Your problem I think that you are missing the fact that your queryChannel
has two subscriber at runtime, not a chain of call.
The first one is <int-jdbc:outbound-gateway>
and the second is that .handle("sampleConvertor","convertUser")
. Right, when you declare a channel in the IntegrationFlow
, the next EIP-method produces a subscriber for this channel. At the same time when you use a channel like request-channel
or input-channel
in the XML configuration that brings a subscriber as well.
So, you have two subscriber on the DirectChannel
with the RoundRobinLoadBalancingStrategy
and therefore only one of them will handle a message and if it is a request-replly component, like that <int-jdbc:outbound-gateway>
it will produce a message into the output-channel
or to the replyChannel
in the headers. In your case the story is exactly about a replyChannel
and therefore you don't go to the .handle("sampleConvertor","convertUser")
because it's not the next in the chain, but just a parallel universe by the round-robin algorithm.
If you really would like to reach that .handle("sampleConvertor","convertUser")
after calling the <int-jdbc:outbound-gateway>
, you should consider to use .gateway("queryChannel")
instead of that .channel()
.