You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by lumi <lu...@gmail.com> on 2013/09/28 00:00:04 UTC
passing data to a polling consumer
Hi,
I don’t know how to pass data from one route that reads a file to another
route that is polling a database.
First route reads id from file.
from("file:testcsv")
.unmarshal().csv()
.to("direct:point1");
Second route needs to use the id in the sql
from("timer://myTimer?period=1000")
.to("sql:select * from test where id = #")
.marshal().csv()
.to("file:target/out ");
With sql consumer faced the same question.
from ("sql:select * from test where id = #?consumer.delay=1000")
.marshal().csv()
.to("file:target/out");
It seems that I’m missing something very basic here, please help.
Thanks and regards,
Lumi
--
View this message in context: http://camel.465427.n5.nabble.com/passing-data-to-a-polling-consumer-tp5740313.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: passing data to a polling consumer
Posted by lumi <lu...@gmail.com>.
Thank you very much, it works with pollEnrich.
from("timer://myTimer?period=1000")
.pollEnrich("file:target/in",
new AggregationStrategy() {
public Exchange aggregate(Exchange oldExchange, Exchange
newExchange) {
if (newExchange == null) return oldExchange;
String myId = newExchange.getIn().getBody(String.class);
oldExchange.getIn().setBody(myId);
return oldExchange;
}
})
.to("sql:select * from test where id = #")
.marshal().csv()
.to("file:target/out");
--
View this message in context: http://camel.465427.n5.nabble.com/passing-data-to-a-polling-consumer-tp5740313p5740392.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: passing data to a polling consumer
Posted by lumi <lu...@gmail.com>.
Thank you for answering, I solved it with pollEnrich.
--
View this message in context: http://camel.465427.n5.nabble.com/passing-data-to-a-polling-consumer-tp5740313p5740393.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: passing data to a polling consumer
Posted by "kraythe ." <kr...@gmail.com>.
I would split on the route and stack the timer before. Any reason you need
it to be 2 routes?
from("timer://myTimer?period=1000")
to("file:testcsv")
.unmarshal().csv()
.split()
.to("sql:select * from test where id = ${body[id]}")
.to("direct:point1");
The split will cause each record to process individually. Probably you have
to adjust the code above for your cases (as I am conding without putting it
in an IDE) but you get the basic idea I hope.
*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39*
On Fri, Sep 27, 2013 at 5:09 PM, Dale King <da...@gmail.com> wrote:
> What you will probably want to do is do a split on the ids so you then have
> a subroute on each ID. Each subroute then needs to access the database, for
> which you will not use a from, but more probably a content enricher to read
> from the SQL endpoint.
>
>
> On Fri, Sep 27, 2013 at 6:00 PM, lumi <lu...@gmail.com> wrote:
>
> > Hi,
> > I don’t know how to pass data from one route that reads a file to another
> > route that is polling a database.
> >
> > First route reads id from file.
> >
> > from("file:testcsv")
> > .unmarshal().csv()
> > .to("direct:point1");
> >
> > Second route needs to use the id in the sql
> >
> > from("timer://myTimer?period=1000")
> > .to("sql:select * from test where id = #")
> > .marshal().csv()
> > .to("file:target/out ");
> >
> >
> > With sql consumer faced the same question.
> >
> > from ("sql:select * from test where id = #?consumer.delay=1000")
> > .marshal().csv()
> > .to("file:target/out");
> >
> > It seems that I’m missing something very basic here, please help.
> >
> > Thanks and regards,
> > Lumi
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://camel.465427.n5.nabble.com/passing-data-to-a-polling-consumer-tp5740313.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
>
>
>
> --
> Dale King
>
Re: passing data to a polling consumer
Posted by Dale King <da...@gmail.com>.
What you will probably want to do is do a split on the ids so you then have
a subroute on each ID. Each subroute then needs to access the database, for
which you will not use a from, but more probably a content enricher to read
from the SQL endpoint.
On Fri, Sep 27, 2013 at 6:00 PM, lumi <lu...@gmail.com> wrote:
> Hi,
> I don’t know how to pass data from one route that reads a file to another
> route that is polling a database.
>
> First route reads id from file.
>
> from("file:testcsv")
> .unmarshal().csv()
> .to("direct:point1");
>
> Second route needs to use the id in the sql
>
> from("timer://myTimer?period=1000")
> .to("sql:select * from test where id = #")
> .marshal().csv()
> .to("file:target/out ");
>
>
> With sql consumer faced the same question.
>
> from ("sql:select * from test where id = #?consumer.delay=1000")
> .marshal().csv()
> .to("file:target/out");
>
> It seems that I’m missing something very basic here, please help.
>
> Thanks and regards,
> Lumi
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/passing-data-to-a-polling-consumer-tp5740313.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Dale King