Camel: check if context is running

@drse / updated May 12, 2015

Share:  

Use the status ENUM: http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/ServiceStatus.html


CamelContext context = new DefaultCamelContext()

// ... add routes

Runtime.runtime.addShutdownHook({ context.stop() })

if (context.status == org.apache.camel.ServiceStatus.Stopped ||
  context.status == org.apache.camel.ServiceStatus.Suspended) {
  context.start()
}