Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Wed, 2 Apr 2008 02:36:47 -0700 (PDT),    group: microsoft.public.dotnet.framework.aspnet.webservices        back       


Lifecycle of .Net Web Service   
I am new to .Net Web Services, having done similar stuff in Java
before.

The life-cycle of a particular Web Service is presumably not the same
as that of the container in which it runs. Therefore, I wonder if
there are hooks that I can use to get something done when the Web
Services starts up, and something else done when the Web Service shuts
down.

At the moment, I'm using the constructor for the start-up hook, but
that seems wrong. And I haven't thought of an equivalent for shut-
down.

I'm using C#, by the way, if that matters.
date: Wed, 2 Apr 2008 02:36:47 -0700 (PDT)   author:   P Chase

Re: Lifecycle of .Net Web Service   
"P Chase"  wrote in message 
news:3155cafa-6cbe-465e-ae17-ca4d6632ed6e@y21g2000hsf.googlegroups.com...
> I am new to .Net Web Services, having done similar stuff in Java
> before.
>
> The life-cycle of a particular Web Service is presumably not the same
> as that of the container in which it runs. Therefore, I wonder if
> there are hooks that I can use to get something done when the Web
> Services starts up, and something else done when the Web Service shuts
> down.
>
> At the moment, I'm using the constructor for the start-up hook, but
> that seems wrong. And I haven't thought of an equivalent for shut-
> down.
>
> I'm using C#, by the way, if that matters.

There is no container. This is not J2EE.

You should probably not be doing things "when the web service starts" or 
"when the web service shuts down". What did you have in mind to do?
-- 
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer
date: Wed, 2 Apr 2008 16:28:37 -0400   author:   John Saunders [MVP] john.saunders at trizetto.com

Re: Lifecycle of .Net Web Service   
On 2 Apr, 21:28, "John Saunders [MVP]" <john.saunders at trizetto.com>
wrote:
> "P Chase"  wrote in message
>
> news:3155cafa-6cbe-465e-ae17-ca4d6632ed6e@y21g2000hsf.googlegroups.com...
>
> > I am new to .Net Web Services, having done similar stuff in Java
> > before.
>
> > The life-cycle of a particular Web Service is presumably not the same
> > as that of the container in which it runs. Therefore, I wonder if
> > there are hooks that I can use to get something done when the Web
> > Services starts up, and something else done when the Web Service shuts
> > down.
>
> > At the moment, I'm using the constructor for the start-up hook, but
> > that seems wrong. And I haven't thought of an equivalent for shut-
> > down.
>
> > I'm using C#, by the way, if that matters.
>
> There is no container. This is not J2EE.
>
> You should probably not be doing things "when the web service starts" or
> "when the web service shuts down". What did you have in mind to do?
> --
> --------------------------------------------------------------------------------
> John Saunders | MVP - Windows Server System - Connected System Developer

