You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by MaWenPeng <ma...@163.com> on 2008/12/24 15:04:51 UTC

About HTTP Connection Pool Problem Of Axis2 Client

  Hello,

    In my programs(Servlet,JSP or Java Application), I find that the Axis2 Client HTTP Connection Pool does not work well.
    I create WebService Axis2 client Stubs with ADB bindings. Each time when the stub accesses the WebService, the HTTP Connections created by the stub could NOT be reused or closed. Then there are a lot of freezed HTTP Connections. I can see the connections' status in my FireWall.
    For a long time, I find out that the MultiThreadedHttpConnectionManager object should be a static one.
    So I make some changes in org.apache.axis2.transport.http.AbstractHTTPSender.java:
        Define a static MultiThreadedHttpConnectionManager in it;
        In getHttpClient(MessageContext msgContext) methd, use this static MultiThreadedHttpConnectionManager;
    Also, I make some changes in MultiThreadedHttpConnectionManager.java:
        Increase DEFAULT_MAX_HOST_CONNECTIONS and DEFAULT_MAX_TOTAL_CONNECTIONS numbers.
    Things change a lot. The MultiThreadedHttpConnectionManager manages the HTTP Connection pool excellently.

    The attachments are the files I have changed.
    In AbstractHTTPSender.java: Line 70 and 447
    In MultiThreadedHttpConnectionManager.java: Line 73 and 76

    I hope this will make some help to Axis2 project.
 

Re: Re: About HTTP Connection Pool Problem Of Axis2 Client

Posted by Andreas Veithen <an...@gmail.com>.
Hi,

I'm not sure that using the same stub instance is the correct
approach. There is an interesting discussion about this here: [1]. The
important point is to use the same ConfigurationContext instance,
because this makes sure that the same HTTP sender instance and
therefore the same connection manager instance is used.

About the maximum number of connections, 2 is the default value for
the maximum number of connections to a given HTTP server. This is
actually required by the HTTP specifications: a client should not keep
open more than 2 connections to a single HTTP server.

Andreas

[1] http://markmail.org/message/57afv4yi3t76b7nk

On Sun, Dec 28, 2008 at 05:02, MaWenPeng <ma...@163.com> wrote:
> Hi,Andreas,
>
> You're right. The truth is the org.apache.axis2.client.Stub object should be
> a static one to reuse the connection manager.
> Formerly I didn't make the stub object to be static. It's a mistake.
> The new problem is the default max connections of a connection manager is
> only 2. It's not large enough for most circumstances.
> I think in AbstractHTTPSender#getHttpClient method we should increase this
> number.
> How about your idea? Thanks!
>
> Best Regards,
>
> WenPeng
>
>
>
> 2008-12-27,"Andreas Veithen" <an...@gmail.com> :
>>Hi,
>>
>>Please note that the HTTP sender already supports reusing the
>>connection manager. This can be enabled by setting the
>>REUSE_HTTP_CLIENT option. See the code in the first part of the
>>AbstractHTTPSender#getHttpClient method.
>>
>>Regards,
>>
>>Andreas
>>
>>On Wed, Dec 24, 2008 at 15:04, MaWenPeng <ma...@163.com> wrote:
>>>   Hello,
>>>     In my programs(Servlet,JSP or Java Application), I find that the
>>> Axis2
>>> Client HTTP Connection Pool does not work well.
>>>     I create WebService Axis2 client Stubs with ADB bindings. Each time
>>> when
>>> the stub accesses the WebService, the HTTP Connections created by the
>>> stub
>>> could NOT be reused or closed. Then there are a lot of freezed HTTP
>>> Connections. I can see the connections' status in my FireWall.
>>>     For a long time, I find out that the
>>> MultiThreadedHttpConnectionManager
>>> object should be a static one.
>>>     So I make some changes in
>>> org.apache.axis2.transport.http.AbstractHTTPSender.java:
>>>         Define a static MultiThreadedHttpConnectionManager in it;
>>>         In getHttpClient(MessageContext msgContext) methd, use this
>>> static
>>> MultiThreadedHttpConnectionManager;
>>>     Also, I make some changes in MultiThreadedHttpConnectionManager.java:
>>>         Increase DEFAULT_MAX_HOST_CONNECTIONS and
>>> DEFAULT_MAX_TOTAL_CONNECTIONS numbers.
>>>     Things change a lot. The MultiThreadedHttpConnectionManager manages
>>> the
>>> HTTP Connection pool excellently.
>>>     The attachments are the files I have changed.
>>>     In AbstractHTTPSender.java: Line 70 and 447
>>>     In MultiThreadedHttpConnectionManager.java: Line 73 and 76
>>>     I hope this will make some help to Axis2 project.
>>>
>>>
>>> ________________________________
>>> [广告] 重奖 悬赏kfc3v3 球衣
>
>
> ________________________________
> 网易免费邮,全球最大的中文免费邮箱

Re:Re: About HTTP Connection Pool Problem Of Axis2 Client

Posted by MaWenPeng <ma...@163.com>.
Hi,Andreas,

You're right. The truth is the org.apache.axis2.client.Stub object should be a static one to reuse the connection manager.
Formerly I didn't make the stub object to be static. It's a mistake. 
The new problem is the default max connections of a connection manager is only 2. It's not large enough for most circumstances.
I think in AbstractHTTPSender#getHttpClient method we should increase this number.
How about your idea? Thanks!

Best Regards,

