SOAP得Axis2的使用(三)Improve the performance and Fix issues

SOAP得Axis2的使用(三)Improve the performance and Fix issues

首页
http://ws.apache.org/axis2/

ISSUE:
2010-12-07 14:23:01,623 ERROR [STDERR] (http-0.0.0.0-80-62)     org.apache.axis2.AxisFault: Timeout waiting for connection
2010-12-07 14:23:01,624 ERROR [STDERR] (http-0.0.0.0-80-62)     at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
2010-12-07 14:23:01,624 ERROR [STDERR] (http-0.0.0.0-80-62)     at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:203)

SOLUTION:
I read the document from the official website. According to the comments, we have these 2 messages:
        1. We need stay the axis2 version with 1.5, because axis2 version 1.5.1/1.5.2 has this issue. (Now we are using 1.5, that is right.)
            https://issues.apache.org/jira/browse/AXIS2-4752
       
        2. We need to call the method client.cleanupTransport() at the end. (It is right in MW2.1, but wrong in MW2)

IMPROVEMENT:
I will to add these 3 parameters to the AXIS2 client option:
       options.setProperty(HTTPConstants.SO_TIMEOUT, 1800000);
       options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, 1800000);
       options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);

The REUSE_HTTP_CLIENT option is recommended from the official document to improve the performance. I do a performance test using junitperf to simulate 50 users calling the server side. And I use wireshark to capture the data.
     1. If the REUSE_HTTP_CLIENT is true, we will open less connection ports and get the results with good performance.
         The snapshot is in right_50.jpg.

     2. If the REUSE_HTTP_CLIENT is false or none, we will open many connection ports.
         The snapshot is in wrong_50.jpg.

我的测试用例修改为:
public void weatherService(){
RPCServiceClient serviceClient = null;
try{
      serviceClient = new RPCServiceClient();
            Options options = serviceClient.getOptions();
            EndpointReference targetEPR = new EndpointReference("http://192.168.1.149:8080/easyaxis/services/WeatherService");
            options.setTimeOutInMilliSeconds(1800000); // 10000 seconds
            options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
            options.setProperty(HTTPConstants.SO_TIMEOUT, 1800000);
            options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, 1800000);
            options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
            // client.getOptions().setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION, Boolean.TRUE);
            options.setExceptionToBeThrownOnSOAPFault(true);
            options.setTo(targetEPR);
            // Setting the weather
            QName opSetWeather = new QName("http://services.weather.axis2.sillycat.com", "setWeather");
            Weather w = new Weather();
            w.setTemperature((float) 39.3);
            w.setForecast("Cloudy with showers");
            w.setRain(true);
            w.setHowMuchRain((float) 4.5);
            Object[] opSetWeatherArgs = new Object[] { w };

            serviceClient.invokeRobust(opSetWeather, opSetWeatherArgs);

            // Getting the weather
            QName opGetWeather = new QName("http://services.weather.axis2.sillycat.com", "getWeather");
            Object[] opGetWeatherArgs = new Object[] {};
            Class[] returnTypes = new Class[] { Weather.class };
            Object[] response = serviceClient.invokeBlocking(opGetWeather, opGetWeatherArgs, returnTypes);

            Weather result = (Weather) response[0];

            if (result == null)
            {
                System.out.println("Weather didn't initialize!");
                return;
            }
            // Displaying the result
            System.out.println("Temperature               : " + result.getTemperature());
            System.out.println("Forecast                  : " + result.getForecast());
            System.out.println("Rain                      : " + result.isRain());
            System.out.println("How much rain (in inches) : " + result.getHowMuchRain());
        }
        catch (Exception e)
        {
            System.out.println("error:" + e);
        }
        finally
        {
            try
            {
                // clear up
                serviceClient.cleanupTransport();
            }
            catch (Exception e)
            {
                System.out.println("error:" + e);
            }
        }
}

你可能感兴趣的:(apache,UP,SOAP,performance)