Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
COM+ server
Message
 
 
À
06/09/2004 04:56:38
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Divers
Thread ID:
00939679
Message ID:
00939720
Vues:
18
Hi, Florin.

>I have created a COM+ server:
>
>
define class TestServer as custom olepublic
>   myProp = 12
>
>   procedure SetProp(lnProp)
>      this.myProp = lnProp
>   endproc
>
>   procedure GetProp()
>
>   return this.myProp
>   endproc
>endefine
>
>I have built my server as MTDLL, Multi Use.
>
>On the server, I ran:
>
lobj = newobject("TestServer.TestServer")
>lobj.SetProp(20)
>?lobj.GetProp() && 20
>
>On the client, at the same time:
>
lobj = newobject("TestServer.TestServer")
>?lobj.GetProp() && 12, not 20
>
>My question: why I don't get the same value on the client as on server? In MSDN is writting that MTDLL creates only one instance on server. What I did wrong?

The problem here is that you shouldn't keep status on COM+ components. They should be stateless, because of this kind of pooling issues. You can't be sure about what physical instance of the component is being used for any client-side instance you get.

Think of a COM+ component the same way as a web page. Once you sent a request and it gave you back a response, the thing has completely forgot about you. You have to pass all the needed parameters in every call. Of course, you can emulate some kind of session state by returning a session id in the first call, and passing it back in all subsequent calls to the service. At the server side, you component should use
this ID (like a web cookie) to get all the needed data again from the database.

It seems like a lot of work, but this is how things have to be done to be able to scale up.

Hope this help. Feel free to make any further questions.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform