axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eran Chinthaka" <eran.chinth...@gmail.com>
Subject Re: Problem with Client Stub
Date Wed, 20 Aug 2008 04:17:33 GMT
Hi Georg,

Stubs are not thread safe by design. If you know about our architecture, you
will know why that is hard to do, because of the way we hold contexts in the
engine.

As you've already observed, you will have no problem if you use multiple
stubs. But there are some tricks you can do to improve the performance, if
you are worried about the performance.

Thanks,
Eran

On Tue, Aug 19, 2008 at 3:42 AM, Werthner, Georg <georg.werthner@siemens.com
> wrote:

> Hi,
>
> I am currently doing a memory footprint analysis of Axis2-1.4 clients.
> For this purpose I wrote a small service with:
>    .) 2 Request/Response operations
>    .) 2 One-Way operations
>
> I have a problem with the client: I am not sure if I am using the Axis2
> generated Client Stub correctly.
>
> I implemented the client as follows:
>    The client consists of multiple (configurable) Threads, that
> continously calls one of the four operations (random).
>    The first implementation:
>
> Public ExecutionThread extends Thread {
> //....
> public void run() {
>   Random rand = new Random(System.currentTimeMillis());
>   TestServiceStub stub = new
> TestServiceStub("http://atpc88vc:8080/axis2/services/TestService");
>   try {
>     while (!stop) {
>        execOperation(stub, rand.nextInt(4));
>     }
>   } catch (Exception e) {
>      stop = true;
>      e.printStackTrace();
>   }
> }
>
> private void execOperation(TestServiceStub stub, int opnr) throws
> Exception {
>                switch (opnr) {
>                case 0: {
>                        TestServiceStub.Operation1 op1 = new
> TestServiceStub.Operation1();
>                        op1.setOperation1Part1(1);
>                        op1.setOperation1Part2(2);
>                        op1.setOperation1Part3(true);
>                        op1.setOperation1Part4(1234);
>                        op1.setOperation1Part5(999);
>                        TestServiceStub.Operation1Response res =
> stub.operation1(op1);
>                        op1Count++;
>                        break;
>                }
>                case 1: {
>                        // Same as above
>                }
>                case 2: {
>                        // Same as above
>                }
>                case 3: {
>                        // Same as above
>                }
>        }
> }
> }
>
> When I did it like that I had the following problems:
> .) 1 Thread started and running: After a minute or so, the client throws
> an Exception:
>
> org.apache.axis2.AxisFault: Address already in use: connect
>        at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
>        at
> org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:1
> 93)
>        at
> org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
>        at
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageW
> ithCommons(CommonsHTTPTransportSender.java:364)
>        at
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(Common
> sHTTPTransportSender.java:208)
>        at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:448)
>        at
> org.apache.axis2.description.OutOnlyAxisOperationClient.executeImpl(OutO
> nlyAxisOperation.java:272)
>        at
> org.apache.axis2.client.OperationClient.execute(OperationClient.java:163
> )
>        at
> org.example.www.testservice.TestServiceStub.operation3(TestServiceStub.j
> ava:503)
>        at
> org.example.www.testservice.ExecutionThread.execOperation(ExecutionThrea
> d.java:128)
>        at
> org.example.www.testservice.ExecutionThread.run(ExecutionThread.java:88)
> Caused by: java.net.BindException: Address already in use: connect
>        at java.net.PlainSocketImpl.socketConnect(Native Method)
>        at java.net.PlainSocketImpl.doConnect(Unknown Source)
>        at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
>        at java.net.PlainSocketImpl.connect(Unknown Source)
>        at java.net.SocksSocketImpl.connect(Unknown Source)
>        at java.net.Socket.connect(Unknown Source)
>        at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
>        at java.lang.reflect.Method.invoke(Unknown Source)
>        at
> org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSoc
> ket(ReflectionSocketFactory.java:140)
>        at
> org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.crea
> teSocket(DefaultProtocolSocketFactory.java:125)
>        at
> org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:70
> 7)
>        at
> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpCon
> nectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
>        at
> org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMe
> thodDirector.java:387)
>        at
> org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMetho
> dDirector.java:171)
>        at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:3
> 97)
>        at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:3
> 46)
>        at
> org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(Abstrac
> tHTTPSender.java:542)
>        at
> org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:1
> 89)
>        ... 9 more
>
> .) 2 Threads started. The above Exception is thrown twice (for each
> Thread) immediately.
>
> .) When 3 or more (I tested it with up to 10 threads), the above
> Exception is not thrown any longer. But now there is a strange
> behaviour: All threads are periodically blocked. Every 10 seconds or so,
> no thread is sending a new request for about 5 seconds, then all threads
> simultanously start sending requests again for the next 10 seconds. Then
> they are blocked once again,.....
>
> When I change the implementation of the Threads in a way, that for every
> new request, a new Stub instance is created, none of these problems
> occur, no exceptions, no blocking. You only experience a little
> slowdown, I assume because of the stub creations:
>
> Public ExecutionThread extends Thread {
> //....
> public void run() {
>   Random rand = new Random(System.currentTimeMillis());
>
>   try {
>     while (!stop) {
>        execOperation(rand.nextInt(4));
>     }
>   } catch (Exception e) {
>      stop = true;
>      e.printStackTrace();
>   }
> }
>
> private void execOperation(int opnr) throws Exception {
>                TestServiceStub stub = new
> TestServiceStub("http://atpc88vc:8080/axis2/services/TestService");
>                switch (opnr) {
>                case 0: {
>                        TestServiceStub.Operation1 op1 = new
> TestServiceStub.Operation1();
>                        op1.setOperation1Part1(1);
>                        op1.setOperation1Part2(2);
>                        op1.setOperation1Part3(true);
>                        op1.setOperation1Part4(1234);
>                        op1.setOperation1Part5(999);
>                        TestServiceStub.Operation1Response res =
> stub.operation1(op1);
>                        op1Count++;
>                        break;
>                }
>                case 1: {
>                        // Same as above
>                }
>                case 2: {
>                        // Same as above
>                }
>                case 3: {
>                        // Same as above
>                }
>        }
> }
> }
>
>
> Is it not allowed to use ONE stub for multiple operations?
> Or is this a bug?
>
> Thanks!
>
> Best regards,
> Georg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
With Mettha,
Eran Chinthaka

--------------------------------------------------------------------
Health is the greatest gift; contentment is the greatest wealth; trusting is
the best relationship; nirvana is the highest joy. - Dhammapada

Mime
View raw message