Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B7BD4F485 for ; Mon, 25 Mar 2013 15:50:34 +0000 (UTC) Received: (qmail 7943 invoked by uid 500); 25 Mar 2013 15:50:34 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 7906 invoked by uid 500); 25 Mar 2013 15:50:34 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 7897 invoked by uid 99); 25 Mar 2013 15:50:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Mar 2013 15:50:34 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of cwolf.algo@gmail.com designates 209.85.128.174 as permitted sender) Received: from [209.85.128.174] (HELO mail-ve0-f174.google.com) (209.85.128.174) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Mar 2013 15:50:28 +0000 Received: by mail-ve0-f174.google.com with SMTP id jz10so2340886veb.5 for ; Mon, 25 Mar 2013 08:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=M+z17s6oG7aePbGxdJt55L6iZIZfKxSdEQQZQphCox0=; b=nUKJh78sXZ6x0Ba03VqEawe8wA2K0o6Zuh3WDxtxknHqb8185swdSfiXJ2sJNGpN1D 1+TSw6yszqB6N4C3f+YZaKSu0XHlf7F7YR98hZJRMXR0KlJp6mCU5iMOIwpvMeETUAo3 2j0M6mkrOyAkcL4C9uag4GrvvTwS0NNMzWORbiFV3RD8tG4FZ8ouJxUfwISaNYTojZfd dsxk76dGemzmVNCIFt5t8uLLio/ofCCHitHEZYr4q3kqmwni/iO7HrrinQGrrMKi5P7L FuSMIQ9/0q5lQCkAeDTcheI1Eh0dNE977VUqn3KZEeH4wlpLzIf7T/GzMN6nGZ//Yxhz j/Wg== MIME-Version: 1.0 X-Received: by 10.58.44.194 with SMTP id g2mr16321404vem.1.1364226607967; Mon, 25 Mar 2013 08:50:07 -0700 (PDT) Received: by 10.58.207.39 with HTTP; Mon, 25 Mar 2013 08:50:07 -0700 (PDT) In-Reply-To: References: Date: Mon, 25 Mar 2013 11:50:07 -0400 Message-ID: Subject: Re: How can I perform immediate shutdown of a context and all it's routes and services, etc.? From: Chris Wolf To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Claus, Ok, that worked - thanks a lot. BTW, the unit test is for testing custom RoutePolicy. The route in the test looks like: from("seda:foo").routeId("foo").noAutoStartup().routePolicy(policy) .loop(10).copy().delay(1000) .log("*** loop ${property.CamelLoopIndex}") .to("mock:foo"); The RoutePolicy suspends the route, then resume it after a period of time - it performs this suspend/resume cycle in a loop. I notice that this route, using the loop() method only does the 10 iterations and does not start from the top again after being resumed, which I guess I should have expected. Is there a way to restart the route from the top upon resuming? Or do you recommend any other "busy work" kind of route to use for RoutePolicy testing? Thanks, Chris On Sat, Mar 23, 2013 at 4:02 AM, Claus Ibsen wrote: > Hi > > Just set the shutdown timeout to 1 milli second (or 1 sec) etc. And > just call stop on CamelContext. > > And if you extend the CamelTestSupport classes for your unit tests. > There may be a method you can override and return 1 to indiciate 1 sec > timeout. > > > > On Fri, Mar 22, 2013 at 5:23 PM, Chris Wolf wrote: >> I am implementing some unit tests and if things go wrong I just want >> to shutdown ASAP without regard for inconsistent >> states, etc. There's no easy hook in DefaultShutDownStrategy to do >> that because you need to know the route >> startup order, so I ended up with this convoluted code (that I kick >> off in a separate thread). It doesn't work, BTW. >> >> DefaultRouteStartupOrder rsuo = null; >> int startOrder = 0; >> List suo = new >> ArrayList(); >> List routes = context.getRoutes(); >> for (Route route : routes) { >> List services = route.getServices(); >> for (Service service : services) { >> if (service instanceof RouteService) { >> rsuo = new >> DefaultRouteStartupOrder(startOrder, route, (RouteService) service); >> suo.add(rsuo); >> } >> } >> startOrder++; >> } >> ShutdownStrategy sds = context.getShutdownStrategy(); >> sds.shutdownForced(context, suo); >> >> I know there must be an easier way, but I haven't found such. Any ideas? >> >> Thanks, >> >> Chris > > > > -- > Claus Ibsen > ----------------- > Red Hat, Inc. > FuseSource is now part of Red Hat > Email: cibsen@redhat.com > Web: http://fusesource.com > Twitter: davsclaus > Blog: http://davsclaus.com > Author of Camel in Action: http://www.manning.com/ibsen