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