Yeah sure. I've attached the route.
As you can see it's effectively a template for a CBR route, the values of which I populate when instantiated. Its then added to the camel context in the standard way: context.addRoutes(CBRRouteBuilder) Cheers, Dan On Wed, Jul 6, 2011 at 4:57 PM, Ashwin Karpe <aka...@fusesource.com> wrote: > Hi Daniel, > > Can you please post your route that exhibits this behavior. I am having a > bit of difficulty reproducing the issue. > > I can see the code, however, I do not see a way to trigger this behavior to > happen. > > Thanks & Regards, > > Ashwin... > > > > ----- > --------------------------------------------------------- > Ashwin Karpe > Apache Camel Committer & Sr Principal Consultant > FUSESource (a Progress Software Corporation subsidiary) > http://fusesource.com > > Blog: http://opensourceknowledge.blogspot.com > --------------------------------------------------------- > -- > View this message in context: > http://camel.465427.n5.nabble.com/Removing-routes-programmatically-tp4556741p4557219.html > Sent from the Camel - Users mailing list archive at Nabble.com. >
package bt.cbrComponent.model; import java.util.HashMap; import java.util.Map.Entry; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.model.ChoiceDefinition; import org.apache.log4j.Logger; /** * Builds the CBR route. * * @author Daniel Spaven * @version 0.1 * */ public class CBRRouteBuilder extends RouteBuilder { private static Logger LOG = Logger.getLogger(CBRRouteBuilder.class.getName()); private String id; private String src; private HashMap<String,CPredicate> map = new HashMap<String,CPredicate>(); public CBRRouteBuilder(String id, String src, HashMap<String,CPredicate> ruleMap) { this.id = id; this.src = src; this.map = ruleMap; } @Override public void configure() throws Exception { ChoiceDefinition cd = from(src).routeId(id).choice(); for (Entry<String, CPredicate> entry : map.entrySet()) { CPredicate predicate = entry.getValue(); LOG.debug("Predicate is: " + predicate); if (predicate.getNamespaces() == null) { LOG.debug("Predicate NS is null calling addwhen"); cd = addWhen(cd,predicate); } else { LOG.debug("Predicate NS is NOT null, calling addwhenN"); cd = addWhenN(cd,predicate); } } } public ChoiceDefinition addWhen(ChoiceDefinition cd, CPredicate predicate) { return cd.when() .xpath(predicate.getXpath()) .to(predicate.getdestination()).process(new Processor() { public void process(Exchange e) { LOG.debug("Received exchange: " + e.getIn()); //LOG.debug("Message body is: " + e.getIn().getBody()); LOG.info("routing using route id: " + e.getFromRouteId()); } }); } public ChoiceDefinition addWhenN(ChoiceDefinition cd, CPredicate predicate) { return cd.when() .xpath(predicate.getXpath(), predicate.getNamespaces()) .to(predicate.getdestination()).process(new Processor() { public void process(Exchange e) { LOG.debug("Received exchange: " + e.getIn()); //LOG.debug("Message body is: " + e.getIn().getBody()); LOG.info("routing using route id: " + e.getFromRouteId()); } }); } }