How to reuse cxf resources and underline HTTP connection?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to reuse cxf resources and underline HTTP connection?

Sigmund God
A typical CXF init codes in client look like this:

ClientProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> factory.setServiceClass(Service.class);
> factory.setAddress(address);
> Service service = (Service) factory.create();
> Client client = ClientProxy.getClient(service);
> HTTPConduit conduit = (HTTPConduit) client.getConduit();
> HTTPClientPolicy policy = conduit.getClient();
> policy.setConnectionTimeout(60000);
> policy.setReceiveTimeout(60000);
> conduit.setClient(policy);


My question is, what instance can be reused if I need to call many web
services?
seems like ClientProxyFactoryBean cannot be reused because every instance
of it  is coressponding to a particular Service.
I guess instance of Service here is the only instance can be reused, am I
correct?

Another question is, what's the proper values of various timeout of
HTTPClientPolicy?

Most important, how can I reused HTTP connection that CXF created?

Many questions here, but point is, how can reduce resource occupy of CXF
asap?

Thanks u all very much.

Bests.
Reply | Threaded
Open this post in threaded view
|

Re: How to reuse cxf resources and underline HTTP connection?

Sigmund God
Any any help me, pls?

Thank u so much!

On Wed, May 10, 2017 at 4:27 PM, Sigmund God <[hidden email]> wrote:

> A typical CXF init codes in client look like this:
>
> ClientProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>> factory.setServiceClass(Service.class);
>> factory.setAddress(address);
>> Service service = (Service) factory.create();
>> Client client = ClientProxy.getClient(service);
>> HTTPConduit conduit = (HTTPConduit) client.getConduit();
>> HTTPClientPolicy policy = conduit.getClient();
>> policy.setConnectionTimeout(60000);
>> policy.setReceiveTimeout(60000);
>> conduit.setClient(policy);
>
>
> My question is, what instance can be reused if I need to call many web
> services?
> seems like ClientProxyFactoryBean cannot be reused because every instance
> of it  is coressponding to a particular Service.
> I guess instance of Service here is the only instance can be reused, am I
> correct?
>
> Another question is, what's the proper values of various timeout of
> HTTPClientPolicy?
>
> Most important, how can I reused HTTP connection that CXF created?
>
> Many questions here, but point is, how can reduce resource occupy of CXF
> asap?
>
> Thanks u all very much.
>
> Bests.
>
Reply | Threaded
Open this post in threaded view
|

Re: How to reuse cxf resources and underline HTTP connection?

Sigmund God
Can I reuse ReflectionServiceFactoryBean?



On Fri, May 12, 2017 at 6:42 PM, Sigmond Hola <[hidden email]> wrote:

> Any any help me, pls?
>
> Thank u so much!
>
> On Wed, May 10, 2017 at 4:27 PM, Sigmund God <[hidden email]>
> wrote:
>
>> A typical CXF init codes in client look like this:
>>
>> ClientProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>>> factory.setServiceClass(Service.class);
>>> factory.setAddress(address);
>>> Service service = (Service) factory.create();
>>> Client client = ClientProxy.getClient(service);
>>> HTTPConduit conduit = (HTTPConduit) client.getConduit();
>>> HTTPClientPolicy policy = conduit.getClient();
>>> policy.setConnectionTimeout(60000);
>>> policy.setReceiveTimeout(60000);
>>> conduit.setClient(policy);
>>
>>
>> My question is, what instance can be reused if I need to call many web
>> services?
>> seems like ClientProxyFactoryBean cannot be reused because every instance
>> of it  is coressponding to a particular Service.
>> I guess instance of Service here is the only instance can be reused, am I
>> correct?
>>
>> Another question is, what's the proper values of various timeout of
>> HTTPClientPolicy?
>>
>> Most important, how can I reused HTTP connection that CXF created?
>>
>> Many questions here, but point is, how can reduce resource occupy of CXF
>> asap?
>>
>> Thanks u all very much.
>>
>> Bests.
>>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to reuse cxf resources and underline HTTP connection?

deki-2
Hi Sigmund,

it's not clear what you want to optimize. You need a bean per service.

Do you want to use some kind of HTTP connection pooling? Check if Keep-Alive is working properly.

You can specify the timeout properties as described in the documentation:
http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport(includingSSLsupport)-Theclientelement

Regards
Dennis
Reply | Threaded
Open this post in threaded view
|

Re: How to reuse cxf resources and underline HTTP connection?

Sigmund God
Hi Dennis,

Thank you so much for your prompt response.

"A bean per service", this mean I can declare my service as a instance
variable and reuse it for every call on this service, it is thread-safe,
right?

Current I'm working on a project that using cxf as webservice
implementation. I found out this code:

ClientProxyFactoryBean factory = new JaxWsProxyFactoryBean();

> factory.setServiceClass(Service.class);
> factory.setAddress(address);
> Service service = (Service) factory.create();
> Client client = ClientProxy.getClient(service);
> HTTPConduit conduit = (HTTPConduit) client.getConduit();
> HTTPClientPolicy policy = conduit.getClient();
> policy.setConnectionTimeout(60000);
> policy.setReceiveTimeout(60000);
> conduit.setClient(policy);
>

are writing within a method of service, so will create service everytime
when u call it!

I think maybe I can declare Service as a instance variable, only
instantiate one time,  and reuse it for upcome invoke.

That's why I want to know if those codes are thread-safe.

Thanks again.

Best regards.
--Sig


On Tue, May 23, 2017 at 4:39 PM, Dennis Kieselhorst <[hidden email]> wrote:

> Hi Sigmund,
>
> it's not clear what you want to optimize. You need a bean per service.
>
> Do you want to use some kind of HTTP connection pooling? Check if
> Keep-Alive is working properly.
>
> You can specify the timeout properties as described in the documentation:
> http://cxf.apache.org/docs/client-http-transport-
> including-ssl-support.html#ClientHTTPTransport(includingSSLsupport)-
> Theclientelement
>
> Regards
> Dennis
>
Reply | Threaded
Open this post in threaded view
|

Re: How to reuse cxf resources and underline HTTP connection?

deki-2
> "A bean per service", this mean I can declare my service as a instance
> variable and reuse it for every call on this service, it is thread-safe,
> right?

Please read: http://cxf.apache.org/faq.html#FAQ-AreJAX-WSclientproxiesthreadsafe?

Regards
Dennis
Reply | Threaded
Open this post in threaded view
|

Re: How to reuse cxf resources and underline HTTP connection?

Sigmund God
Hi Dennis,

Thank u so much for the link.
I think its thread-safe for me.

Best regards.
--Sig

On Wed, May 24, 2017 at 7:32 PM, Dennis Kieselhorst <[hidden email]> wrote:

> > "A bean per service", this mean I can declare my service as a instance
> > variable and reuse it for every call on this service, it is thread-safe,
> > right?
>
> Please read: http://cxf.apache.org/faq.html#FAQ-AreJAX-
> WSclientproxiesthreadsafe?
>
> Regards
> Dennis
>