Multiple thread access to a single remoting object (proxy)
-
Hi, I'm writing a web service that talks to a windows service via remoting. The windows service is configured to remote the object as a singleton. Since multiple web service threads can be spawned by multiple client requests the Remoted object has been written to b thread safe, but what about the web service (client) proxy to the remoted object? Worded another way - I have multiple threads firing methods on a single remoting proxy that is connecting to a singleton object. Will there be any problems with the proxy itself? Here's some psuedo code:
static RemoteObject remObject; <-- globally stored
main()
{
remObject = GetRemoteConnection(); <-- obtain connection
...
// Create some threads
...
DoSomethingThread1.start();
DoSomethingThread2.start();
}static void DoSomething()
{
remObject.DoSomething(); <-- Will get called by two threads at virtually the same time.
}Thanks in advance for any insights.
Assert(this);
-
Hi, I'm writing a web service that talks to a windows service via remoting. The windows service is configured to remote the object as a singleton. Since multiple web service threads can be spawned by multiple client requests the Remoted object has been written to b thread safe, but what about the web service (client) proxy to the remoted object? Worded another way - I have multiple threads firing methods on a single remoting proxy that is connecting to a singleton object. Will there be any problems with the proxy itself? Here's some psuedo code:
static RemoteObject remObject; <-- globally stored
main()
{
remObject = GetRemoteConnection(); <-- obtain connection
...
// Create some threads
...
DoSomethingThread1.start();
DoSomethingThread2.start();
}static void DoSomething()
{
remObject.DoSomething(); <-- Will get called by two threads at virtually the same time.
}Thanks in advance for any insights.
Assert(this);
I answered this question myself. I could not find the information in the MSDN, so I made a test app. that connected to the service. The connections were done from 256 threads that then proceeded to make 50,000 calls at the same time. The server registered these calls and marked the begin and end of each call along with the thread ID. The trace log indicated multiple calls were being executed at the same time with no problems. So the answer seems to be that he remoting proxy is thread safe, and will make multiple calls per connection instance instead of sequencing the calls over one connection. The only other thing I need to do is sniff the wire to see if multiple connections are being made, or if they are getting to the server over one connection. BTW: Anyone know if after a remoting call over a TCP channel if the TCP connection is dropped, or does it stay connected for the life of the proxy?
Assert(this);