camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesse Sanford <jessesanf...@gmail.com>
Subject need help with interceptor in camel 1.6.2 using custom predicate
Date Sun, 11 Apr 2010 21:11:30 GMT
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("jessesanford@gmail.com")) {
                    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("jessesanford@gmail.com")) {


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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message