Digital Edition

SYS-CON.TV
The Truth About Coldfusion and DCOM
The Truth About Coldfusion and DCOM

Extending ColdFusion to incorporate Microsoft's Distributed Component Object Model (DCOM) is a powerful way to expand the capabilities of the application server on the Microsoft platform.

We'll view DCOM through ColdFusion and cover some of the features and pitfalls of using these technologies together. The examples here are made in conjunction with Visual Basic's support of the distributed interface. By the end of this article you should be able to start planning the framework for your DCOM-enabled ColdFusion applications.

DCOM is a derivative of COM, Microsoft's interface definition standard. COM provides a medium for developers to create interoperable interfaces and a means to connect to any COM-compliant service, regardless of implementation language or process space. DCOM extends COM functionality by providing distributed services such as transport, security and directory services that allow component interfaces to be accessed anywhere across a network.

How ColdFusion Accesses DCOM Services
ColdFusion provides a mechanism to access COM components through its CFOBJECT tag, which is used to gain the initial reference for an external object through COM, DCOM or CORBA. (COM and DCOM are used synonymously in reference to the CFOBJECT tag because in ColdFusion these types of objects are identical.)

<CFOBJECT type="COM" class="" action="create" name="xxx">

Keep in mind that COM components are designated with a unique ID, known as their GUID, each time they're compiled. Components are registered when the GUID is incorporated into the Windows registry. The same GUID version must be registered on the calling and receiving machine for the DCOM services to be properly located.

Building DCOM Components with Visual Basic
DCOM components can be built using various programming languages (Java, Visual Basic, Visual C++, etc.). In this article we'll cover the specifics of how to build and deploy COM objects written in Visual Basic. When compiling a Visual Basic 6.0 COM object for compatibility with the distributed model architecture, set an additional compilation option in your project's properties - the Remote Server Files option on the Component Tab of the Project Properties sheet.

When the time comes to deploy your compiled DCOM object, it's recommended you use Microsoft's Package & Deployment Wizard to create an installation program for the object. This wizard provides a simple means for placing and registering your new DCOM component. Remember to install the new component on any client and server machines that will be using this object. The last step in setting up your DCOM component is to configure its registered settings through the utility DCOMCNFG.exe provided with Microsoft's Visual Studio 6.

In using Microsoft's DCOM configuration utility (DCOMCNFG.EXE), configuring your newly registered DCOM objects is as simple as a few clicks of the mouse. Launch the "dcomcnfg" utility through your Windows command prompt and find your registered object in the list of registered components. Select the new component and click the Properties button for it. The utility must be used to configure the client and server machines where the component is installed. The following are recommendations for how to initially set your DCOM configurations on each machine.

