Announcement Announcement Module
Collapse
No announcement yet.
Info: GZIP compression with HTTPInvoker Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Info: GZIP compression with HTTPInvoker

    I just wanted to share information about using GZIP compression with HTTPInvoker. This may be common knowledge but I did not find it from reference, API or from this forum.

    GZIP compression support is present in CommonsHttpInvokerRequestExecutor. This Executor just needs be used by client side HttpInvokerProxyFactoryBean:
    Code:
      <bean id="clientService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
          <property name="serviceUrl" value="http://domain.com:port/clientService/ClientService"/>
          <property name="serviceInterface" value="my.program.clientService.ClientService"/>
          <property name="httpInvokerRequestExecutor">
             <bean class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor"/>
          </property>
       </bean>
    Then we need to include Apache HttpClient into classpatch. Note that new HttpClient 4.x is not yet supported so we need to use older 3.1 version. commos-codec is also required (I use version 1.4 but I dont know what version is correct for HttpClient 3.1).

    GZIP conpression needs to enabled on server for Java Serialized Object data. I use Tomcat server so the required configration in server.xml is following (compression config in bold):
    Code:
     <Connector port="8080" protocol="HTTP/1.1" 
                   connectionTimeout="20000" 
                   redirectPort="8443" 
                   compression = "on"
                   compressableMimeType="application/x-java-serialized-object"
                   compressionMinSize="2048"/>

  • #2
    Update

    Update!

    There is an error in Tomcat server.xml configuration above. There should not be a space between parameter and its value on "compression". This leads to strange Tomcat behavior (slowdowns, freezing). So the correct Tomcat configuration is:

    Code:
    <Connector port="8080" protocol="HTTP/1.1" 
                   connectionTimeout="20000" 
                   redirectPort="8443" 
                   compression="on"
                   compressableMimeType="application/x-java-serialized-object"
                   compressionMinSize="2048"/>

    I could not use this HTTPInvoker GZip-packing because there were some mysterious connection problems in some environments. I don't know the reason but I plan to test it again when Spring 3.1 is released with support to Apache HttpClient 4.x.

    Comment


    • #3
      Wanted to register just to say that this definitely wasn't common knowledge for me, and it ended up being super helpful. Thanks for sharing!

      Comment

      Working...
      X