Hi All,
trying to get a firm grip on MTS object creation techniques and the good and bad ways to do it. I've read "Professional VB6 MTS Programming" by Bortniker and read tons online. The Bortniker book is out of date as I am using Windows 2000. I have read
"One of the big improvements in COM+ is the integration of COM and MTS. The two programming models have been unified. This eliminates the issue of calling to the MTS runtime versus calling to the SCM. This means that a call to the CreateObject function under Windows 2000 is the same as a call to CreateInstance. As long as a component is configured properly, the new object will always be loaded into the activity of its creator."
from
It is my understanding now that I should be instancing my MTS objects from other MTS objects, which reside in the same DLL, like this under Windows 2000/VB 6. For Example:
MyDll has 2 classes: MyRoot and MyOther. MyRoot is the class where my transaction originates from. Both classes are MultiUse and Requires Transaction. MyOther is the class I need to instantiate from within MyRoot.
From within MyDll.MyRoot Class:
Public Function Foo() As Boolean
' Reference to MTS Object Context
Dim ctxObject As ObjectContext
Set ctxObject = GetObjectContext()
Dim MyMTSObj As MyDll.MyOther
' Instantiate MyOther class within same activity
' is done this way according to docs to maintain
' transactional integrity within MTS.
Set MyMTSObj = CreateObject("MyDll.MyOther"
' I used to do it this way but I'm told this
' is *bad* under MTS
' Set MyMTSObj = New MyDll.MyOther
' Do Some Work with MyMTSObj
blnRtn = MyMTSObj.DoSomething()
If blnRtn = False Then
' Something went wrong. Lets abort
ctxObject.SetAbort
Foo = False
Else
ctxObject.SetComplete
Foo = True
End If
End Function
this will instance MyMTSObj within the same activity as the root object.
I'd feel warm and fuzzy if an MTS guru out there validated this for me.
Also, *when* and *if* or *never* should I do this (assuming ctxObject is a reference to the ObjectContext):
Set ctxObject = Nothing
This was asked of me by an associate.
TIA,
Mark
trying to get a firm grip on MTS object creation techniques and the good and bad ways to do it. I've read "Professional VB6 MTS Programming" by Bortniker and read tons online. The Bortniker book is out of date as I am using Windows 2000. I have read
"One of the big improvements in COM+ is the integration of COM and MTS. The two programming models have been unified. This eliminates the issue of calling to the MTS runtime versus calling to the SCM. This means that a call to the CreateObject function under Windows 2000 is the same as a call to CreateInstance. As long as a component is configured properly, the new object will always be loaded into the activity of its creator."
from
It is my understanding now that I should be instancing my MTS objects from other MTS objects, which reside in the same DLL, like this under Windows 2000/VB 6. For Example:
MyDll has 2 classes: MyRoot and MyOther. MyRoot is the class where my transaction originates from. Both classes are MultiUse and Requires Transaction. MyOther is the class I need to instantiate from within MyRoot.
From within MyDll.MyRoot Class:
Public Function Foo() As Boolean
' Reference to MTS Object Context
Dim ctxObject As ObjectContext
Set ctxObject = GetObjectContext()
Dim MyMTSObj As MyDll.MyOther
' Instantiate MyOther class within same activity
' is done this way according to docs to maintain
' transactional integrity within MTS.
Set MyMTSObj = CreateObject("MyDll.MyOther"
' I used to do it this way but I'm told this
' is *bad* under MTS
' Set MyMTSObj = New MyDll.MyOther
' Do Some Work with MyMTSObj
blnRtn = MyMTSObj.DoSomething()
If blnRtn = False Then
' Something went wrong. Lets abort
ctxObject.SetAbort
Foo = False
Else
ctxObject.SetComplete
Foo = True
End If
End Function
this will instance MyMTSObj within the same activity as the root object.
I'd feel warm and fuzzy if an MTS guru out there validated this for me.
Also, *when* and *if* or *never* should I do this (assuming ctxObject is a reference to the ObjectContext):
Set ctxObject = Nothing
This was asked of me by an associate.
TIA,
Mark