|
Programmatic Execution |
|
See Also: |
Microsoft Transaction Server (MTS) and COM+ are commonly used for the application services they provide. Microsoft Transaction Server runs on Windows NT 4.0, and COM+ provides a superset of MTS features on Windows 2000. This topic discusses developing with APGen and APG scripts in an MTS or COM+ environment.
To keep this topic more concise, references to COM+ should be construed as also applying to MTS, unless otherwise noted. We refer to COM+ because it is the newer and more widely used version.
We suggest that the APGen COM components not be registered in COM+. To execute APG scripts in COM+, write a wrapper COM component, and register the wrapper component in MTS or COM+. This is the best way to leverage the benefits of COM+ and APGen together.
An example APGen wrapper component is shown in the Executing APG Scripts in Visual Basic topic. This component can be installed in a COM+ Library or Server application. The application can even be set as a Queued Server application.
Note: Support for Queued Components is present only in COM+, and not in MTS.
The APGen COM components are not eligible for direct use as COM+ Queued Components, because Queued Components require input only, by-value parameters, and no return values. The best way to use APGen with Queued Components is to write a wrapper component that conforms to the Queued Components rules. As an example, the VB COM component shown in Executing APG Scripts in Visual Basic can be registered in a Queued Server application.
An alternative to using Queued Components is to use MSMQ directly. The MSMQ example (see APGen Examples) does not use Queued Components. Instead, it creates messages explicitly using the "MSMQ.MSMQMessage" component, and uses MSMQ Triggers to read queued messages. The MSMQ messages represent content update messages, and are sent from ASP pages and from SQL Server triggers. The messages are received using MSMQ Triggers, which is configured to run an APG script every time content update messages are received. The APG script reads the message(s) from the queue, and performs the content update.
To clarify, there are three different ObjectContext objects - they are related but different:
GetObjectContext() API. An
IObjectContext interface is returned. This is the
true ObjectContext object.If the APGen component is created by a COM+ object, the APG script executes
in the caller's context. Context is propagated from the caller to
the APG script. Objects created using
APGScript.CreateObject() (from outside of the script)
and Script.CreateObject() (from inside of the script)
will also run in the caller's context, unless they are COM+ objects that create a new context.