Hi Clauss,

I have done different tests to manualy start/stop the route. The tests I
have done are:

- I have tried all trying to access through the lifecycle to control the
status of the route if is started, starting..
- I have tried to create inside the route a separate thread to stop the
route as is indicated in the camel documentation but it still continues not
working.

Now but I'm doing is to stop the route using the next code through a
processor and removing the route of the context 

    /**
     * Stop manual route.
     * 
     * @param exchange
     *            the exchange
     * @param name
     *            the name
     */
    private void stopManualRoute(final Exchange exchange, final String name)
{
        if (stop == null) {
            stop = new Thread() {

                @Override
                public void run() {
                    try {
                        ModelCamelContext modelContext = (ModelCamelContext)
exchange.getContext();
                       
exchange.getContext().getInflightRepository().remove(exchange);
                        exchange.getContext().stopRoute(name);
                        RouteDefinition routedefinition =
modelContext.getRouteDefinition(name);
                       
routedefinition.setShutdownRunningTask(ShutdownRunningTask.CompleteAllTasks);
                        List<RouteDefinition> list = new
ArrayList<RouteDefinition>();
                        list.add(routedefinition);
                        modelContext.removeRouteDefinitions(list);
                       
                    } catch (Exception e) {
                        logger.error("Problem stopping the route " + name);
                    }
                }
            };
        }

And when I start the route I check if the route is started and is in the
camel context if not I try to load the route definition of another xml.


/**
     * Executes thread method to start the route
     */
    public synchronized void run() {
        try {
            
            ModelCamelContext modelContext = (ModelCamelContext)
camelContext;
            RouteDefinition manualRouteDefinition =
modelContext.getRouteDefinition("manualSendingReceivingFromRtcRoute");
            
            if (manualRouteDefinition != null) {
               
camelContext.startRoute("manualSendingReceivingFromRtcRoute");
            } else {
                // load route from XML and add them to the existing camel
context
                InputStream is =
getClass().getResourceAsStream("../src/main/resources/META-INF/spring/manualRtcRoute.xml");
                RoutesDefinition routes =
modelContext.loadRoutesDefinition(is);
                modelContext.addRouteDefinitions(routes.getRoutes());

               
camelContext.startRoute("manualSendingReceivingFromRtcRoute");
            }
            
        } catch (Exception e) {
            throw Throwables.propagate(e);
        }
    }

Can you provide a sample complete or loading the routes from an XML I think
may be this solution can work for me.

Thanks





--
View this message in context: 
http://camel.465427.n5.nabble.com/Stop-manually-camel-route-tp5753505p5753571.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to