If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Advice Required on Creating Stateful COM+ Objects with .Net

Hi All,

I know this topic (stateful/stateless) sometimes brings up some fairly long discussions, and I'm still confused even after all these years, so allow me to explain and provide some background about this particular situation for you. Just so you know, we're going with a stateful approach for the reasons below .

We're currently moving some servers to 2003 from NT 4 (a case of 'have to do it'), and we have a fairly old service written in C running on there that provides mainframe access to about fifty users each on workstations, at most. Now this old service runs perfectly fine on 2003 (far better than on NT 4 in fact), but due to some problems with the old communication mechanism a component at a higher level uses we've decided to take some components from the workstation and re-write them to work on the server so all client/server communication works with DCOM/COM+. This actually works, and we've had a proof of concept up and running for a while, if a little ropy. The setup looks like this:

For each mainframe connection there is a session id, which the mainframe server actually keeps track of, and the client DLL holds this state so it can pass this ID down the chain to use the session that it has created. We'd like to get away from the client having to know the session ID, and we'd rather the COM+ server was able to free up resources independently (implies knowing the session ID) because we can't always rely on the client doing it. What I'd like to do is this:

In terms of state, all a COM+ instance would have would be a simple session ID variable - nothing expensive. The interesting thing to note here is that even though the COM+ server is stateful it doesn't actually matter at all what instance and session ID a client uses at any given time, so from their perspective it is stateless. What I'm aiming for here is to set up some object pooling so we can have far less than fifty instances up and running (perhaps as little as five or less sessions), as a call to the COM+ server and mainframe only takes around thirty milliseconds at most and then it will be released by the client for reuse. From this perspective, I think a stateful setup would be a good idea here as it would place far less stress on everything all-round, including the mainframe server, and people will love me .

The COM+ server we have is written with VB 6, and of course, DLLs created with VB 6 do not support object pooling . Given the tools available (out of my hands), we've decided to write this COM+ component in VB.Net which will allow us to do this. So, my *real* question is:

What advice, articles and books would people recommend for writing stateful COM+ components with VB.Net? My searches have turned up very little that's actually useful, and I'm quite surprised.

Is it possible to pool stateful objects, and have them pooled and used automatically like stateless objects?

Note: I should point out that the clients are all written with VB 6 and are COM based.