Try filtering using a custom bean expression instead. Something like this from("jms:queue:testQueue").filter().method("myTestDBFilter", "hasNewContent").to("jms:queue:otherTestQueue");
Where your bean would be something like this class TestDBFilter { public static boolean hasNewContent(@Body YourCustomObject body) { // 1. extracts the content from the body // 2. performs the DB lookup // 3. returns true if it has new content } } Also your message will be discarded if you don't have any other steps in your route so your other requirement is good too. On Thu, Feb 19, 2009 at 3:20 PM, triswork <tristan.k...@gmail.com> wrote: > > I am new to Camel and am trying to migrate some code I wrote using the > javax.jms classes across to Camel. I have a specific problem and I am not > too sure if my approach is the optimal solution. I would really appreciate > some feedback from the veterans on this list. > > Basically, my application performs the following: > 1) A consumer retrieves a Serialized Java object from a Queue. > 2) The contents of a data field within the object are matched against a set > of database records. > 3) If the content corresponds to an existing record, the database record is > updated and the object is discarded. > 4) If the content is new, it is written to the database, some of the object > data is updated and it is routed to another JMS queue for further > processing. > > My approach in Camel has been to create a RouteBuilder that works something > like this > from("jms:queue:testQueue") > .process(new TestDBFilter()) > > > .filter(header("newContent").isEqualTo("true")).to("jms:queue:otherTestQueue"); > > My TestDBFilter class basically > - extracts the content from the message using getIn(); > - Performs the DB lookup > - Updates the message headers on getOut() > > Is this a valid approach? It seems a bit contrived to me that I have to put > a filter on a header field after my processor executes. Two specific > questions: > 1) Is there a simpler/more efficient way to do this? > 2) Do I have to do anything special to the message to get rid of it (in > cases where the DB record already exists). Or will it just be discarded > when > it fails on my filter predicate? > > Thanks in advance for any feedback/advice > > Tristan > -- > View this message in context: > http://www.nabble.com/Newbie-Question---Content-Filtering-tp22107198s22882p22107198.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > -- Cheers, Jon http://janstey.blogspot.com/