You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by raffi <ra...@gmail.com> on 2015/12/09 22:34:38 UTC

Shutdown hook in FatJarRouter - Springboot

I'm using Camel 2.16.0 with springboot 1.2.6-RELEASE, the app is packaged
and executed using FatJarRouter.

My routes run properly, but I'm having an issue with shutdown. I can
shutdown Camel using setShutdownNowOnTimeout() via JMX, that's not a
problem. But when shutting down Springboot using http://.../shutdown, it
gets stuck closing 'metricsExecutor' pool, and the JVM does not exit. I
don't believe this problem is related to Camel, but to address it, I want to
test shutting down this thread pool manually, so I need a way to hook into
the springboot's shutdown process.

##last line in log file where JVM hangs
2015-12-09 13:27:56,607 INFO  ThreadPoolTaskExecutor - Shutting down
ExecutorService 'metricsExecutor'

This is how we launch Camel in Springboot using FatJarRouter; can I hook
into the shutdown process to close 'metricsExecutor' bean manually?

@ImportResource(value={"classpath:META-INF/spring/camel-context.xml"})
@SpringBootApplication
public class MySpringBootRouter extends FatJarRouter {

   public static void main(String[] options){
      MySpringBootRouter router = new MySpringBootRouter();
   }
}

Raffi




--
View this message in context: http://camel.465427.n5.nabble.com/Shutdown-hook-in-FatJarRouter-Springboot-tp5774880.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Shutdown hook in FatJarRouter - Springboot

Posted by raffi <ra...@gmail.com>.
After some more digging, here's what I found.

Invoking stop() on camel context shuts down all routes gracefully as per the
log, but two problems I'm seeing after routes are shut down is (I believe)
the cause for JVM not shutting down:

#1) ActiveMQ connection remains open

#2) AbstractInactivityMonitor is constantly checking every 10s

We use Springboot config for ActiveMQ instead of the typical <bean> config:

#application.properties
spring.activemq.broker-url=tcp://amq1:61107
spring.activemq.user=amq
spring.activemq.password=xxx1
spring.activemq.pooled=true


And our camel route config, just a short sample, but key point: no JMS
connection pool info defined here:

  <route autoStartup="true"
            id="readFromQueueThenTODb">
        <from uri="activemq:queue:fromTheForce"/>
  </route>


I'm not sure why the activemq connection is not closing, is there anything
wrong with this config that causing the inability to not shut down cleanly?
 



--
View this message in context: http://camel.465427.n5.nabble.com/Shutdown-hook-in-FatJarRouter-Springboot-tp5774880p5774884.html
Sent from the Camel - Users mailing list archive at Nabble.com.