|
|
Distributed applications can't rely on a specific connection existing at any given time-the client and server might not even have a connection. Therefore, the request/reply event system is
In the old setup, there was a client and a server with a direct connection. The client registered an event handler directly with the server. The publish/subscribe event system, on the other hand, uses an intermediary to handle the client/server communication. In short, the publish/subscribe event model has three main elements:
The server publishes data through an event class that it registers with Component Services. Once the server publishes data, it's no longer
The client subscribes to an event that the server publishes. However, unlike COM client, which registers with the server, the COM+ client registers with the COM+ Catalog. In reality, the client has no idea which server provides the data. All it
The server creates the event object before firing an event. When the server fires the event, the event object receives it. At this point, the server can terminate if it wants to-it has
At this point, you might be wondering what this three-element method buys you in the way of productivity or reliability. Creating the server is
The event object is simple too. All it really contains is stub code (empty functions). The COM+ Event System Service handles the actual event object details. It merely uses the event object you create as a template of the interfaces and
Another advantage of using the publish/subscribe methodology is that you can combine it with Microsoft Message Queuing Services (MSMQ). A COM server (publisher) could queue up changes that would wait until the host computer has time to service them. Likewise, the event object can queue the fired events until the client can pick them up. Consequently,
You must consider several subscription issues when working with COM+. The first is the type of subscription you want to create: transient or permanent. The type is determined by the type of registration you want to perform: manual or dynamic. We've already discussed methods for manual component registration in the other COM+ chapters of the book. The following sections describe the two subscription types and the dynamic method of registering a component.
Transient applications allow you to make a quick subscription to an event object without spending a lot of time traversing the COM+ catalog. In addition, transient subscriptions won't survive a reboot, which means that applications that fail in the middle of a session won't leave permanent bits of
Permanent subscriptions are located in another part of the COM+ catalog and require a lot more work because you have to first locate the right application. The advantage of a permanent subscription is that it survives reboots and tends to be more efficient for use by long-
Sometimes you don't want to clutter the global assembly cache with components that will see intermittent or temporary use. That's where dynamic registration comes into play. Theoretically, you can place an assembly containing a serviced component in the application folder for a COM+ application. When a client
|
|