我正在尝试在tanuki服务包装器上运行一个Camel(基于Spring)项目作为Windows服务。 我尝试了两种集成方法#1和#2:WrapperSimpleApp,WrapperStartStopApp,两者都导致了以下行为:
Camel开始正常,立即封包将其关闭!
起初我怀疑这与Camel非守护程序线程有关,但在使用集成方法和org.tanukisoftware.wrapper.WrapperStartStopApp.systemThreadCount系统属性后,我意识到包装器关闭JVM必然会有另一个原因
有人知道为什么吗?
这是包装器和Camel日志 - 注意第2行和第3行:
INFO | jvm 1 | 2012/09/01 20:39:45.643 | srvmain | 2012-09-01 20:39:45,596 INFO spring.SpringCamelContext Apache Camel 2.6.0 (CamelContext: main-camel-context) started in 1.450 seconds
INFO | jvm 1 | 2012/09/01 20:39:45.643 | srvmain | WrapperSimpleApp Debug: main method completed
INFO | jvm 1 | 2012/09/01 20:39:45.643 | srvmain | WrapperManager Debug: ShutdownHook started
INFO | jvm 1 | 2012/09/01 20:39:45.643 | srvmain | WrapperManager Debug: WrapperManager.stop(0) called by thread: Wrapper-Shutdown-Hook
INFO | jvm 1 | 2012/09/01 20:39:45.643 | srvmain | WrapperManager Debug: Send a packet STOP : 0
INFO | jvm 1 | 2012/09/01 20:39:45.643 | srvmain | WrapperManager Debug: Pausing for 1,000ms to allow a clean shutdown...
DEBUG | wrapperp | 2012/09/01 20:39:45.643 | srvmain | read a packet STOP : 0
DEBUG | wrapper | 2012/09/01 20:39:45.643 | srvmain | JVM requested a shutdown. (0)
DEBUG | wrapper | 2012/09/01 20:39:45.643 | srvmain | wrapperStopProcess(0, FALSE) called.
DEBUG | wrapper | 2012/09/01 20:39:45.643 | srvmain | Sending stop signal to JVM
DEBUG | wrapperp | 2012/09/01 20:39:45.643 | srvmain | send a packet STOP : NULL
INFO | jvm 1 | 2012/09/01 20:39:45.752 | srvmain | WrapperManager Debug: Received a packet STOP :
INFO | jvm 1 | 2012/09/01 20:39:45.752 | srvmain | WrapperManager Debug: Stopped checking for control events.
INFO | jvm 1 | 2012/09/01 20:39:46.735 | srvmain | WrapperManager Debug: Thread, Wrapper-Shutdown-Hook, handling the shutdown process.
INFO | jvm 1 | 2012/09/01 20:39:46.735 | srvmain | WrapperManager Debug: calling listener.stop()
INFO | jvm 1 | 2012/09/01 20:39:46.735 | srvmain | WrapperSimpleApp Debug: stop(0)
INFO | jvm 1 | 2012/09/01 20:39:46.735 | srvmain | WrapperManager Debug: returned from listener.stop() -> 0
INFO | jvm 1 | 2012/09/01 20:39:46.735 | srvmain | WrapperManager Debug: shutdownJVM(0) Thread: Wrapper-Shutdown-Hook
INFO | jvm 1 | 2012/09/01 20:39:46.735 | srvmain | WrapperManager Debug: wait for 0 shutdown locks to be released.
INFO | jvm 1 | 2012/09/01 20:39:46.735 | srvmain | WrapperManager Debug: Send a packet STOPPED : 0
DEBUG | wrapperp | 2012/09/01 20:39:46.735 | srvmain | read a packet STOPPED : 0
DEBUG | wrapper | 2012/09/01 20:39:46.735 | srvmain | JVM signaled that it was stopped.
INFO | jvm 1 | 2012/09/01 20:39:46.954 | srvmain | WrapperManager Debug: Closing backend connection.
INFO | jvm 1 | 2012/09/01 20:39:46.954 | srvmain | WrapperManager Debug: Closed backend socket (Normal): java.net.SocketException: socket closed
INFO | jvm 1 | 2012/09/01 20:39:46.954 | srvmain | WrapperManager Debug: Returned from backend handler.
DEBUG | wrapperp | 2012/09/01 20:39:46.954 | srvmain | socket read no code (closed?).
DEBUG | wrapperp | 2012/09/01 20:39:46.954 | srvmain | Closing backend socket.
INFO | jvm 1 | 2012/09/01 20:39:47.500 | srvmain | WrapperManager Debug: Server daemon shut down
INFO | jvm 1 | 2012/09/01 20:39:47.500 | srvmain | WrapperManager Debug: ShutdownHook complete
ERROR | wrapper | 2012/09/01 20:40:07.608 | srvmain | Shutdown failed: Timed out waiting for the JVM to terminate.
ERROR | wrapper | 2012/09/01 20:40:07.827 | srvmain | JVM did not exit on request, terminated
STATUS | wrapper | 2012/09/01 20:40:08.778 | srvmain | <-- Wrapper Stopped
这是我在Camel(独立)上运行的线程转储:
"RMI TCP Connection(idle)" daemon prio=6 tid=0x000000000f194800 nid=0x1a24 waiting on condition [0x000000001062e000]
"RMI TCP Connection(6)-10.244.123.73" daemon prio=6 tid=0x000000000f194000 nid=0x1218 runnable [0x000000001038e000]
"RMI TCP Connection(4)-10.244.123.73" daemon prio=6 tid=0x000000000f193000 nid=0x188c in Object.wait() [0x00000000104ad000]
"RMI TCP Connection(idle)" daemon prio=6 tid=0x000000000eb1f000 nid=0xbf8 waiting on condition [0x000000001020f000]
"JMX server connection timeout 20" daemon prio=6 tid=0x000000000e4e1800 nid=0x1804 in Object.wait() [0x00000000100af000]
"RMI TCP Connection(idle)" daemon prio=6 tid=0x000000000eba3000 nid=0x10e8 waiting on condition [0x000000000fe7e000]
"RMI Scheduler(0)" daemon prio=6 tid=0x000000000f5c3000 nid=0x103c waiting on condition [0x000000000ff8f000]
"RMI TCP Connection(idle)" daemon prio=6 tid=0x000000000e0d0800 nid=0xd5c waiting on condition [0x000000000fd1e000]
"Camel (main-camel-context) thread #1 - file://./toAggregator" daemon prio=6 tid=0x000000000e0bf800 nid=0x18e4 runnable [0x000000000dcaf000]
"Camel (main-camel-context) thread #0 - AggregateTimeoutChecker" daemon prio=6 tid=0x000000000ecad800 nid=0x1b54 waiting on condition [0x000000000fb6f
"RMI TCP Accept-0" daemon prio=6 tid=0x000000000d4e6800 nid=0x1ba0 runnable [0x000000000de0e000]
"RMI TCP Accept-7780" daemon prio=6 tid=0x000000000d586800 nid=0xff0 runnable [0x000000000e8fe000]
"RMI TCP Accept-0" daemon prio=6 tid=0x000000000d55e000 nid=0x38c runnable [0x000000000e7df000]
"Service Thread" daemon prio=6 tid=0x000000000b7d3800 nid=0x1980 runnable [0x0000000000000000]
"C2 CompilerThread1" daemon prio=10 tid=0x000000000b7d0800 nid=0x1be4 waiting on condition [0x0000000000000000]
"C2 CompilerThread0" daemon prio=10 tid=0x000000000b7c3800 nid=0x594 waiting on condition [0x0000000000000000]
"Attach Listener" daemon prio=10 tid=0x000000000b7c2800 nid=0x10bc runnable [0x0000000000000000]
"Signal Dispatcher" daemon prio=10 tid=0x000000000b7bb000 nid=0x1b2c waiting on condition [0x0000000000000000]
"Finalizer" daemon prio=8 tid=0x0000000002416000 nid=0x1b94 in Object.wait() [0x000000000cd5e000]
"Reference Handler" daemon prio=10 tid=0x000000000240f000 nid=0x9a0 in Object.wait() [0x000000000caae000]
"Thread-1" prio=6 tid=0x000000000e530800 nid=0xc50 runnable [0x000000000da7f000]
"DestroyJavaVM" prio=6 tid=0x000000000231f000 nid=0x199c in Object.wait() [0x00000000026ff000]
"VM Thread" prio=10 tid=0x000000000b732800 nid=0x17a0 runnable
"GC task thread#0 (ParallelGC)" prio=6 tid=0x0000000002365000 nid=0x1a94 runnable
"GC task thread#1 (ParallelGC)" prio=6 tid=0x0000000002367000 nid=0x4e8 runnable
"GC task thread#2 (ParallelGC)" prio=6 tid=0x0000000002368800 nid=0xf44 runnable
"GC task thread#3 (ParallelGC)" prio=6 tid=0x000000000236a000 nid=0xd30 runnable
"VM Periodic Task Thread" prio=10 tid=0x000000000d4fb800 nid=0x384 waiting on condition
答案 0 :(得分:1)
从Apache Camel阅读此常见问题解答: http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html
答案 1 :(得分:1)
嗯,由于Camel的启动方式,问题确实是非守护程序线程的湖泊。
Camel开始使用oeg.apache.camel.spring.Main.start()而不是run()。
start()只是启动Camel指望主线程以某种方式继续运行。这适用于在应用程序中运行时。 另一方面,run()阻塞主线程直到Camel或JVM退出。
调用enableHangupSupport()来注册一个关闭钩子以允许Camel在JVM出口上正常关闭也很有用。
我必须在信用到期时给予信任:-)感谢tanuki java服务包装的超级专业团队为我解决这个问题。