OK, so hopefully I understand another difference now between Java
servlets (what I'm used to) and .Net Web services.

However, I still have issue to sort out. For part of its operation, my
Web service depends uses a DLL that is single-threaded. Therefore, I
have a dedicated thread to interact with the DLL, and use a queue to
post requests to that thread. I need to know when to start and when to
stop that thread.

At the moment, I start the thread when the first request is received
at my Web service. But I would like to find a time when i can shut it
down cleanly; currently, it just runs until the process is killed,
which is ugly.

Note that I don't want to make my whole Web service single-threaded
(if, indeed, that option is available in .Net), because it does plenty
of other processing that is not restricted to single threads. As the
intended throughput of the system is high, and we're supposed to get
some fancy hardware to run it on, I need to use multi-threading
wherever possible, to keep those many cores busy servicing users.

Any suggestions?
date: Thu, 3 Apr 2008 00:13:04 -0700 (PDT)   author:   P Chase

Re: Lifecycle of .Net Web Service   
"P Chase"  wrote in message 
news:32cd88c3-34fa-4620-b86b-04d22988f8f9@d45g2000hsc.googlegroups.com...
> On 2 Apr, 21:28, "John Saunders [MVP]" <john.saunders at trizetto.com>
> wrote:
>> "P Chase"  wrote in message
>>
>> news:3155cafa-6cbe-465e-ae17-ca4d6632ed6e@y21g2000hsf.googlegroups.com...
>>
>> > I am new to .Net Web Services, having done similar stuff in Java
>> > before.
>>
>> > The life-cycle of a particular Web Service is presumably not the same
>> > as that of the container in which it runs. Therefore, I wonder if
>> > there are hooks that I can use to get something done when the Web
>> > Services starts up, and something else done when the Web Service shuts
>> > down.
>>
>> > At the moment, I'm using the constructor for the start-up hook, but
>> > that seems wrong. And I haven't thought of an equivalent for shut-
>> > down.
>>
>> > I'm using C#, by the way, if that matters.
>>
>> There is no container. This is not J2EE.
>>
>> You should probably not be doing things "when the web service starts" or
>> "when the web service shuts down". What did you have in mind to do?
>> --
>> --------------------------------------------------------------------------------
>> John Saunders | MVP - Windows Server System - Connected System Developer
>
> OK, so hopefully I understand another difference now between Java
> servlets (what I'm used to) and .Net Web services.
>
> However, I still have issue to sort out. For part of its operation, my
> Web service depends uses a DLL that is single-threaded. Therefore, I
> have a dedicated thread to interact with the DLL, and use a queue to
> post requests to that thread. I need to know when to start and when to
> stop that thread.
>
> At the moment, I start the thread when the first request is received
> at my Web service. But I would like to find a time when i can shut it
> down cleanly; currently, it just runs until the process is killed,
> which is ugly.
>
> Note that I don't want to make my whole Web service single-threaded
> (if, indeed, that option is available in .Net), because it does plenty
> of other processing that is not restricted to single threads. As the
> intended throughput of the system is high, and we're supposed to get
> some fancy hardware to run it on, I need to use multi-threading
> wherever possible, to keep those many cores busy servicing users.
>
> Any suggestions?

Yes. I suggest you take your single thread and put it into a Windows 
Service. It should not be in the web service at all. Communicate between the 
web service and the Windows Service by using either .NET Remoting or by 
using WCF (over a TCP-based channel).

This should actually simplify the testing, as the two concerns will be 
separated. You can also get automatic restart of the windows service if the 
single-threaded DLL crashes.
-- 
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer
date: Thu, 3 Apr 2008 08:16:47 -0400   author:   John Saunders [MVP] john.saunders at trizetto.com

Re: Lifecycle of .Net Web Service   
On 3 Apr, 13:16, "John Saunders [MVP]" <john.saunders at trizetto.com>
wrote:
> "P Chase"  wrote in message
>
> news:32cd88c3-34fa-4620-b86b-04d22988f8f9@d45g2000hsc.googlegroups.com...
>
>
>
> > On 2 Apr, 21:28, "John Saunders [MVP]" <john.saunders at trizetto.com>
> > wrote:
> >> "P Chase"  wrote in message
>
> >>news:3155cafa-6cbe-465e-ae17-ca4d6632ed6e@y21g2000hsf.googlegroups.com...
>
> >> > I am new to .Net Web Services, having done similar stuff in Java
> >> > before.
>
> >> > The life-cycle of a particular Web Service is presumably not the same
> >> > as that of the container in which it runs. Therefore, I wonder if
> >> > there are hooks that I can use to get something done when the Web
> >> > Services starts up, and something else done when the Web Service shuts
> >> > down.
>
> >> > At the moment, I'm using the constructor for the start-up hook, but
> >> > that seems wrong. And I haven't thought of an equivalent for shut-
> >> > down.
>
> >> > I'm using C#, by the way, if that matters.
>
> >> There is no container. This is not J2EE.
>
> >> You should probably not be doing things "when the web service starts" or
> >> "when the web service shuts down". What did you have in mind to do?
> >> --
> >> --------------------------------------------------------------------------------
> >> John Saunders | MVP - Windows Server System - Connected System Developer
>
> > OK, so hopefully I understand another difference now between Java
> > servlets (what I'm used to) and .Net Web services.
>
> > However, I still have issue to sort out. For part of its operation, my
> > Web service depends uses a DLL that is single-threaded. Therefore, I
> > have a dedicated thread to interact with the DLL, and use a queue to
> > post requests to that thread. I need to know when to start and when to
> > stop that thread.
>
> > At the moment, I start the thread when the first request is received
> > at my Web service. But I would like to find a time when i can shut it
> > down cleanly; currently, it just runs until the process is killed,
> > which is ugly.
>
> > Note that I don't want to make my whole Web service single-threaded
> > (if, indeed, that option is available in .Net), because it does plenty
> > of other processing that is not restricted to single threads. As the
> > intended throughput of the system is high, and we're supposed to get
> > some fancy hardware to run it on, I need to use multi-threading
> > wherever possible, to keep those many cores busy servicing users.
>
> > Any suggestions?
>
> Yes. I suggest you take your single thread and put it into a Windows
> Service. It should not be in the web service at all. Communicate between the
> web service and the Windows Service by using either .NET Remoting or by
> using WCF (over a TCP-based channel).
>
> This should actually simplify the testing, as the two concerns will be
> separated. You can also get automatic restart of the windows service if the
> single-threaded DLL crashes.
> --
> --------------------------------------------------------------------------------
> John Saunders | MVP - Windows Server System - Connected System Developer

Thanks for this.

I guess being a .Net Web Service is quite a restrictive role.

I can see that moving the DLL's functionality into a separate process
is probably the right thing to do, if retaining the Web Service idea.
However, I am concerned about performance, as the size of data to pass
to and from the DLL is large.

As we don't really need to deliver our service as a Web Service (it
just seemed like a convenient and buzzword-compliant delivery
vehicle), perhaps I'll reconsider. Perhaps I will just write an
ordinary application, and receive data over sockets in a low-level way.
date: Thu, 3 Apr 2008 05:50:03 -0700 (PDT)   author:   P Chase

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us