Hi All,
I've been reading through Camel in action today but am a bit confused about
how to shut down my application. I have it working but ultimately my
understanding is lacking.
My entry point into the application originally looked like below. It loads a
spring application context.
public class Main extends org.apache.camel.spring.Main {
public static void main(String... args) throws Exception {
new Main().run(args);
Using this approach the application just lives indefinitely.
The first thing I tried was to add the following into my application
context...
<bean id="shutdown"
class="org.apache.camel.impl.DefaultShutdownStrategy">
<property name="timeout" value="10"/>
</bean>
<camelContext trace="true" id="camel"
xmlns="http://camel.apache.org/schema/spring">
<package>org.apache.camel.etl.route</package>
</camelContext>
This did not work and my application still lived after executing the route.
The next thing I tried was to change my main....
public class Main extends org.apache.camel.spring.Main {
Main main = new Main();
main.enableHangupSupport();
main.start();
main.run(args);
main.stop();
This did not work and my application still died straight away before
executing the route.
The next thing I tried was to change my main again....
public class Main extends org.apache.camel.spring.Main {
String filename = "META-INF/spring/camel-context.xml";
AbstractXmlApplicationContext spring =
new ClassPathXmlApplicationContext(filename);
spring.start();
Thread.sleep(30000);
spring.stop();
spring.destroy();
Success, because of the sleep the application runs and then before it shuts
down it waits to check what routes have not completed because in my routes I
have specified .shutdownRoute(ShutdownRoute.Defer).
So I guess I can keep my application like this as it does what i want. But
appreciate if someone could respond in regards to why the application didn't
work properly for first two attempts. I am in particular interested as to
why the bean injection method in the spring application context files did
not work. And also why I have to allow for a sleep time in camel before
trying to shut down.
thanks for your time
I've been reading through Camel in action today but am a bit confused about
how to shut down my application. I have it working but ultimately my
understanding is lacking.
My entry point into the application originally looked like below. It loads a
spring application context.
public class Main extends org.apache.camel.spring.Main {
public static void main(String... args) throws Exception {
new Main().run(args);
Using this approach the application just lives indefinitely.
The first thing I tried was to add the following into my application
context...
<bean id="shutdown"
class="org.apache.camel.impl.DefaultShutdownStrategy">
<property name="timeout" value="10"/>
</bean>
<camelContext trace="true" id="camel"
xmlns="http://camel.apache.org/schema/spring">
<package>org.apache.camel.etl.route</package>
</camelContext>
This did not work and my application still lived after executing the route.
The next thing I tried was to change my main....
public class Main extends org.apache.camel.spring.Main {
Main main = new Main();
main.enableHangupSupport();
main.start();
main.run(args);
main.stop();
This did not work and my application still died straight away before
executing the route.
The next thing I tried was to change my main again....
public class Main extends org.apache.camel.spring.Main {
String filename = "META-INF/spring/camel-context.xml";
AbstractXmlApplicationContext spring =
new ClassPathXmlApplicationContext(filename);
spring.start();
Thread.sleep(30000);
spring.stop();
spring.destroy();
Success, because of the sleep the application runs and then before it shuts
down it waits to check what routes have not completed because in my routes I
have specified .shutdownRoute(ShutdownRoute.Defer).
So I guess I can keep my application like this as it does what i want. But
appreciate if someone could respond in regards to why the application didn't
work properly for first two attempts. I am in particular interested as to
why the bean injection method in the spring application context files did
not work. And also why I have to allow for a sleep time in camel before
trying to shut down.
thanks for your time