You are missing using the routeId. When you create your route you need to:

from(uri + "?splitEntries=false&consumer.initialDelay=0").
                marshal().rss().
                to("mock:result").routeId("routeId");

Then when you remove the route you use the same routeId string.

I hope this helps.

-josh.




On 26/04/2011 15:13, "Jeff Segal" <jeffrey.se...@gmail.com> wrote:

>Hi all,
>
>I have written a service bean which can add and remove Routes dynamically
>and I'd like to know if my approach was "kosher" in terms of best
>practices.
>It's not exactly pretty, but it does work. Here are the two classes:
>
>@Component
>public class RssRouter implements CamelContextAware {
>
>    protected CamelContext camelContext;
>    RssRouteBuilder rssRouteBuilder;
>
>    final Logger log = Logger.getLogger(this.getClass());
>
>    public void addFeed(String uri) throws Exception {
>        log.info("Adding feed '" + uri + "'");
>        uri = "rss://" + uri;
>
> camelContext.addRouteDefinition(rssRouteBuilder.getRouteDefinition(uri));
>    }
>
>    public void removeFeed(String uri) throws Exception {
>        log.info("Removing feed '" + uri + "'");
>        uri = "rss://" + uri;
>        camelContext.removeRoute(uri);
>    }
>
>    public CamelContext getCamelContext() {
>        return camelContext;
>    }
>
>    public void setCamelContext(CamelContext camelContext) {
>        this.camelContext = camelContext;
>    }
>
>    public void setRssRouteBuilder(RssRouteBuilder rssRouteBuilder) {
>        this.rssRouteBuilder = rssRouteBuilder;
>    }
>
>}
>
>public class RssRouteBuilder extends RouteBuilder {
>
>    @Override
>    public void configure() throws Exception {
>// Do nothing here since we are creating routes dynamically
>    }
>
>    RouteDefinition getRouteDefinition(String uri) {
>        return from(uri + "?splitEntries=false&consumer.initialDelay=0").
>                marshal().rss().
>                to("mock:result");
>    }
>
>}
>
>Thanks!
>Jeff

Reply via email to