Remoting Singleton v.s. SingleCall

J

JSheble

I understand the difference between the two types (Singleton & SingleCall)
but what affect does this have if the Remoting Server accepts multiple
connections from multiple clients, and they're all sending messages or using
methods? Does it (server) manage this automatically?
 
M

Mehdi

I understand the difference between the two types (Singleton & SingleCall)
but what affect does this have if the Remoting Server accepts multiple
connections from multiple clients, and they're all sending messages or using
methods? Does it (server) manage this automatically?

Yes. If you published your object as a Singleton (or used Remoting.Marshall
to publish your object), the server will make sure that there is always at
most one instance of your object created and all your clients will always
access the same object.

If you publish your object as Single Call, then the server will alwasy
create a new instance of the object whenever a client calls one of its
method and will destroy the object afterwards, which ensures you that
you'll never have 2 clients or the same client accessing the same instance
twice.
 
J

JSheble

Ok, but I'm still a bit confused about multiple clients connecting to a
Singleton object... what if multiple clients all call the same method
simultaneously? Say 3 clients all call the same method, does the 2nd and
3rd call wait until the first finishes? Meaning does it queue the calls?
 
O

Oliver Sturm

JSheble said:
Ok, but I'm still a bit confused about multiple clients connecting to a
Singleton object... what if multiple clients all call the same method
simultaneously? Say 3 clients all call the same method, does the 2nd and
3rd call wait until the first finishes? Meaning does it queue the calls?

If I'm not completely mistaken, it runs multiple threads, one for each
incoming request. That's why it's important to code Singleton objects
thread-safe for use in Remoting.



Oliver Sturm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top