如何优雅地释放CXF-Endpoint的端口?
How to release port of CXF-Endpoint gracefully?
我正在使用 CXF 来简单地发布端点,比方说:
final String uri = http://myServiceEndpoint:12345
final Endpoint endpoint = Endpoint.publish(uri, MyService());
经过一些处理后,我想关闭端点并释放端口:
endpoint.stop();
在 "stop" 指令之后,另一个服务应立即启动并绑定上述端口,但我收到以下错误:
Bind to port 12345 failed: java.net.BindException: Address already in use: bind
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:455)
at java.base/sun.nio.ch.Net.bind(Net.java:447)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
at org.apache.http.impl.nio.reactor.DefaultListeningIOReactor.processSessionRequests(DefaultListeningIOReactor.java:243)
at org.apache.http.impl.nio.reactor.DefaultListeningIOReactor.processEvents(DefaultListeningIOReactor.java:144)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:348)
at de.hacon.dds.actor.net.http.hc.HttpApacheManager.lambda$startTheReactorQuaid(HttpApacheManager.java:135)
at java.base/java.lang.Thread.run(Thread.java:834)
如何立即释放端口?
同时我可以解决优雅释放端口的问题:
endpoint.stop();
JettyHTTPServerEngineFactory.destroyForPort(myPort);
额外调用destroy方法端口立即释放,其他服务可以绑定同一个端口
我正在使用 CXF 来简单地发布端点,比方说:
final String uri = http://myServiceEndpoint:12345
final Endpoint endpoint = Endpoint.publish(uri, MyService());
经过一些处理后,我想关闭端点并释放端口:
endpoint.stop();
在 "stop" 指令之后,另一个服务应立即启动并绑定上述端口,但我收到以下错误:
Bind to port 12345 failed: java.net.BindException: Address already in use: bind
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:455)
at java.base/sun.nio.ch.Net.bind(Net.java:447)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
at org.apache.http.impl.nio.reactor.DefaultListeningIOReactor.processSessionRequests(DefaultListeningIOReactor.java:243)
at org.apache.http.impl.nio.reactor.DefaultListeningIOReactor.processEvents(DefaultListeningIOReactor.java:144)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:348)
at de.hacon.dds.actor.net.http.hc.HttpApacheManager.lambda$startTheReactorQuaid(HttpApacheManager.java:135)
at java.base/java.lang.Thread.run(Thread.java:834)
如何立即释放端口?
同时我可以解决优雅释放端口的问题:
endpoint.stop();
JettyHTTPServerEngineFactory.destroyForPort(myPort);
额外调用destroy方法端口立即释放,其他服务可以绑定同一个端口