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

    The Software Defined Data Center (SDDC), which enables organizations to seamlessly run in a hybrid c...
    @CloudEXPO and @ExpoDX, two of the most influential technology events in the world, have hosted hund...
    "NetApp's vision is how we help organizations manage data - delivering the right data in the right p...
    Historically, some banking activities such as trading have been relying heavily on analytics and cut...
    DevOps is often described as a combination of technology and culture. Without both, DevOps isn't com...
    Your homes and cars can be automated and self-serviced. Why can't your storage? From simply asking q...
    Cognitive Computing is becoming the foundation for a new generation of solutions that have the poten...
    The Jevons Paradox suggests that when technological advances increase efficiency of a resource, it r...
    DevOps tends to focus on the relationship between Dev and Ops, putting an emphasis on the ops and ap...
    Kubernetes is a new and revolutionary open-sourced system for managing containers across multiple ho...
    Growth hacking is common for startups to make unheard-of progress in building their business. Career...
    New competitors, disruptive technologies, and growing expectations are pushing every business to bot...
    Fact: storage performance problems have only gotten more complicated, as applications not only have ...
    More and more companies are looking to microservices as an architectural pattern for breaking apart ...
    In his session at 19th Cloud Expo, Claude Remillard, Principal Program Manager in Developer Division...
    In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, will provide an ...
    A look across the tech landscape at the disruptive technologies that are increasing in prominence an...
    When you focus on a journey from up-close, you look at your own technical and cultural history and h...
    In his session at 21st Cloud Expo, James Henry, Co-CEO/CTO of Calgary Scientific Inc., introduced yo...
    The proper isolation of resources is essential for multi-tenant environments. The traditional approa...