Advanced Ajapa Yoga Kriyas and Meditations for Software Developers : Tap the power of breath, mantra, mudra, and dhyana for improved focus, peace of mind, and blissful inner connection.


Introduction to MTS

What is Microsoft Transaction Server?

  • MTS is a middle-ware from Microsoft
  • In a n-tire system middleware sits between your business components and client application. It handles all the client requests for the components
  • MTS is a component-based transaction processing system for building, deploying, and administering internet and intranet server applications
  • MTS manages resources like database connections, threads etc. for your components

What are main parts of systems built around MTS?

  • Application components
  • MTS executive
  • Server processes
  • Resource managers
  • Resource dispensers
  • MS-DTC
  • MTS explorer

What are application components?

Application components are custom components that you design to suit your business needs. These components are in-process (DLL) components which run under the control of MTS. If you are designing components using VB you must make them as ActiveX DLLs with Apartment threading.

What is MTS executive?

  • MTS Executive is a DLL that provides run-time services for MTS components like thread and context management
  • This DLL loads into the processes that host application components and runs in the background

What is server process ?

A server process is a system process that hosts the application components. A server process can host multiple components.

What are resource managers ?

  • A resource manager is a system service that manages transactional data with help of MS-DTC
  • MTS supports resource managers that implement the OLE Transactions protocol e.g. MS-SQL Server

What are resource despensers ?

Resource dispensers manage system resources like database connections. MTS provides two resource dispensers :

  • ODBC/OLEDB Resource Dispenser
  • Shared Property Manager

What is MS-DTC ?

Microsoft Distributed Transaction Coordinator is a system service that coordinates transactions. With MS-DTC MTS can handle transactions spanning more than one machines. MS-DTC uses a two-phase commit protocol for transaction management.

What is MTS explorer ?

MTS explorer is a GUI for managing and administrating MTS components

How to create transactional components?

There are two steps in creating transactional components.

  • Inside your component you need to add code which tells MTS weather transaction is completed successfully or not
  • You need to set the transaction attribute of the component inside MTS - generally using MTS explorer.

What is Object Pooling?

Object pooling is nothing but recycling a certain number of objects among clients requesting them. The client requests for an object. If no instance of the object is available MTS will create a new instanced and give it to the calling client. The client will use the object and inform MTS when done with the help of special methods. MTS will not immediately destroy the object but keep it in 'object pool'. The same instance of the object is supplied to other clients requesting for the same component.

Presently (ver 2.0) MTS do not provide object pooling but Microsoft has promised it at some later date. Microsoft has also provided some interfaces which you can use for this forward compatibility. Currently, MTS simply creates and destroys objects rather than recycling them.

What is Connection Pooling?

Connection pooling is similar to object pooling but it applies to database connections instead of object instances. MTS does provides connection pooling.

Why MTS components are generally built stateless?

Because of object pooling feature of MTS clients are not guaranteed that between different method calls they will get same object instance. Naturally, storing properties or state in such objects is useless. MTS provides alternative mechanism of state management called 'shared property manager'

What are transaction attributes of MTS components?

There are 4 transaction attributes in MTS :

  • Requires a transaction : the objects require a transaction. If transaction do not exist a new transaction is started
  • Requires a new transaction : A new transaction is always started for the object
  • Supports a transaction : The object uses a transaction context only if one already exists
  • Does not support transaction : The object do not participate in transaction

You can set these attribute in MTS explorer or if you are working with VB6 you can set the MTSTransactionMode property (which you can change later in MTS explorer)

How does a typical component is built with VB to work under MTS?

To create components with VB for MTS you should create ActiveX DLLs with apartment threading model. The classes you create are similar to your normal class modules with some limitations like :

  • You should not use functions like MsgBox in the class as the class is running on server and any call to such methods invokes the Msgbox at the server and not at the client
  • You should avoid storing state i.e. properties because of object pooling feature of MTS( presently MTS do not support true object pooling but Microsoft has promised it at later date)

A typical method will look like this :

Public Function Method1() As Boolean
    On Error GoTo err_proc
    Dim objcntxt As MTxAS.ObjectContext
    Set objcntxt = GetObjectContext()
    cnn.Open "file=sample.udl"
    cnn.Execute "update authors set author='Bipin Joshi' where author='bipin'"
    objcntxt.SetComplete
    Method1 = True
    Exit Function
err_proc:
    objcntxt.SetAbort
    Method1 = False
End Function

In the above function calling setComplete or setAbort is important because it tells MTS that you are finished with the object and the object can be recycled.

After you built the component you need to host it under the control of MTS using MTS explorer.


Bipin Joshi is an independent software consultant and trainer by profession specializing in Microsoft web development technologies. Having embraced the Yoga way of life he is also a meditation teacher and spiritual guide to his students. He is a prolific author and writes regularly about software development and yoga on his websites. He is programming, meditating, writing, and teaching for over 27 years. To know more about his ASP.NET online courses go here. More details about his Ajapa Japa and Shambhavi Mudra online course are available here.

Posted On : 18 December 2000







Advanced Ajapa Yoga Kriyas and Meditations for Software Developers : Tap the power of breath, mantra, mudra, and dhyana for improved focus, peace of mind, and blissful inner connection.