I connection pool my service clients, because they also have minor memory leak issues - i.e. they don't seem to get completely garbage collected - (I discovered this after heavy duty performance testing of them - haven't drilled it down further to work out what is the issue with them though). 

When a call to the web service is made, I grab the service client out of the connection pool or lazily instantiate it as is necessary, re-jig its security outflow configuration depending on the user who made the call, then put it back in the pool after the call is finished (in a finally block).

Will Briggs wrote:
I just had to go through re-writing my singleton connection class to use ThreadLocal (quick and relatively painless, but a learning experience nonetheless)...  Maybe someone else on the list has a better suggestion, but this seems to be the easiest way I've found of being able to use a pseudo-singleton pattern with ServiceClient.  Like I said, with a lot of threads, you still end up with a lot of connections, but at least for me, sharing within the thread is a much bigger gain than worrying about sharing between threads.

-Will

Alexis Midon wrote:
well, actually I was trying to get ride of the threadLocal ;)
maybe I will stick with it.
Thanks for your answer!

nevertheless, can we get a rock-solid answer about this?

On Thu, May 22, 2008 at 4:35 PM, Will Briggs <[EMAIL PROTECTED]> wrote:
Is it critical to share it amongst several threads, or are you just looking to minimize the number of clients you instantiate?  Last I heard, ServiceClient was not thread-safe.  However, you can implement a Singleton pattern using ThreadLocal so that everything running within the same thread can share the service client.  This is pretty effective if you only have a few threads, but doesn't save you much if you have many.

-Will


Alexis Midon wrote:
Hi all,

I'd like to know if I can share one ServiceClient instance among several threads.

Thanks,

Alexis


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





-- 

Anthony
------------------------------------- 
Anthony Bull
Senior Developer
Black Coffee Software Ltd
PO Box 10-192 The Terrace
Wellington, New Zealand
 
[EMAIL PROTECTED]
Ph  +64 4 472 8818
Fax +64 4 472 8811
------------------------------------- 
www.bcsoft.co.nz
--------------------------------------------------------------- 
This email may contain confidential or privileged information, 
and is intended for use only by the addressee, or addressees. 
If you are not the intended recipient please advise the sender 
immediately and do not copy, use or disclose the contents to 
any other person or organisation.
Black Coffee Software Ltd accepts no responsibility for viruses 
received with this email, or to any changes made to the original 
content. Any views or opinions expressed in this email may be
personal to the sender and are not necessarily those of Black 
Coffee Software Ltd.
--------------------------------------------------------------- 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to