Thanks Raul, Knew there had to be some way of doing this but new to Camel
-----Original Message----- From: Raul Kripalani [mailto:[email protected]] Sent: 08 August 2012 13:31 To: [email protected] Subject: Re: Using timer and MongoDb queries Hi Rich, All you need to do is specify the query object as the body of the IN message. Ultimately, the query object should be a DBObject (i.e. a JSON object), but the good news is that camel-mongodb supports automatic type conversions from Strings and HashMaps! So you could do the following: from("timer://myTimer?period=30000") .setBody().constant("{\"foo\": \"bar\"}") .to("mongodb:myDb?database=test&collection=test&operation=findAll&dynamicity=true") .to("stream:out"); This will return all objects that contain a field "foo" whose value is "bar". Remember to escape inner quotes in the JSON object. And you are right, this use case doesn't appear in the component's documentation. I'll update straightaway. Hope that helps. P.S.: No need to use custom processors as Sam described. As of Camel 2.10, there's a camel-mongodb component to interact with MongoDB databases directly from your routes. Thanks, *Raúl Kripalani* *Principal Consultant | FuseSource Corp. [email protected] | fusesource.com <http://www.fusesource.com/> skype: raul.fuse | twitter: @raulvk <http://twitter.com/raulvk>, @fusenews<http://twitter.com/fusenews> * blog: F3 - Flashes From the Field<http://blog.raulkr.net/?utm_source=fusesourceemail&utm_medium=email&utm_campaign=fusesourcemail> aboutme: http://about.me/raulkripalani <http://twitter.com/fusenews> On 31 July 2012 17:12, rich_g <[email protected]> wrote: > Hi all > I want to make a timer that polls a Mongo collection to get data with an id > > variable set at runtime. > > I am able to get a timer working using but don't know how to set a query > filter > > from("timer://myTimer?period=30000") > > > .to("mongodb:myDb?database=test&collection=test&operation=findAll&dynamicity=true") > .to("stream:out"); > but don't know > > > And using the unit tests for camel-mongo I am able to query using the code > below to get the filtered set. > > DBObject query = > BasicDBObjectBuilder.start().push("_id").add("$gte",12).get(); > Object result = template.requestBody("direct:findAll", query); > > .... > > from("direct:findAll") > .to("mongodb:myDb?database > test&collection=test&operation=findAll&dynamicity=true") > .to("mock:resultFindAll"); > > > Can anyone give me some advice on how to combine the 2? > > Thanks > > Rich > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Using-timer-and-MongoDb-queries-tp5716634.html > Sent from the Camel - Users mailing list archive at Nabble.com. >
