As more people migrate to Windows 2000 servers, COM+ is replacing Microsoft Transaction Services (MTS) as the middleware of choice for managing components. COM+ installs as part of Win2K; it's not an add-on like MTS, and you don't need an additional add-on pack (e.g., the NT Option Pack) to install it. COM+ is a full-fledged part of the OS, and as such, it's more tightly integrated with the OS than MTS is. Let's examine COM+'s management features and discuss how you can use these features to manage components.
You can think of COM+ as a tool to simplify the creation and use of software components. This framework enables interoperability of these components regardless of how you implemented them. You manage COM+ using the Microsoft Management Console (MMC) Component Services snap-in. Component Services works like the MTS Explorer under NT 4.0, except that many of the names and option locations have changed—and of course, it includes many new options. To open Component Services, click Start, Programs, Administrative Tools, Component Services.
COM+ applications, which replace MTS packages, are containers for components and roles that you can use to define the process boundary for the application's components. To add a new application, right-click the COM+ Applications folder, select New, Application, and click Next. Continue by clicking Create an Empty Application and entering the application name. Select either Library or Server application to control whether the application runs in the calling process's library or the server process space. If you select Server, a separate copy of dllhost.exe (from the System32 folder) hosts the component when it is instantiated. Dllhost.exe performs the same function as mtx.exe in MTS. After you select the activation setting of either Library or Server application, click Next. On the wizard's next screen, select This User and click Browse to select a valid user account for the application. Enter the user's password, and click Next. Click Finish on the wizard's last screen to complete the application creation process. The Component Services manager will update its display to include your new applications folder, as Figure 1 shows. In the figure, 32XTechWeb is the new application name.
You can change an application's properties by right-clicking the application name and selecting Properties. You can use these properties to set the application activation and identity of the user account, and to determine whether users can access the application using Microsoft Message Queue Server (MSMQ), as Figure 2 shows. If you select this last option, developers can change the way they call the components' methods and access the methods via MSMQ queues. Selecting this check box results in a method call over a queue that fires the component and executes its method as if a local application had executed it. The only difference is that the method can't return anything to the calling application. If you plan to use a queued component, you should also select the Listen check box on this same tab to have COM+ monitor the component's queue and automatically fire a method when a request comes in across the queue.
Because queued method calls occur asynchronously, they can dramatically improve performance by offloading work from the servers. In a traditional application, components or other applications perform all updates to a database synchronously. A synchronous call ties up the application and the database server until the update is complete. Queued method calls don't have to wait in the queue, so the calling application can immediately return to its next task. The method might run immediately if the queue is lightly loaded and the server running the queued components isn't loaded, or the method might not execute for a longer period. As long as the data the method updates isn't time-critical, the decision to use queued method calls or synchronous calls usually doesn't matter.
The Advanced Property tab lets you control several miscellaneous settings. If you select the first button, Leave running when idle, the application continues to run even when no applications are executing any methods in one of its components. If you select the second button, Minutes until idle shutdown, the application shuts down after a specified time.
If you select the Disable deletion check box from the Advanced Property tab, you can prevent anyone from deleting the application; if you select Disable changes, you can prevent anyone from changing the application. Both options are useful when you want to lock down an application's configuration.
The next option, Launch in debugger, is a hook that lets COM+ load in a debugger. After you select the option, enter the correct debugger configuration in the Debugger path box.
The last two options let you control advanced features. The Enable Compensating Resource Managers option enables the use of custom resource managers. A Compensating Resource Manager (CRM) is a custom resource manager that provides functionality for a nontransactional resource, such as a file's participation in transactions. For example, if a component deletes a file and the transaction aborts, COM+ won't roll back the deletion because the file deletion isn't part of a transactional operation. Instead, the CRM handles the rollback by restoring the file. The final option enables support for up to 3GB of memory on Win2K Advanced Server.
You can load components into Component Services by dragging them from Windows Explorer and dropping them in the Components folder, just as you did in MTS. Doing so adds the component classes to the Components folder. Figure 3 shows the Components folder after you add a component with three classes (Author, Royalty, and Title).
However, you can't load components that contain event classes using the drag-and-drop method. You must install such components with the Import or Install a Component wizard or with some automated process. To add a component using the wizard, right-click the Components folder, select New, Component, and click Next on the wizard's first page. Select the component type you want to install. You can install a component that's not registered on your system, choose from all components registered on the system, or install a component that contains one or more event classes.
The next step in managing or installing components involves setting properties for each component. To view the properties, select the component in the Components folder, right-click the component, and select Properties.
The General tab lets you set the description for the class and displays the Class Identifier (CLSID) for the class and the full path to the executable file. The description defaults to the class's program ID, and it's generally not a good idea to change it.
The Transactions tab controls class transactional setting. If you select Disabled (a new COM+ option), COM+ won't run the class in a transaction, removing almost all of the overhead of running a component in COM+. This setting is very useful when you're using a class that doesn't need transactional support, but you want to manage it using COM+. The other transaction options are Not Supported (the class doesn't support transactions), Supported (the class supports but doesn't require a transaction), Required (class requires a transaction), and Requires New (the class requires a new transaction).
With languages such as Visual Basic (VB) 6.0, you can set the transaction setting for each class and compile it into the class. I prefer to set the transaction property this way because it automatically defaults to the correct setting when you load the property into COM+. However, you can't set the Disabled value with VB 6.0; you must use either the Component Services Explorer or some automation process. If you select either Required or Requires New, you can set the Override global transaction timeout value. Selecting this option lets you specify how long the transaction runs before timing out, which is useful when you need to tweak the settings for a class that executes for a long time. You can use this setting to enter a custom value for just this particular class.
On the Security tab, you can select the roles that the class uses and set the option to check security at the component, interface, and method levels.
The Activation tab's control settings pertain to the activation of the class. You can enable the Enable pooling settings to control object pooling. COM+ doesn't support VB object pooling with VB 6.0 because VB 6.0 doesn't support the threading model required for object pooling. The Enable object construction setting enables a string to pass into the class when the class is instantiated. For instance, if you enter the name of the database server in the constructor string, the class can obtain that name each time the class starts.
The Component supports events and statistics option turns on and off reporting for the class. You can disable this setting when you need to squeeze that last bit of performance out of an application. However, disable this option judiciously—doing so disables reporting that you might need for management purposes. If you enable the final option on this tab, Must be activated in callers context, you can't activate the class unless it can run in the calling applications context.
The Concurrency and Advanced tabs don't pertain to most applications. The Concurrency tab sets the synchronization requirements for the class. The available options will vary depending on the transaction options you have selected for the class. The Advanced tab lets you control the queuing exception class used for a queued component. This class has methods that are played back before the request is routed to the dead letter queue.
To select multiple classes and open the properties for all of them, right-click the selection and select Properties. When you select multiple classes, any changes you specify will apply to all the classes.
I don't recommend that you always rely on the GUI to manage COM+ applications. As with MTS, there are many settings that you must configure for each application, component, and class. In fact, we have only reviewed some of the most important settings—you can set many others.
You have several tools to automate the rollout of components (you might consider automating administration if you have several COM+ servers to manage). COMREPL is a command-line utility that lets you copy all COM+ applications from one system to another. This tool is useful in Web farms and other server farms where you have several application servers running COM+ applications and you want to replicate the applications from one master system to all the other systems. You execute COMREPL using the following syntax:
where sourceComputer is the name of the master server; targetComputerList is a space delimited list of target computers; /n turns off all prompting; and /v logs the file operations to the screen.
The COM+ documentation provides several notes about using COMREPL:
- COM+ must already be installed on the target systems.
- The user running the utility must pass role checks on the source and target systems.
- Local accounts that the roles use are not replicated.
- All systems must be online.
- The user must replicate any data not in COM+ using other tools or manually.
- COMREPL only replicates to named computers, not clusters.
You can also export applications with COM+. Right-click the application you want to export, and select Export. Click Next on the first dialog box, and enter the full path and filename of the file you want to export. Select Server application, as Figure 4 shows, and click Next. Click Finish to start the export operation.
The export operation creates a .msi install file and a .cab file for your application. These files will have the same name as the name you entered for the export files. You can now install this application on another system using the msiexec command. The msiexec command is the client component of the Windows Installer service. The syntax for msiexec is as follows:
msiexec -i \[
You can specify the TARGETDIR property to override the installation directory, which lets you control the target directory for files on the target systems. You can also double-click the .msi file from Windows Explorer to install the application without specifying any options to install the application and the other files from the .cab file. You can execute the msiexec command with a particular .msi file by typing the file name at the command Prompt or in a batch file.
You can install components and COM+ applications on servers in many different ways. The best approach to automating these features is to use a programmable language such as VB that lets you drive the installation and capture any errors with either error handling code or a log file. You can also create your own installation application using COM+'s automation features, which work like the MTS automation features.
Later this year, Microsoft plans to release a product called Microsoft Application Center 2000 that will help you deploy and manage your Web servers. You can use it to roll out upgrades and new installs and monitor the servers. Microsoft Application Center 2000 also provides component load balancing, which lets you scale your application by balancing your COM+ components across multiple servers. You can learn more about Microsoft Application Center 2000 at the Microsoft Web site.