473,499 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: Using a Singleton within a web service

The weird thing
is that *different instances* of my singleton ProcessAgentPool class are
actually instantiated!
Evidenced by? You didn't say why you think this...
And over what time interval are you seeing tihs?
Are you sure you aren't getting different ProcessAgent instances from a
single ProcessAgentPool?

Basically, by using a singleton, you have exposed yourself to several
threading issues. I wouldn't be at all surprised if a thread race is
causing a failed lookup of a ProcessAgent (in fact, a thread-race here
could crash the whole app, so it is unsafe if you haven't synchronized).

Another possibility is that your app-pool has recycled. This happens. It
also isn't clear on what thread the long-running operation is
happening - if you are using a web-service thread to do the main work, I
might expect starvation (and/or timeouts) to be an issue here as well.

Marc
Jun 27 '08 #1
7 1837
Hi Marc,

thank for having payed attention to my long and boring message and for
your reply! ;-)

Marc Gravell ha scritto:
Evidenced by? You didn't say why you think this...
You're right.
In each web service WebMethod I use the DefaultTraceListener to write
some useful info such:
- ProcessAgentPool hash code,
- ProcessAgentPool count (i.e. how many active process are held by the
pool),
And over what time interval are you seeing tihs?
"Pollings" are 500ms spaced (just for debuggin purpose).
Are you sure you aren't getting different ProcessAgent instances from a
single ProcessAgentPool?
No, different ProcessAgentPool. I set a trace-line (writing on the
DefaulTraceListener) also within the ProcessAgentPool .ctor(), and I can
see that sometimes a new pool instance is created.
Basically, by using a singleton, you have exposed yourself to several
threading issues.
[cut]

I know, but I can ensure that everything is synchronized internally. I
could not post here the whole code of the sample application but you can
trust me. ;-)
Another possibility is that your app-pool has recycled. This happens. It
also isn't clear on what thread the long-running operation is happening
- if you are using a web-service thread to do the main work, I might
expect starvation (and/or timeouts) to be an issue here as well.
I must admit I didn't get this last quote. Please, could you explain a
little?
Thanks a lot,
Giulio

--
OnAir:
http://www.giuliopetrucci.it
Jun 27 '08 #2
I must admit I didn't get this last quote. Please, could you explain a
little?
I'm assuming that you are hosting your app in IIS; IIS has an option
(enabled by default) to restart an app-pool periodically; as I
understand it, this is intended to solve memory growth issues, and a few
other things. After a while, it will literally destroy your app-pool
(i.e. your app-domain), and the next request will get a nice fresh one -
which will mean that you get a new singleton.

You can disable this, but I'm not sure it wold be my first choice. If I
had a long-running stateful web-service, I would look at using WCF to
host it in a dedicated windows service process (there are sample project
templates for this in VS2008u and VS2005 with the WF extension). That
way, you control the lifetime etc.

Marc
Jun 27 '08 #3
(there are sample project
templates for this in VS2008u and VS2005 with the WF extension).
Sorry, I meant WCF extensions (WF on the mind...); for VS2005 it is here:

http://www.microsoft.com/downloads/d...DisplayLang=en

But it is cleaner in VS2008.

Marc
Jun 27 '08 #4
Hi Marc,

Marc Gravell ha scritto:
I'm assuming that you are hosting your app in IIS;
[cut]

Ok, I goti it now.
You can disable this, but I'm not sure it wold be my first choice.
Neither do I.
At this point my first choiche would be to create a windows service
process and make my web-service code-behind "talk" to it. My question
is: should I use remoting (or things similar) to make my objects pass
from the windows service context to the web service (IIS) one?
If I
had a long-running stateful web-service, I would look at using WCF
[cut]

Got it.
Anyway, do I need to install FW 3.0, right?

Ciao,
Giulio

--
OnAir:
http://www.giuliopetrucci.it
Jun 27 '08 #5
Anyway, do I need to install FW 3.0, right?

To use WCF, yes; WCF is part of .NET 3.0 and won't work without it.
should I use remoting (or things similar) to make my objects pass
from the windows service context to the web service (IIS) one?
Actually, WCF would be my first choice for IPC too... (perhaps on a
net-tcp binding or named pipe in this case) - but remoting is an option.
Personally, I get very confused by remoting, but if remoting works for
you, then fine; this would allow you to work without .NET 3.0, as you
could have you ASP.NET web-service talk to a well-known object (or
whatever the term is in remoting - see, I'm already lost!).
Your existing ASP.NET talking to a remoting service may well be less
complex and involve less changes.

Note that WCF running from a service or a console exe can expose itself
directly over http etc as though it were running inside IIS. In fact,
even WCF running inside IIS don't run through the same ASP.NET pipeline...

Marc
Jun 27 '08 #6
Hi Marc,

Marc Gravell ha scritto:
To use WCF, yes; WCF is part of .NET 3.0 and won't work without it.
Ok, so I think I can't use it, as the specs want my application to run
on FW2.0...
Actually, WCF would be my first choice for IPC too... (perhaps on a
net-tcp binding or named pipe in this case) - but remoting is an option.
[cut]

I see.
Anyway I'm stiil experiencing the same absurd problem: two similar
application, the first works fine, the second doesn't. Very strange...
Note that WCF running from a service or a console exe can expose itself
directly over http etc as though it were running inside IIS. In fact,
even WCF running inside IIS don't run through the same ASP.NET pipeline...
Yes, I know a bit of WCF, but should get through deeper... (when I have
time I'll do).

Thanks a lot,
Giulio

--
OnAir:
http://www.giuliopetrucci.it
Jun 27 '08 #7


Hi Giulio

Look into the GetDataObject method in the ISerializable interface. I
think that will work for a web service, although I am finding it does
not work for WCF.

Take a look at this link:
http://dotnetslackers.com/community/...2007/05/04/Whe
n-is-a-singleton-not-a-singleton_3F00_-Serialization_2100_.aspx
*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
858
by: Joey | last post by:
Hey, Is there a way to kill the asp_wp process using a web service? The process I want to kill is on the server the web service is sitting on. Thanks in advance! --Joey
0
223
by: Pedro Cardoso | last post by:
i have been using google web service and since about a month ago i am unable to access it anymore the error messaqge it returns is: System.InvalidOperationException: Client found response content...
1
1151
by: Sniper | last post by:
Hi guys I am retrieving an attachment using a web service. what would be the fastest way to download the attcahment ? WSE Attacahment or byte array or any other methods ??? tahnks in...
1
1855
by: Tor Inge Rislaa | last post by:
Using PowerPoint within my application I am developing an application that needs some functionality of displaying some text and graphic in full screen modus, as when you run a PowerPoint show....
2
1858
by: Avatar | last post by:
Hi: My team is developing a project where a client app needs to interact with a remote Access database using a Web Service. The client app, the Web Service and the database accessing layer are...
5
1240
by: Geoff | last post by:
My apologies for asking something so basic, I just want to avoid unpleasant surprises. I am using a web service developed by someone else on a remote server. In my development environment I used...
2
3254
by: UJ | last post by:
Is it reasonable to use a web service to transfer a large file (current < 1MB but could end up being 1Gig in the future.) The reason for my thought of using a web service is that then I can make...
3
8204
by: duyanning | last post by:
I have written a pyhton script that will process data file in current working directory. My script is in an different directory to data file. When I debug this script using pdb within emacs, emacs...
3
2250
by: Ilyas | last post by:
Hi all What is the recommended way for using Linq within a 3 Tier project? Many thanks
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.