Tuesday, December 10, 2013

Tune spring remoting over http exporter

Noticed that using spring remoting over HttpInvokerProxyFactoryBean everything hangs when one of invokations is too long.

The problem is with SimpleHttpServerFactoryBean on server side. It turns out it handles requests on single thread by default. Solution:
package transport;

import org.springframework.remoting.support.SimpleHttpServerFactoryBean;
import java.util.concurrent.Executors;

public class ThreadedHttpServerFactoryBean extends SimpleHttpServerFactoryBean {

    public ThreadedHttpServerFactoryBean() {
        setExecutor( Executors.newFixedThreadPool( 50 ) );
    }
}

Here we gave 50 threads to http server.