You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by roger_rabbit <ro...@gmx.fr> on 2013/07/22 20:39:48 UTC
Quartz and enrich seem not to work together...
Hi,
I read a few things about the subject, but since most of them were 3 years
old, I guess there are new features that may have changed the issue... so
here's my 2013 problem.
First of all, I am quite new to camel (20 days experience).
In a previous project, I managed to use a quartz-triggered route to get some
informations from a http site and send them as messages on a bus topic
(Fuse).
This worked fine for me.
Now, I am trying to use the same kind of process to manage a file, in such a
way I read the file at a time pointed out by a cron expression, and use the
content of the file to trigger several messages on bus (basicely : one
message will be triggerd per line in file).
Very basicely, this should look like (from my RouteBuilder-implementing
class) :
from("quartz:mytimer?0+0/2+*+*+*")
.enrich("file:/my/directory/?fileName=myFile.pair&noop=true")
.split("\n",1)
.to("activemq:my.topic.out");
My problem is that the file is processed only for the first quartz event,
and then, never processed again... (even if I change file's content).
So, what I guess is that it is "consumed" (thus, never read, and that's why
the route failed during the next quartz events), and that I have to keep
the content of the file in some ... place (topic?/seda?/other?) and enrich
my quartz route from that place without consuming the message...
My problem is, as a noobie, I don't know how to that.
I tried to set a previous route such as :
from("file:/my/directory/?fileName=myFile.pair&noop=true").to("direct:file");
and then use as as my enrichment source :
from("quartz:mytimer?0+0/2+*+*+*")
.enrich("direct:file")
.split("\n",1)
.to("activemq:my.topic.out");
... but the problem was the same... since obviously it is still consumed.
I also tried to use a ConsumerTemplate from a processor to enrich the
exchange with stg like :
Process(Exchange ex){
...
Exchange newEx =
template.receive("file:/my/directory/?fileName=myFile.pair&noop=true");
ex.setIn(newEx);
}
... but all the same...
So I tried many things and ended up thinking I .. think the wrong way. So
any tip here would be welcome.
Thanks in advance
--
View this message in context: http://camel.465427.n5.nabble.com/Quartz-and-enrich-seem-not-to-work-together-tp5736046.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Quartz and enrich seem not to work together...
Posted by roger_rabbit <ro...@gmx.fr>.
Claus,
thanks for your tip. That was that little thingy I was looking for.
I should have read the "noop" option closer... "rtfm" should be my mantra!
Roger.
--
View this message in context: http://camel.465427.n5.nabble.com/Quartz-and-enrich-seem-not-to-work-together-tp5736046p5736117.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Quartz and enrich seem not to work together...
Posted by Claus Ibsen <cl...@gmail.com>.
You can set idempotent=false on the file to allow it to re-read the
file always. As when you use noop=true that would otherwise imply
idempotent=true. But by setting it explicit to false will always make
the file readable again.
On Mon, Jul 22, 2013 at 8:39 PM, roger_rabbit <ro...@gmx.fr> wrote:
> Hi,
>
> I read a few things about the subject, but since most of them were 3 years
> old, I guess there are new features that may have changed the issue... so
> here's my 2013 problem.
>
> First of all, I am quite new to camel (20 days experience).
>
> In a previous project, I managed to use a quartz-triggered route to get some
> informations from a http site and send them as messages on a bus topic
> (Fuse).
> This worked fine for me.
>
> Now, I am trying to use the same kind of process to manage a file, in such a
> way I read the file at a time pointed out by a cron expression, and use the
> content of the file to trigger several messages on bus (basicely : one
> message will be triggerd per line in file).
>
> Very basicely, this should look like (from my RouteBuilder-implementing
> class) :
> from("quartz:mytimer?0+0/2+*+*+*")
> .enrich("file:/my/directory/?fileName=myFile.pair&noop=true")
> .split("\n",1)
> .to("activemq:my.topic.out");
>
> My problem is that the file is processed only for the first quartz event,
> and then, never processed again... (even if I change file's content).
> So, what I guess is that it is "consumed" (thus, never read, and that's why
> the route failed during the next quartz events), and that I have to keep
> the content of the file in some ... place (topic?/seda?/other?) and enrich
> my quartz route from that place without consuming the message...
> My problem is, as a noobie, I don't know how to that.
> I tried to set a previous route such as :
>
>
> from("file:/my/directory/?fileName=myFile.pair&noop=true").to("direct:file");
>
> and then use as as my enrichment source :
>
> from("quartz:mytimer?0+0/2+*+*+*")
> .enrich("direct:file")
> .split("\n",1)
> .to("activemq:my.topic.out");
>
> ... but the problem was the same... since obviously it is still consumed.
>
> I also tried to use a ConsumerTemplate from a processor to enrich the
> exchange with stg like :
>
> Process(Exchange ex){
> ...
> Exchange newEx =
> template.receive("file:/my/directory/?fileName=myFile.pair&noop=true");
> ex.setIn(newEx);
> }
> ... but all the same...
>
> So I tried many things and ended up thinking I .. think the wrong way. So
> any tip here would be welcome.
>
>
> Thanks in advance
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Quartz-and-enrich-seem-not-to-work-together-tp5736046.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen