You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Andrei Shakirin <as...@talend.com> on 2015/03/12 17:01:56 UTC

JettyHTTPDestination: shutdown() leaves JettyEngine instance running even without active endpoints

Hi,

Scenario: standalone CXF service registers endpoint using following code:
...
        Object implementor = new GreeterSoapMessageProvider();
        String address = "http://localhost:9000/SoapContext/SoapPort1";
        Endpoint ep = Endpoint.publish(address, implementor); 
...

The service starts Jetty instance and uses JettyHTTPDestination - that's fine.

After some activities, code closes endpoint using ep.stop().

The user expectation is that JettyEngine will be closed and after exiting from main() application will be finished.
Currently Endpoint.stop() unregisters listeners and message observers, removes endpoint path from the destination registry, but leaves JettyEngine running. As result some qtp threads continue to run and service application hangs after exiting from main() method.

Are there any special reason for such behaviour? Does it makes sense to shutdown JettyEngine when no active endpoints are there at least for standalone deployment?

Regards,
Andrei.


RE: JettyHTTPDestination: shutdown() leaves JettyEngine instance running even without active endpoints

Posted by Andrei Shakirin <as...@talend.com>.
Yep, that makes sense.

Thanks, Dan!

> -----Original Message-----
> From: Daniel Kulp [mailto:dkulp@apache.org]
> Sent: Mittwoch, 18. März 2015 17:04
> To: users@cxf.apache.org; Andrei Shakirin
> Subject: Re: JettyHTTPDestination: shutdown() leaves JettyEngine instance
> running even without active endpoints
> 
> 
> > On Mar 12, 2015, at 12:01 PM, Andrei Shakirin <as...@talend.com>
> wrote:
> >
> > Hi,
> >
> > Scenario: standalone CXF service registers endpoint using following code:
> > ...
> >        Object implementor = new GreeterSoapMessageProvider();
> >        String address = "http://localhost:9000/SoapContext/SoapPort1";
> >        Endpoint ep = Endpoint.publish(address, implementor); ...
> >
> > The service starts Jetty instance and uses JettyHTTPDestination - that's fine.
> >
> > After some activities, code closes endpoint using ep.stop().
> >
> > The user expectation is that JettyEngine will be closed and after exiting from
> main() application will be finished.
> > Currently Endpoint.stop() unregisters listeners and message observers,
> removes endpoint path from the destination registry, but leaves JettyEngine
> running. As result some qtp threads continue to run and service application
> hangs after exiting from main() method.
> >
> > Are there any special reason for such behaviour? Does it makes sense to
> shutdown JettyEngine when no active endpoints are there at least for
> standalone deployment?
> 
> It kind of depends….    If you KNOW you will not then start another service on
> that port for at least 30 seconds, we could shut down the port.   However, if you
> try to start another service within that time period, it may not fully startup and
> there is no way to determine if it was actually successful or not.
> 
> That said, in the above case, you would still have stuff “running”.   To fully
> shutdown, you should grab the CXF bus and shut that down:
> 
> BusFactory.getThreadDefaultBus().shutdown();
> 
> I believe that would then shut down the Jetty server as well.
> 
> 
> --
> Daniel Kulp
> dkulp@apache.org - http://dankulp.com/blog Talend Community Coder -
> http://coders.talend.com


Re: JettyHTTPDestination: shutdown() leaves JettyEngine instance running even without active endpoints

Posted by Daniel Kulp <dk...@apache.org>.
> On Mar 12, 2015, at 12:01 PM, Andrei Shakirin <as...@talend.com> wrote:
> 
> Hi,
> 
> Scenario: standalone CXF service registers endpoint using following code:
> ...
>        Object implementor = new GreeterSoapMessageProvider();
>        String address = "http://localhost:9000/SoapContext/SoapPort1";
>        Endpoint ep = Endpoint.publish(address, implementor); 
> ...
> 
> The service starts Jetty instance and uses JettyHTTPDestination - that's fine.
> 
> After some activities, code closes endpoint using ep.stop().
> 
> The user expectation is that JettyEngine will be closed and after exiting from main() application will be finished.
> Currently Endpoint.stop() unregisters listeners and message observers, removes endpoint path from the destination registry, but leaves JettyEngine running. As result some qtp threads continue to run and service application hangs after exiting from main() method.
> 
> Are there any special reason for such behaviour? Does it makes sense to shutdown JettyEngine when no active endpoints are there at least for standalone deployment?

It kind of depends….    If you KNOW you will not then start another service on that port for at least 30 seconds, we could shut down the port.   However, if you try to start another service within that time period, it may not fully startup and there is no way to determine if it was actually successful or not.   

That said, in the above case, you would still have stuff “running”.   To fully shutdown, you should grab the CXF bus and shut that down:

BusFactory.getThreadDefaultBus().shutdown();

I believe that would then shut down the Jetty server as well.


-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com