首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Tanuki服务包装器启动Camel OK并立即关闭它。

Tanuki服务包装器启动Camel OK并立即关闭它。
EN

Stack Overflow用户
提问于 2012-09-03 19:24:11
回答 2查看 1.1K关注 0票数 1

我正试图在tanuki服务包装上运行一个基于Camel (Spring )的项目,将其作为一个windows服务。我尝试了两种集成方法#1和#2: WrapperSimpleApp、WrapperStartStopApp,这两种方法都导致了以下行为:

Camel启动OK,包装立即关闭它!

起初,我怀疑这与Camel非守护进程线程有关,但在使用了集成方法和org.tanukisoftware.wrapper.WrapperStartStopApp.systemThreadCount系统属性之后,我意识到包装器关闭JVM的另一个原因。

,有人知道为什么吗?

下面是包装和骆驼日志-注意第2和第3行:

代码语言:javascript
复制
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 (独立的)上运行的一个线程转储:

代码语言:javascript
复制
"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
EN

回答 2

Stack Overflow用户

发布于 2012-09-04 05:21:14

从Apache:http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html阅读这个常见问题

票数 1
EN

Stack Overflow用户

发布于 2012-09-06 19:39:11

这个问题确实是由非守护进程线程组成的,这是因为Camel的启动方式。

Camel是使用oeg.apache.camel.spring.Main.start()而不是run()启动的。

start()只是启动Camel,依靠主线程来保持运行。这适用于在应用程序中运行。另一方面,run()阻塞主线程,直到Camel或JVM退出。

调用enableHangupSupport()来注册一个关机挂钩也是有用的,从而允许Camel在JVM退出时优雅地关闭。

我必须给信用是值得的:-)感谢超级专业团队的坦基爪哇服务包装,为我弄清楚这一点。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12253074

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档