Hi,

Your approach is valid and will work as expected. However there is no need
for this header field to be added.

I would add an exception clause to deal with any exceptions thrown by the
DBFilter. For more on exception handling check out 
http://camel.apache.org/exception-clause.html
http://camel.apache.org/exception-clause.html 

from("jms:queue:testQueue")
  .process(new TestDBFilter())
 
.onException(OrderExistsException.class).handled(true).maximumRedeliveries(0).to("mock:RecordExists").end()
  .to("jms:queue:otherTestQueue");

Hope this helps.

Cheers,

Ashwin...


triswork 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
> 


-----
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: 
http://www.nabble.com/Newbie-Question---Content-Filtering-tp22107198s22882p22114960.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to