2 Replies Latest reply on Jun 17, 2013 12:10 PM by Thorsten Kunz

    Graceful undeploy/shutdown notification?

    Thorsten Kunz Novice

      Hi,

       

      I have a component that is called from a cron schedule. Now this call can take quite some time to complete (most of the time hours) and when I want to redeploy the archive it is waiting forever for the background threads to complete.

      The component actually provides methods to gracefully shutdown the running call but the question is how can I trigger the shutdown call? I tried @PostContruct lifecycle but that does not seem to work. Are there any other SwitchYard specific lifecycle hooks I can tap into to shutdown that long running component call in a reasonable way?

       

      Thanks

        • 1. Re: Graceful undeploy/shutdown notification?
          Keith Babo Master

          Just to confirm - are you referring to the default shutdown strategy in Camel which prints stuff like "Waiting as there are n in flight exchanges ..." ?  There was a JIRA posted recently which would allow for the wait time to be configurable - I think the default is like five minutes or something. 

          • 2. Re: Graceful undeploy/shutdown notification?
            Thorsten Kunz Novice

            In a way yes. Due to the long running process in a component this messag appears and since the process is very long running always ticks down to 0.

             

            For now I have solved the issue with an @ApplicationScoped component that holds 1 AtomicBoolean "shutdown" that is set to true in a @PreDestroy method and in several places of the app other components check if they are supposed to cancel whatever long running action they execute.

            While I do get a few errors due to already removed components and failed injection it seems to work ok in general.

             

            It would be ideal if there would be a @PreComponentShutdown annotation that would get called on all components before the system actually starts to tear down the deployment. Once all annotated methods have been executed then tear everything down. Would give the chance to handle the shutdown process more smoothly. But maybe there is already some way to do this that I just don't see?

             

            Thanks