You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by akoufoudakis <ak...@gmail.com> on 2015/05/13 21:57:42 UTC
InOut MEP
Dear all!
I am sure that this questions has been already asked. Apologies that you
have to look at it again.
I have a very trivial route, which uses InOut MEP:
@Component
public class InOutRouter extends RouteBuilder {
public void configure() {
from("jms:incomingOrders")
.inOut("jms:validate");
from("jms:validate")
.bean(ValidatorBean.class);
}
}
The bean is also very trivial:
public class ValidatorBean {
private static Logger logger = Logger.getLogger(ValidatorBean.class);
public void validateSmth(Exchange exchange) {
logger.info("bean invoked!!!");
String body = exchange.getIn().getBody(String.class);
if(body.contains("SOMETHING")) {
exchange.getOut().setBody("Valid");
} else {
exchange.getOut().setBody("Invalid");
}
}
}
The bean is invoked and I can see the logging output.
I can also see that the route works. The number of enqueued/dequeued
messages grows in both "incomingOrders" and "validate" queues.
However, I cannot see any kind of output after the bean execution is over.
Please, help me to find out what I am doing wrong or recommend what should I
do to process the reply (i.e., how and where can process the "Valid/Invalid"
bodies).
Thank you in advance.
--
View this message in context: http://camel.465427.n5.nabble.com/InOut-MEP-tp5767079.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: InOut MEP
Posted by akoufoudakis <ak...@gmail.com>.
Hello, Henryk!
Thanks for the hint.
It is a good workaround.
I myself would do something similar: simple pipes and filters or a
content-based router.
I just wanted to see how InOut works "in theory".
So, what I did, I just continued experimenting with routes, and tried the
following:
public void configure() {
from("jms:incomingOrders")
.inOut("jms:validate").log("${body}");
from("jms:validate")
.bean(ValidatorBean.class);
}
After "log" EIP is executed, I can see the "Valid" output.
If I change it to:
from("jms:incomingOrders")
.inOut("jms:validate").to("jms:queue:smth");
from("jms:validate")
.bean(ValidatorBean.class);
I can see the "Valid" in the "smth" queue. Most probably, I missed
something, when I was testing it yesterday...
--
View this message in context: http://camel.465427.n5.nabble.com/InOut-MEP-tp5767079p5767122.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: InOut MEP
Posted by Henryk Konsek <he...@gmail.com>.
Hi,
Set the validation results on the message header instead of the out message
body. For example:
exchange.getIn().setHeader("VALIDATION_STATUS", "Valid");
Cheers!
czw., 14.05.2015 o 00:06 użytkownik Anton Hughes <ku...@gmail.com>
napisał:
> Please take a look at http://camel.apache.org/content-based-router.html
>
> I think this will help.
>
> On Wed, May 13, 2015 at 9:57 PM, akoufoudakis <ak...@gmail.com>
> wrote:
>
> > Dear all!
> >
> > I am sure that this questions has been already asked. Apologies that you
> > have to look at it again.
> >
> > I have a very trivial route, which uses InOut MEP:
> >
> > @Component
> > public class InOutRouter extends RouteBuilder {
> >
> > public void configure() {
> > from("jms:incomingOrders")
> > .inOut("jms:validate");
> >
> > from("jms:validate")
> > .bean(ValidatorBean.class);
> > }
> >
> > }
> >
> > The bean is also very trivial:
> > public class ValidatorBean {
> >
> > private static Logger logger =
> > Logger.getLogger(ValidatorBean.class);
> >
> > public void validateSmth(Exchange exchange) {
> > logger.info("bean invoked!!!");
> > String body = exchange.getIn().getBody(String.class);
> > if(body.contains("SOMETHING")) {
> > exchange.getOut().setBody("Valid");
> > } else {
> > exchange.getOut().setBody("Invalid");
> > }
> > }
> >
> > }
> >
> > The bean is invoked and I can see the logging output.
> > I can also see that the route works. The number of enqueued/dequeued
> > messages grows in both "incomingOrders" and "validate" queues.
> >
> > However, I cannot see any kind of output after the bean execution is
> over.
> >
> > Please, help me to find out what I am doing wrong or recommend what
> should
> > I
> > do to process the reply (i.e., how and where can process the
> > "Valid/Invalid"
> > bodies).
> >
> > Thank you in advance.
> >
> >
> >
> > --
> > View this message in context:
> > http://camel.465427.n5.nabble.com/InOut-MEP-tp5767079.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
>
Re: InOut MEP
Posted by Anton Hughes <ku...@gmail.com>.
Please take a look at http://camel.apache.org/content-based-router.html
I think this will help.
On Wed, May 13, 2015 at 9:57 PM, akoufoudakis <ak...@gmail.com>
wrote:
> Dear all!
>
> I am sure that this questions has been already asked. Apologies that you
> have to look at it again.
>
> I have a very trivial route, which uses InOut MEP:
>
> @Component
> public class InOutRouter extends RouteBuilder {
>
> public void configure() {
> from("jms:incomingOrders")
> .inOut("jms:validate");
>
> from("jms:validate")
> .bean(ValidatorBean.class);
> }
>
> }
>
> The bean is also very trivial:
> public class ValidatorBean {
>
> private static Logger logger =
> Logger.getLogger(ValidatorBean.class);
>
> public void validateSmth(Exchange exchange) {
> logger.info("bean invoked!!!");
> String body = exchange.getIn().getBody(String.class);
> if(body.contains("SOMETHING")) {
> exchange.getOut().setBody("Valid");
> } else {
> exchange.getOut().setBody("Invalid");
> }
> }
>
> }
>
> The bean is invoked and I can see the logging output.
> I can also see that the route works. The number of enqueued/dequeued
> messages grows in both "incomingOrders" and "validate" queues.
>
> However, I cannot see any kind of output after the bean execution is over.
>
> Please, help me to find out what I am doing wrong or recommend what should
> I
> do to process the reply (i.e., how and where can process the
> "Valid/Invalid"
> bodies).
>
> Thank you in advance.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/InOut-MEP-tp5767079.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>