December 1998
Build Reliable and Scalable N-tier Applications that Run on Both Windows NT and Unix
Download the code (5KB)
At the time this article was written, Mai-lan Tomsen was a program manager on the cross-platform COM team at Microsoft. She is currently working on an e-commerce service provided by QPass Inc. and can be reached at mai-lan@qpass.com.
It's gotten a lot
easier to be a Windows NT® developer working on both Windows® and Unix platforms. Microsoft and major Unix
vendors are cooperating to improve interoperability
between COM and Unix. Working in a heterogeneous environment (with different operating systems, databases, and platforms) is a fact of life for most developers. Now you can use Microsoft COM to extend Windows NT-based n-tier applications to the Unix platform.
This article describes how you can build reliable and scalable n-tier applications that work across Windows NT and Unix platforms. To help you understand the movement toward interoperability, I'll start off by explaining the relationships that Microsoft and other operating system vendors have established and what that means to you. I'll describe the extent of Windows NT functionality on Unix by explaining what COM support Unix vendors can implement and the conformance test suite that Unix implementations must pass. A thorough knowledge of the requirements for COM implementations on Unix will help you understand how your COM-based Windows app works on the Unix platform. I'll walk you through the steps of porting a Windows NT-based application to Unix, and describe options for developers using Visual C++® and Visual Basic®. Finally, I'll discuss other interoperability efforts that are underway and how you can use them in your cross-platform application. Several Unix vendors have committed to or are implementing COM support. See http://www.microsoft.com/com for the latest list of system vendors who have agreed to implement COM on their platforms. In this article, when I refer to Unix, assume that I am referring to the different Unix flavors that support or will support COM. VMS, MVS, and other non-Windows operating systems also fall under this rubric.
COM on Unix Basics
Let's examine each of these points in detail. Figure 1 depicts the traditional two-tier application architecture. In a traditional two-tier application, scaling is an expensive operation for both server resources and your budget. The client tier consists of "fat" clients, which contain the business logic for the application and have a much larger footprint than, say, an Internet client. Since the server hosts the data and the client contains the application, each client requires a database connection. Multiple users mean multiple connections, which degrades the performance and scalability of the application. Two-tier applications are also very expensive to scale in terms of hardware; generally, you have to acquire a more powerful database and host server to support an increased client load. |
Figure Two-tier Architecture |
|
Figure 2 Three-tier Architecture |
N-tier Interoperability
|
Figure 3 N-tier Interoperability Architecture |
Vendor Partnerships
The COM Conformance Test Suite
As you can see from the types of required tests with COM source licensing, Microsoft is interested in maintaining conformity across COM implementations. This helps ensure that the developers can obtain the same functionality for the COM application whether it's running on Windows NT or Unix.
Developing COM for Unix
Developing with Visual C++
Porting COM to Unix with Visual Studio
Step 5 Change GetCommandLine since MS-DOS is not available on Unix. You can use the CreateCommandLine function in Figure 8 to create a command line. Step 6 If you have used the ATL for development, you have to add values for all default arguments in the ATL-generated files. Note that some C++ compilers cannot compile ATL-generated files. Contact your C++ compiler vendor for more information about their ATL support. Step 7 Remove any UpdateRegistryFromResource calls and add DECLARE_REGISTRY in the class definition so that your class can register using ATL. For example: |
|
Step 8 Compile the server. This generates two binaries: the server executable or DLL itself and the proxy stub DLL. You can differentiate them by the "ps" in the name of the proxy stub DLL. For example, if your server DLL is called libMyServer.so, the proxy stub DLL is named libMyServerps.so. Step 9 Finally, register both the server and the proxy stub binaries by running regsvr, which is conveniently part of the COM implementation on Unix. |
|
Developing with Visual Basic
Developers using Visual Basic have a more restricted scope with legacy code since Visual Basic-based applications don't run on Unix. These developers must already have legacy components wrapped in COM interface classes (using C++) in order to extend the functionality of the legacy application. Programmers using Visual Basic will not be able to write additional COM components and deploy them on a Unix platform. Instead, they must evolve the legacy application into an n-tier application using MTS. If the Unix objects are properly wrapped in a COM interface class, you don't have to do any magic to make your MTS components talk to the Unix objects. Since COM operates on the concept of polymorphism (clients treat all objects the same despite differences in object logic), all the MTS components care about is if they can get a pointer to the Unix object, instantiate it, call it, and release it. How the MTS component uses the data in the Unix object is your decision.
Interoperability on the Data Tier
Microsoft's ODBC provides a solid foundation for interoperability on the data tier by giving a single data interface for multiple SQL data stores. This driver layer lets you talk to Oracle, SQL Server, Sybase, or IBM DB2. Microsoft provides other powerful data access methods, as well. For example, the latest version of OLE DB (released with Microsoft Visual Studio 6.0) includes session pooling, auto transaction enlistment, OLAP, SQL Server, and Oracle native providers. OLE DB and ADO are exciting, new data access technologies that make accessing data stores much easier. You can use the ADO programming model as a layer over ODBC to access data sources. Not only is ADO much easier to program than direct ODBC, but it also offers you the flexibility of using disconnected recordsets. OLE DB also offers a more flexible programming model than ODBC, as well as letting you get at OLAP, spatial, mail, directory, and index services and text. These two key Microsoft data access technologies are an important part of n-tier architecture development. Using them with an n-tier application lets you take advantage of their current functionality and improvements in future releases. There are other related interoperability technologies that you can use in a heterogeneous environment. For example, Microsoft SNA Server 4.0 offers COMTI for IMS and CICS, which lets MTS or COM components access and participate in transactions on IBM mainframes using LU 6.2. (See the "COMTI Interoperability Details" sidebar for a quick example of the gory details behind interoperability technology.) The database interop story is improving as rapidly as operating systems are changing. Sybase and Informix are currently working on their XA-compliant drivers to be used with MTS. In addition, IBM is working on implementing direct support for MSMQ, which will greatly improve the performance of transactional message queues with IBM mainframes. Two interesting interoperability developments in the next generation of COM are the support for TIP and manual transactions (sometimes called "bring your own transactions"). TIP is a proposed Internet Engineering Task Force (IETF) standard. Unlike previous IETF standard protocols, TIP is a very simple two-phase commit protocol; TIP only specifies how different nodes agree on the outcome of a transaction. The actual subject matter on which the nodes agree moves through other protocols like HTTP. A transaction manager (like MS DTC) can use TIP on one Internet node to communicate with a transaction manager on another node. Manual transactions let an MTS component that is not already associated with a transaction to acquire one from another transaction manager. In MTS 2.0, component transactions are automatic. Transactional attributes are set at deployment, but the MTS runtime controls transaction lifetimes (as part of resource pooling). In the next generation of COM, you will be able to manually associate a preexisting transaction with a component. This means that COM components can be associated with transactions whose lifetimes are controlled by a TP monitor, OTS, or DBMS. Other vendors have already announced their planned support for TIP or manual transactions. Compaq plans to use TIP to integrate MTS and Digital ACMS. Digital ACMS users on Digital Open VMS, Digital Unix, and Windows NT will be able to participate in MTS transactions through TIP. IONA Technologies is using TIP to integrate its transaction monitor (OrbixOTM) with MTS so that transactions can start in MTS components or OrbixOTM/CORBA objects and flow between platforms.
Bringing Interoperability to Users
From the December 1998 issue of Microsoft Systems Journal.
|