You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by maskellp <ma...@gmail.com> on 2016/05/25 12:45:18 UTC
Returning response from external webservice using dynamicRouter
Hi,
I am new to Camel so please allow for Newbie issues.
I have a Camel Route in java as follows :
public void configure() throws Exception {
from("servlet:routeTest")
.to("log:input")
.to("activemq:queue:inbox");
from("activemq:queue:inbox")
.dynamicRouter(method(DynamicRouter.class, "route"))
.log("${body}");
}
This is bundled in a war deployed on tomcat, this calls the route method as
follows :
public String route(Exchange exchange) {
if (exchange.getIn().getHeader("Server") == null) {
if
(checkBodyToDeterminServer(exchange.getIn().getBody(String.class)))
return
"http4://server1/webservices/ClientService?bridgeEndpoint=true&throwExceptionOnFailure=false";
return
"http4://server2/webservices/ClientService?bridgeEndpoint=true&throwExceptionOnFailure=false";
}
return null;
}
This routes to server 1 and 2 correctly, my question, is
'exchange.getIn().getHeader("Server") == null' the best way to determine
where I am in flow and not process the route on return from the server?
If I call server 1 or 2 directly from soapUi I get a success xml message, I
see this in the body in the route method, but it doesn't get passed back to
the originating soapUi, what step am I missing?
Hope this makes sense.
Thanks in advance.
Phil Maskell
--
View this message in context: http://camel.465427.n5.nabble.com/Returning-response-from-external-webservice-using-dynamicRouter-tp5783073.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Returning response from external webservice using dynamicRouter
Posted by Costash <co...@yahoo.com>.
Hi,
I don't know if i get your question correctly, but
DynamicRouter acts like a loop: it will send the exchange over and over to
the endpoint name returned by the method "route." It will end the loop when
the method "route" will returned "null".
So your method should returned "null" when you want to stop from routing and
go to next line ".log("${body}");"
Regarding passing variables from one call of a dynamicRouter to another, is
better to set in exchange properties instead of message header.
Take a look also to RecipientList - maybe it can help you more (this will
not do a "loop", it will just send to a bunch of endpoint and continue.)
--
View this message in context: http://camel.465427.n5.nabble.com/Returning-response-from-external-webservice-using-dynamicRouter-tp5783073p5783292.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Returning response from external webservice using dynamicRouter
Posted by maskellp <ma...@gmail.com>.
Should I return null from the route method?
The returned success xml from the redirected server is in the Exchange body,
how can I return this as if the client had called the redirected server
directly?
--
View this message in context: http://camel.465427.n5.nabble.com/Returning-response-from-external-webservice-using-dynamicRouter-tp5783073p5783291.html
Sent from the Camel - Users mailing list archive at Nabble.com.