View Full Version : Question about Remoting Methods + Threading
Feb 28th, 2006, 12:41 AM
This is probably an easy question...here goes....
I can see how using an HttpInvoker based solution would allow you to rely on your servlet container to manage the threading aspect of your service... That is to say that multiple "simultaneous" invocations would be handled by multiple threads issued by your servlet container upon recipet of the HttpRequest.
So...what happens if i exported the same service using RmiServiceExporter? What's the behavior here? Can simultaneous invocations be handled? Will it just block?
Appreciate the clarification!
Mar 11th, 2006, 12:27 PM
I think i understand what happens here now...
There will be a remote thread that corresponds to the local thread for each RMI connection...
However, I'm assuming this is unmanaged...
Mar 13th, 2006, 08:53 AM
in fact all your beans are :
stateless (for a given "configuration")
singleton (by default)
and so can be invoked in parallell (like a good old servlet)
the state is in your request/response parameters.
all aspects (transaction, local,...) that are per request are handled using thread local mecanism. The threadlocal variable is initialized by the first caller (controller or filter) and cleared at the last caller return point.
Sep 13th, 2006, 06:18 AM
So...what happens if i exported the same service using RmiServiceExporter? What's the behavior here?
- New thread created for each request.
This is fine for small to medium scale app but may get expensive as thread creation climbs.
Can simultaneous invocations be handled?
Will it just block?
Sep 13th, 2006, 08:37 AM
Excellent response...thank you.
Sep 13th, 2006, 01:08 PM
With complex and long running background jobs, I normally don't want to execute such a task on an arbitrary client thread.
That is why I create a component that has his own thread(s). The 'threadaware' component delegates the real work to components that don't know anything about threading.
This makes it easier to create asynchronous calls, control the number of concurrent threads, control the tasks being processed concurrently. And it also gives you more control on liveness problems and thread priority related problems.
Sep 13th, 2006, 02:05 PM
Yeah...I'm looking at doing JMS remoting long term...
But for now it's RMI, and I wanted to make sure it worked as i thought it did.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.