You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by mi...@accenture.com on 2012/09/13 10:43:18 UTC
Preventing empty results from MyBatis producer being forwarded
Hi.
I have a route similar to the polling example on MyBatis component page:
from("timer://pollTheDatabase?delay=30000").to("mbatis:selectAllAccounts").to("activemq:queue:allAccounts");
When I run Camel I see that also the empty resultsets are being sent to MQ. This causes redundant messages and data transfer and I would like to avoid that. The MyBatis docs tell about option "consumer.routeEmptyResultSet" which sadly works only for producers.
Is there a way to prevent sending the empty results sets to the next step? I tried to fondle a bit with the .choice(), but found no solution.
Regards,
Mikko
________________________________
Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
______________________________________________________________________________________
www.accenture.com
Re: Preventing empty results from MyBatis producer being forwarded
Posted by Claus Ibsen <cl...@gmail.com>.
See the filter EIP, then check for an empty list or something in the
filter predicate.
On Thu, Sep 13, 2012 at 10:43 AM, <mi...@accenture.com> wrote:
> Hi.
>
> I have a route similar to the polling example on MyBatis component page:
>
> from("timer://pollTheDatabase?delay=30000").to("mbatis:selectAllAccounts").to("activemq:queue:allAccounts");
>
> When I run Camel I see that also the empty resultsets are being sent to MQ. This causes redundant messages and data transfer and I would like to avoid that. The MyBatis docs tell about option "consumer.routeEmptyResultSet" which sadly works only for producers.
>
> Is there a way to prevent sending the empty results sets to the next step? I tried to fondle a bit with the .choice(), but found no solution.
>
> Regards,
>
> Mikko
>
> ________________________________
> Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
> ______________________________________________________________________________________
>
> www.accenture.com
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
RE: Preventing empty results from MyBatis producer being forwarded
Posted by Graham Little <gr...@outlook.com>.
Hi Mikko,
You could use a custom processor to check the body of the message, if there is no content then exit the route otherwise carry on.
You can see examples of processors here: http://camel.apache.org/processor.html
from("activemq:myQueue").process(new Processor() {
public void process(Exchange exchange) throws Exception {
String payload = exchange.getIn().getBody(String.class);
// do something with the payload and/or exchange here
exchange.getIn().setBody("Changed body");
}
}).to("activemq:myOtherQueue");
thanks
Graham
> From: mikko.wuokko@accenture.com
> To: users@camel.apache.org
> Subject: Preventing empty results from MyBatis producer being forwarded
> Date: Thu, 13 Sep 2012 08:43:18 +0000
>
> Hi.
>
> I have a route similar to the polling example on MyBatis component page:
>
> from("timer://pollTheDatabase?delay=30000").to("mbatis:selectAllAccounts").to("activemq:queue:allAccounts");
>
> When I run Camel I see that also the empty resultsets are being sent to MQ. This causes redundant messages and data transfer and I would like to avoid that. The MyBatis docs tell about option "consumer.routeEmptyResultSet" which sadly works only for producers.
>
> Is there a way to prevent sending the empty results sets to the next step? I tried to fondle a bit with the .choice(), but found no solution.
>
> Regards,
>
> Mikko
>
> ________________________________
> Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
> ______________________________________________________________________________________
>
> www.accenture.com
RE: Preventing empty results from MyBatis producer being forwarded
Posted by mi...@accenture.com.
Hi.
Thanks. I was on the right track with .choice()/.filter(), but just didn't know how to figure out the right condition.
Just for anyone with similar problem. The IN message was an java.util.ArrayList eg. the resultset from MyBatis. I used the .simple() language for the condition. The route then became like this
from("timer://pollTheDatabase?delay=30000")
.to("mbatis:selectAllAccounts")
.filter().simple("${in.body.size} > 0")
.to("activemq:queue:allAccounts");
The .choice() did work too.
-Mikko
-----Original Message-----
From: Christian Müller [mailto:christian.mueller@gmail.com]
Sent: 13. syyskuuta 2012 12:32
To: users@camel.apache.org
Subject: Re: Preventing empty results from MyBatis producer being forwarded
Use the filter EIP as Claus sugested...
Sent from a mobile device
Am 13.09.2012 10:43 schrieb <mi...@accenture.com>:
> Hi.
>
> I have a route similar to the polling example on MyBatis component page:
>
>
> from("timer://pollTheDatabase?delay=30000").to("mbatis:selectAllAccoun
> ts").to("activemq:queue:allAccounts");
>
> When I run Camel I see that also the empty resultsets are being sent
> to MQ. This causes redundant messages and data transfer and I would
> like to avoid that. The MyBatis docs tell about option
> "consumer.routeEmptyResultSet" which sadly works only for producers.
>
> Is there a way to prevent sending the empty results sets to the next step?
> I tried to fondle a bit with the .choice(), but found no solution.
>
> Regards,
>
> Mikko
>
> ________________________________
> Subject to local law, communications with Accenture and its affiliates
> including telephone calls and emails (including content), may be
> monitored by our systems for the purposes of security and the
> assessment of internal compliance with Accenture policy.
>
> ______________________________________________________________________
> ________________
>
> www.accenture.com
>
Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
______________________________________________________________________________________
www.accenture.com
Re: Preventing empty results from MyBatis producer being forwarded
Posted by Christian Müller <ch...@gmail.com>.
Use the filter EIP as Claus sugested...
Sent from a mobile device
Am 13.09.2012 10:43 schrieb <mi...@accenture.com>:
> Hi.
>
> I have a route similar to the polling example on MyBatis component page:
>
>
> from("timer://pollTheDatabase?delay=30000").to("mbatis:selectAllAccounts").to("activemq:queue:allAccounts");
>
> When I run Camel I see that also the empty resultsets are being sent to
> MQ. This causes redundant messages and data transfer and I would like to
> avoid that. The MyBatis docs tell about option
> "consumer.routeEmptyResultSet" which sadly works only for producers.
>
> Is there a way to prevent sending the empty results sets to the next step?
> I tried to fondle a bit with the .choice(), but found no solution.
>
> Regards,
>
> Mikko
>
> ________________________________
> Subject to local law, communications with Accenture and its affiliates
> including telephone calls and emails (including content), may be monitored
> by our systems for the purposes of security and the assessment of internal
> compliance with Accenture policy.
>
> ______________________________________________________________________________________
>
> www.accenture.com
>