WenPeng





2008-12-27,"Andreas Veithen" <an...@gmail.com> :
>Hi,
>
>Please note that the HTTP sender already supports reusing the
>connection manager. This can be enabled by setting the
>REUSE_HTTP_CLIENT option. See the code in the first part of the
>AbstractHTTPSender#getHttpClient method.
>
>Regards,
>
>Andreas
>
>On Wed, Dec 24, 2008 at 15:04, MaWenPeng <ma...@163.com> wrote:
>>   Hello,
>>     In my programs(Servlet,JSP or Java Application), I find that the Axis2
>> Client HTTP Connection Pool does not work well.
>>     I create WebService Axis2 client Stubs with ADB bindings. Each time when
>> the stub accesses the WebService, the HTTP Connections created by the stub
>> could NOT be reused or closed. Then there are a lot of freezed HTTP
>> Connections. I can see the connections' status in my FireWall.
>>     For a long time, I find out that the MultiThreadedHttpConnectionManager
>> object should be a static one.
>>     So I make some changes in
>> org.apache.axis2.transport.http.AbstractHTTPSender.java:
>>         Define a static MultiThreadedHttpConnectionManager in it;
>>         In getHttpClient(MessageContext msgContext) methd, use this static
>> MultiThreadedHttpConnectionManager;
>>     Also, I make some changes in MultiThreadedHttpConnectionManager.java:
>>         Increase DEFAULT_MAX_HOST_CONNECTIONS and
>> DEFAULT_MAX_TOTAL_CONNECTIONS numbers.
>>     Things change a lot. The MultiThreadedHttpConnectionManager manages the
>> HTTP Connection pool excellently.
>>     The attachments are the files I have changed.
>>     In AbstractHTTPSender.java: Line 70 and 447
>>     In MultiThreadedHttpConnectionManager.java: Line 73 and 76
>>     I hope this will make some help to Axis2 project.
>>
>>
>> ________________________________
>> [广告] 重奖 悬赏kfc3v3 球衣

Re: About HTTP Connection Pool Problem Of Axis2 Client

Posted by Andreas Veithen <an...@gmail.com>.
Hi,

Please note that the HTTP sender already supports reusing the
connection manager. This can be enabled by setting the
REUSE_HTTP_CLIENT option. See the code in the first part of the
AbstractHTTPSender#getHttpClient method.

Regards,

Andreas

On Wed, Dec 24, 2008 at 15:04, MaWenPeng <ma...@163.com> wrote:
>   Hello,
>     In my programs(Servlet,JSP or Java Application), I find that the Axis2
> Client HTTP Connection Pool does not work well.
>     I create WebService Axis2 client Stubs with ADB bindings. Each time when
> the stub accesses the WebService, the HTTP Connections created by the stub
> could NOT be reused or closed. Then there are a lot of freezed HTTP
> Connections. I can see the connections' status in my FireWall.
>     For a long time, I find out that the MultiThreadedHttpConnectionManager
> object should be a static one.
>     So I make some changes in
> org.apache.axis2.transport.http.AbstractHTTPSender.java:
>         Define a static MultiThreadedHttpConnectionManager in it;
>         In getHttpClient(MessageContext msgContext) methd, use this static
> MultiThreadedHttpConnectionManager;
>     Also, I make some changes in MultiThreadedHttpConnectionManager.java:
>         Increase DEFAULT_MAX_HOST_CONNECTIONS and
> DEFAULT_MAX_TOTAL_CONNECTIONS numbers.
>     Things change a lot. The MultiThreadedHttpConnectionManager manages the
> HTTP Connection pool excellently.
>     The attachments are the files I have changed.
>     In AbstractHTTPSender.java: Line 70 and 447
>     In MultiThreadedHttpConnectionManager.java: Line 73 and 76
>     I hope this will make some help to Axis2 project.
>
>
> ________________________________
> [广告] 重奖 悬赏kfc3v3 球衣

Re:About HTTP Connection Pool Problem Of Axis2 Client

Posted by MaWenPeng <ma...@163.com>.
 Sorry for missing attachments.

 -------------------------

  Hello,

    In my programs(Servlet,JSP or Java Application), I find that the Axis2 Client HTTP Connection Pool does not work well.
    I create WebService Axis2 client Stubs with ADB bindings. Each time when the stub accesses the WebService, the HTTP Connections created by the stub could NOT be reused or closed. Then there are a lot of freezed HTTP Connections. I can see the connections' status in my FireWall.
    For a long time, I find out that the MultiThreadedHttpConnectionManager object should be a static one.
    So I make some changes in org.apache.axis2.transport.http.AbstractHTTPSender.java:
        Define a static MultiThreadedHttpConnectionManager in it;
        In getHttpClient(MessageContext msgContext) methd, use this static MultiThreadedHttpConnectionManager;
    Also, I make some changes in MultiThreadedHttpConnectionManager.java:
        Increase DEFAULT_MAX_HOST_CONNECTIONS and DEFAULT_MAX_TOTAL_CONNECTIONS numbers.
    Things change a lot. The MultiThreadedHttpConnectionManager manages the HTTP Connection pool excellently.

    The attachments are the files I have changed.
    In AbstractHTTPSender.java: Line 70 and 447
    In MultiThreadedHttpConnectionManager.java: Line 73 and 76

    I hope this will make some help to Axis2 project.
 



[广告] 重奖 悬赏kfc3v3 球衣