On the client machine:

  • Location tab: Choose only "Run Application on following server." Specify server in textbox.
  • Security tab: Set permissions for who can launch and access your component.
  • Identity tab: Choose "The launching user."
  • End points: Leave defaults.

    On the server machine:

  • Location tab: Choose "Application on this computer."
  • Security tab: Give all necessary permissions. DCOM won't work with incorrect permissions.
  • Identity tab: Choose "The interactive user."
  • End points: Leave defaults.

    Passing Variables from ColdFusion to DCOM
    This process has some intricacies that we'll cover in respect to Visual Basic components. To support the interoperability of accessing COM components, we use a process called marshaling to pass variables to COM. It's the process of deconstructing objects and data types from one implementation and translating them into another.

    In DCOM components, functions accept two types of variables: primitive and object references. Primitive data types refer to variables that are string, integers, booleans and real number. When passing primitive data types to a COM interface, that interface must be defined to accept the value with the "ByVal" attribute. When passing nonprimitive variables or object variables through COM, the reference of the variable is passed and no additional attribute needs to be set. For example, the following code snippet shows how to declare a Visual Basic function that's able to accept the Integer primitive data type.

    Function TestFunction(By Val Parameter1 As Integer) ... End Function

    Managing DCOM Objects in Multiuser Scenarios
    Two main issues must be considered when programming your DCOM-enabled ColdFusion application for multiuser scenarios. The first is that the instantiation of remote objects tends to be resource-intensive and can have performance implications for your application. The second is the complication of handling multiple concurrent requests to your remote object. Because ColdFusion handles user requests in multiple threads and the ColdFusion server itself can be loaded on multiple machines (via load balancing), the developer must consider whether the DCOM objects are thread-safe. Using resource pools to manage your remote components can help you through these problems. Resource pools are a programming paradigm generally used to manage a limited number of resources for multiuser services.

    In ColdFusion you can implement a resource pool manager by following this example: enable application-level variables through the Application.cfm file, then add the following two application variables.

    Application.cfm:
    <cfparam name="application.recPool" default="NewArray(1)">
    <cfparam name="application.MAX_POOL_SIZE" default=5>

    These variables are used to hold the resources and define how many are to be pooled. The maximum number of resources should be defined in terms of how resource-intensive the components are and how robust the server is that will be running them.

    Listing 1 is the algorithm for actually implementing an example pooling mechanism. As you'll notice, this algorithm assumes that the DCOM component is defined with the "isAvailable" and "setAvailability" functions. Use this snippet to create a custom tag to manage your resource pools.

    The algorithm will loop through the pool until a resource becomes available. It's important that requesters for pool resources set them to available once they're done. The resource pool paradigm is good for handling resources that are used quickly and then returned. It doesn't work well when they're used for an extended period of time, in which case circumstances of deadlock can occur. The resource pool also solves any concurrency issues because it ensures that no more than one user request accesses any given resource at the same time.

    Using ColdFusion and DCOM together opens new windows of possibility for your Web applications. However, the many intricacies involved can create hours of trial and error. With this framework of knowledge, we hope that using DCOM can be a viable and painless solution for expanding your Web application.

    About Elias K. Jo
    Elias K. Jo is a
    consultant with Inventa Corporation, a
    professional services firm focused on B2B
    e-commerce integration.
    He has five years of
    programming experience with client/server and multitier application
    projects and is a
    Sun-certified Java
    Programmer.

    About Daniel Del Savio
    Daniel Del Savio, a
    graduate of the
    University of Notre Dame, is also a
    consultant with Inventa Corporation. He's
    been involved with the development of several multitiered and data
    processing applications.

  • In order to post a comment you need to be registered and logged in.

    Register | Sign-in

    Reader Feedback: Page 1 of 1



    ADS BY GOOGLE
    Subscribe to the World's Most Powerful Newsletters

    ADS BY GOOGLE

    With digital video content creation going viral and assuming the bulk of Internet traffic, how can t...
    In an age of borderless networks, security for the cloud and security for the corporate network can ...
    After years of investments and acquisitions, CloudBlue was created with the goal of building the wor...
    Technology has changed tremendously in the last 20 years. From onion architectures to APIs to micros...
    At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with exp...
    Financial enterprises in New York City, London, Singapore, and other world financial capitals are em...
    CloudEXPO has been the M&A capital for Cloud companies for more than a decade with memorable acquisi...
    In a recent survey, Sumo Logic surveyed 1,500 customers who employ cloud services such as Amazon Web...
    The standardization of container runtimes and images has sparked the creation of an almost overwhelm...
    ShieldX's CEO and Founder, Ratinder Ahuja, believes that traditional security solutions are not desi...
    In an age of borderless networks, security for the cloud and security for the corporate network can ...
    The graph represents a network of 1,329 Twitter users whose recent tweets contained "#DevOps", or wh...
    Is advanced scheduling in Kubernetes achievable?Yes, however, how do you properly accommodate every ...
    DevOps is a world surrounded by information, starting from a single commit and ending in roll out to...
    In his session at 20th Cloud Expo, Mike Johnston, an infrastructure engineer at Supergiant.io, will ...
    At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with exp...
    As you know, enterprise IT conversation over the past year have often centered upon the open-source ...
    Using serverless computing has a number of obvious benefits over traditional application infrastruct...
    At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with exp...
    At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with exp...