You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by DanielArias <da...@koghi.com> on 2016/11/21 15:15:08 UTC

send reply body after finishing complete route

Hi, I'm trying to make a synchronous call to an activemq sending a body right
after I process some rest service invocation. Here is my code:

some process here.. sent to this route.

private String velocitySetThirdPartyTemplate =
"velocity:file://url/velocity/file/SetThirdParty_Template.vm";

from("direct:QueueThirdParty")
		.process(new ProcessThirdPartyError())
		.marshal()
		.xstream("UTF-8")
//		wait for the body when the response of the Web Service is 200 ok
		.to(ExchangePattern.InOut,"jms:queue:CreateThirdParty")
                .to("activemq:queue:somequeue");               

from("jms:queue:CreateThirdParty")
		.transacted()
		.unmarshal()
		.xstream()
		.process(new SetBodyThirdParty())->this route define body as an ArrayList
of Pojo 
		.split(body())
		.to(velocitySetThirdPartyTemplate)->this velocity make the json required
for the Web Service
		.process(new RestHeadersSetThirdParty())
		.to("restlet:http://ip:port/Web/Service/url"
					+ "?restletMethod=post&throwExceptionOnFailure")
		.process(new ResponseProcess())
		.log("response ${in.body.getStatus().getCode()}")
		.process(new SetExchangeInOutBody()); -> this final process set the body
that I want to                                            send to the
activemq in that is waiting for the reply.

the problem is that the body that is sending to the end point
"activemq:queue:somequeue" after waiting for a reply is the ArrayList of
POJO before the split.

Any Idea of how to send the body of the ".process(new
SetExchangeInOutBody());" that is the one I need.

Thanks in advance.

		



--
View this message in context: http://camel.465427.n5.nabble.com/send-reply-body-after-finishing-complete-route-tp5790291.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: send reply body after finishing complete route

Posted by DanielArias <da...@koghi.com>.
I already did that, but is still taking the body of the processor that sends
to the splitter.
I even set the exchange.getIn().setBody() and the
exchange.getOut().setBody() whit the body I need.
but nothing :(



--
View this message in context: http://camel.465427.n5.nabble.com/send-reply-body-after-finishing-complete-route-tp5790291p5790293.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: send reply body after finishing complete route

Posted by souciance <so...@gmail.com>.
I would assume since it is an InOut pattern, you need to set the body to
your Out exchange. You should be able to do that in your processor.

On Mon, Nov 21, 2016 at 4:15 PM, DanielArias [via Camel] <
ml-node+s465427n5790291h84@n5.nabble.com> wrote:

> Hi, I'm trying to make a synchronous call to an activemq sending a body
> right after I process some rest service invocation. Here is my code:
>
> some process here.. sent to this route.
>
> private String velocitySetThirdPartyTemplate =
> "velocity:file://url/velocity/file/SetThirdParty_Template.vm";
>
> from("direct:QueueThirdParty")
>                 .process(new ProcessThirdPartyError())
>                 .marshal()
>                 .xstream("UTF-8")
> // wait for the body when the response of the Web Service is 200 ok
>                 .to(ExchangePattern.InOut,"jms:queue:CreateThirdParty")
>                 .to("activemq:queue:somequeue");
>
> from("jms:queue:CreateThirdParty")
>                 .transacted()
>                 .unmarshal()
>                 .xstream()
>                 .process(new SetBodyThirdParty())->this route define body
> as an ArrayList of Pojo
>                 .split(body())
>                 .to(velocitySetThirdPartyTemplate)->this velocity make
> the json required for the Web Service
>                 .process(new RestHeadersSetThirdParty())
>                 .to("restlet:<a href="http://ip:port/Web/
> Service/url">http://ip:port/Web/Service/url"
>                                         + "?restletMethod=post&throwExceptionOnFailure")
>
>                 .process(new ResponseProcess())
>                 .log("response ${in.body.getStatus().getCode()}")
>                 .process(new SetExchangeInOutBody()); -> this final
> process set the body that I want to
>    send to the activemq in that is waiting for the reply.
>
> the problem is that the body that is sending to the end point
> "activemq:queue:somequeue" after waiting for a reply is the ArrayList of
> POJO before the split.
>
> Any Idea of how to send the body of the ".process(new
> SetExchangeInOutBody());" that is the one I need.
>
> Thanks in advance.
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/send-reply-body-after-
> finishing-complete-route-tp5790291.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/send-reply-body-after-finishing-complete-route-tp5790291p5790292.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: send reply body after finishing complete route

Posted by Claus Ibsen <cl...@gmail.com>.
If you want to do a fork/join pattern with the splitter, then see
http://camel.apache.org/composed-message-processor.html

with the spliter only way. eg use the aggregation strategy to merge your result.

On Mon, Nov 21, 2016 at 4:15 PM, DanielArias <da...@koghi.com> wrote:
> Hi, I'm trying to make a synchronous call to an activemq sending a body right
> after I process some rest service invocation. Here is my code:
>
> some process here.. sent to this route.
>
> private String velocitySetThirdPartyTemplate =
> "velocity:file://url/velocity/file/SetThirdParty_Template.vm";
>
> from("direct:QueueThirdParty")
>                 .process(new ProcessThirdPartyError())
>                 .marshal()
>                 .xstream("UTF-8")
> //              wait for the body when the response of the Web Service is 200 ok
>                 .to(ExchangePattern.InOut,"jms:queue:CreateThirdParty")
>                 .to("activemq:queue:somequeue");
>
> from("jms:queue:CreateThirdParty")
>                 .transacted()
>                 .unmarshal()
>                 .xstream()
>                 .process(new SetBodyThirdParty())->this route define body as an ArrayList
> of Pojo
>                 .split(body())
>                 .to(velocitySetThirdPartyTemplate)->this velocity make the json required
> for the Web Service
>                 .process(new RestHeadersSetThirdParty())
>                 .to("restlet:http://ip:port/Web/Service/url"
>                                         + "?restletMethod=post&throwExceptionOnFailure")
>                 .process(new ResponseProcess())
>                 .log("response ${in.body.getStatus().getCode()}")
>                 .process(new SetExchangeInOutBody()); -> this final process set the body
> that I want to                                            send to the
> activemq in that is waiting for the reply.
>
> the problem is that the body that is sending to the end point
> "activemq:queue:somequeue" after waiting for a reply is the ArrayList of
> POJO before the split.
>
> Any Idea of how to send the body of the ".process(new
> SetExchangeInOutBody());" that is the one I need.
>
> Thanks in advance.
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/send-reply-body-after-finishing-complete-route-tp5790291.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2