PDA

View Full Version : Thread Synch w/HttpInvoker Client



bincbom
Feb 7th, 2006, 12:15 PM
Hello Spring Gods:

I am working with remoting, using it to export a service interface to one of our clients. This client is capable of servicing multiple HTTP requests simultaneously, so it's an inherently multithreaded situation.

What are the "rules of the road" for synchronization w/HttpInvoker? Is it thread-safe? Right now, my client-side Spring HttpInvoker is declared a singleton (in the bean factory XML). Is this correct?

Any comments on the multi-threads properties of HttpInvoker would be greatly appreciated.

Thanks in advance...

jbalint
Feb 7th, 2006, 12:50 PM
What exactly are you asking? If you make your service implementation thread-safe, preferably stateless, you will be fine.

The client proxy generated by HttpInvokerProxyFactoryBean is thread-safe.

Jess

bincbom
Feb 7th, 2006, 01:01 PM
Hello, and thanks for your reply.

Yes, the service implementation is both thread-safe and stateless.

But I am implementing a proxy for results-caching on the client side (which is a singleton at the moment) and that's how I started wondering about multithreaded access to HttpInvoker on the client-side.

I am asking whether the Spring HttpInvoker client is thread-safe, and you seem to be indicating that it is. I will go read the Spring code to verify, but since the HttpInvoker client seems to be built on an atomically-used URLConnection, it's hard to see how it would not be thread-safe.

jbalint
Feb 7th, 2006, 01:09 PM
I think you should be able to get by with locks for the cache data structures or thread-safe data structures (which probably have internal locks anyways).

The RequestExecutor stuff is stateless which mean it's inherently thread-safe.

Jess