473,608 Members | 1,809 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 ProcessAgentPoo l 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 ProcessAgentPoo l?

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 1843
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 DefaultTraceLis tener to write
some useful info such:
- ProcessAgentPoo l hash code,
- ProcessAgentPoo l 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 ProcessAgentPoo l?
No, different ProcessAgentPoo l. I set a trace-line (writing on the
DefaulTraceList ener) also within the ProcessAgentPoo l .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_2 100_.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
869
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 type of '', but expected 'text/xml'. The request failed with the error message: -- <HTML><HEAD><META HTTP-EQUIV="REFRESH" CONTENT="0" URL="http://api.google.com/search/beta2"></HEAD><BODY> </BODY></HTML>
1
1158
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 advice -Ruwan
1
1862
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. Is there a way that I can use the functionality of PowerPoint within my application, an ActiveX for instance? What I want is to dynamically create the number of slides I need, add textboxes to the slides and run the show. I need for an object that...
2
1864
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 all implemented. The Access database works fine in the server machine but when we try to interact with it using the Web service, the database says "there are no permissions or the database is blocked". I think it is not a permissions problem...
5
1244
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 Visual Studio to create a Web Reference. I have successfully connected to and used the web service. Here's the question. When I migrate the application to the production server, is there anything special I need to do? Or do I just copy the Web...
2
3260
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 a userid/password parameters. I'm currently using a page where that will return the file but there's no security on it which means that people could just send the appropriate URL and it will work. I'm trying to put in a least a little bit of...
3
8222
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 will change the current working directory to the directory which include the script, so my script cannot find the data file. I think this is the problem of emacs because when I start pdb from console directly, it will not change current...
3
2259
by: Ilyas | last post by:
Hi all What is the recommended way for using Linq within a 3 Tier project? Many thanks
0
8069
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8011
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8503
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8488
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6826
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6017
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5482
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4036
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.