Hi Jesse btw thanks for the kudo.
The interceptors in Camel 1.x is not working super duper. And hence why they have been overhauled in the 2.0 onwards, which would allow you to do what you want. I suggest to search in the camel-core src/test/java directory for any intercept unit tests and see if you can find an example that looks like what you are doing. I assume upgrading to 2.x is not an option. You may instead want to use a Filter EIP in 1.x to build a solution where you can use the predicate to include the "good" messages in the filter. Then the bad messages can be "skipped". On Sun, Apr 11, 2010 at 11:11 PM, Jesse Sanford <[email protected]> wrote: > I am trying to intercept an exchange using a custom predicate and I am > having trouble re-routing the exchange or even simply stoping it. > > Here is my routebuilder: > > public class commentRoute extends RouteBuilder{ > �...@override > public void configure(){ > intercept().when(isBlacklisted()).to("mock:intercepted").stop(); > from("comment-queue").to("comment-catcher"); > } > > private Predicate isBlacklisted(){ > return new Predicate(){ > public boolean matches(Object ex) { > Exchange exchange = (Exchange)ex; > String email = > exchange.getIn().getBody(Comment.class).getEmail(); > if(email.equalsIgnoreCase("[email protected]")) { > return true; > } else { > return false; > } > } > > public void assertMatches(String s, Object o) { > //do nothing > //this just satisfies the interface > } > }; > } > > } > > I know that the predicate is being run because If I set a breakpoint at > > if(email.equalsIgnoreCase("[email protected]")) { > > > and step through the code from there the return true; is reached when i send > an exchange with the email address filled in with my email address. > > Am I doing this all wrong? If this predicate is run and returns true why > doesn't camel respect my intercept re-routing or stoping? > > Thanks so much, > jesse > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
