COM+ is an evolution of Microsoft Component Object Model (COM) and Microsoft Transaction Server (MTS). COM+ builds on and extends applications written using COM, MTS, and other COM-based technologies.
2. PUBLISHING INFORMATION
• One of the classic programming problems of distributed
computing is how to advertise and deliver information to
one or more interested parties without a priori knowledge
of their identity
• In this context there are only two types of programs:
those who possess info, and those who need it
3. Application client
IStockEvents
Component
THE COMPONENT PROGRAMMING MODEL
(REQUEST/REPLY)
• Early bound
• Class Identity (CLSID) usually compiled in
• 1 : 1
• Client calls a single component
• Blocking
• Client thread generally blocks until
the call completes
4. Subscriber
Publisher
PUBLISH/SUBSCRIBE SYSTEMS
(PUSH)
• Late bound
• Subscriber identity not known at development time
• 1 : many
• “Events” are sent to all registered subscribers
• Non-blocking
• Publishers generally do not wait
for a response from subscribers
Subscriber
Subscriber
6. COM EVENTS TODAY
(CONNECTION POINTS)
• No activation
• Shared life-cycles between publisher
and subscriber
• Interface-only (no implementation)
• Binding, dispatching, error semantic,
etc., left to developer
• Subscriptions aren’t persistent
• No opportunity for interception between publisher and subscriber
7. option explicit
' --------------------------------------------------
' Call a simple component
' --------------------------------------------------
Dim obj
set obj = CreateObject(”StockComponent.1")
obj.StockPriceChange ”MSFT", 185.00
set obj = Nothing
COM+ PROGRAMMING MODEL
• Simple programming model
• Create Object, Invoke method, Release
Client
IStockEvents
StockComponent.1
8. option explicit
' ------------------------------------------
' Fire an event
' ------------------------------------------
Dim obj
set obj = CreateObject(”StockEvents.1")
obj.StockPriceChange ”MSFT", 185.00
set obj = Nothing
COM EVENTS
PROGRAMMING MODEL
• Same basic programming model
• Create Object, Invoke method, Release
Subscriber
Publisher
IStockEvents
Event class
(StockEvents.1)
IStockEvents
IStockEvents
IStockEvents
Subscriber
Subscriber
9. EVENT CLASS AS INTERMEDIARY
• Indirection between the publisher
and subscriber
• Meta-data defined (CLSID, ProgID, IID)
• Requires no coding on part of developer
• Exposes arbitrary interface
• May be Secured to control event delivery
• Subscriptions are wired to methods within the EventClass’ firing
interface
10. TRANSFORMATIONS VIA
THE “EVENTCLASS”
• Introduction of the EventClass caused two transformations:
• Ordinary, vanilla COM client
became a publisher
• Ordinary, vanilla COM component became a subscriber
• Publisher = COM client
• Subscriber = COM component
11. EVENT CLASS INTERFACE
EXAMPLE
interface IStockEvents
{
HRESULT StockPriceChange ( BSTR StockSymbol, double Price );
HRESULT NewStock ( BSTR StockSymbol, BSTR CompanyName );
HRESULT StockSymbolChanged (BSTR OldSymbol,
BSTR NewSymbol );
HRESULT DowJonesUpdate ( double Current );
};
• Each method may have 0 - n subscriptions
• Subscribers expose this interface as well
You subscribe
to individual
methods on the
firing interface
IStockEvents StockEvents.1
{ 877E7998-E8EC-11D1-B994-00C04F990088 }
12. option explicit
Dim EventSystem
Dim EventClass
set EventSystem = CreateObject("EventSystem.EventSystem")
' ----------------------------------------------
' Subscription for IStockEvents.StockPriceChange
' ----------------------------------------------
set EventClass = CreateObject("EventSystem.EventClass")
EventClass.EventClassID = "{58A7E1A1-5A4A-11d2-BD11-0080C72B9899}"
EventClass.EventClassName = "StockEvents"
EventClass.FiringInterfaceID = "{58A7E1A2-5A4A-11d2-BD11-0080C72B9899}"
EventSystem.Store "EventSystem.EventClass", EventClass
Set EventClass = Nothing
CREATING AN EVENTCLASS
14. HOW DO I SUBSCRIBE?
• Traditionally:
• Subscriber gives pointer to
self to a publisher
• This is problematic!
• Lifecycles must be shared
• Assumes one publisher of the event
• Adds complexity to subscriber
• Subscriber now “knows about”
the publisher
• Subscriber includes subscription
building logic
16. TIGHTLY-COUPLED SUBSCRIPTIONS
• This model cannot be used if:
• Subscribers do not want to be active until the event is fired
• Subscribers want to subscribe prior to publisher start-up or installation
• Administrative management of subscriptions is required
• Publisher of event changes over time
17. ◆ A subscription is a relation composed of:
◆ EventClass (IID inferred)
◆ A specific method within the EventClass interface
◆ A subscriber
◆ May be a CLSID, moniker or an interface pointer
◆ The use of CLSID solves the activation problems, but not the
life-cycle issue
Publisher
Event
class
Subscriber
StockEvents StockPriceChange StockSubscriber StockSymbol = “MSFT”
EventClass EventMethod Subscriber PublisherProperties
SUBSCRIPTION AS
A FORMAL OBJECT
18. SUBSCRIPTION DETAILS
• MachineName
• Used to indicate that the subscribing component must be called remotely
• Subscriber
• May be a CLSID, moniker or interface pointer
• Security
• May be Secured
• Publisher Properties
• May be used by the publisher for filtering, etc.
• Subscriber Properties
• May be used by the subscriber for filtering, forwarding, etc.
• Roaming
• Subscription follows the user (owner)
19. Publisher
Event
class
Subscriber
COM+ Events
Subscription
DECOUPLING THE LIFE-CYCLES
• Achieving independent life-cycles requires that a third-party become involved: COM+
events
• Subscribers add subscriptions to COM+ events
• Publisher’s EventClass retrieves subscriptions from
COM+ events
20. Subscriptions
SURVIVING SYSTEM FAILURES
• Ensuring subscriptions survive software failures requires persistence
• COM+ Events stores subscriptions
in a database
Publisher
Event
class
Subscriber
COM+ Events
Subscription
21. FORMALIZING THE ROLE OF
“SUBSCRIPTION BUILDER”
• Most publish/subscribe models do not delineate between:
• Subscribers
• Subscription builders
• Subscriber = Component which receives an event call
• Subscription Builder = Entity that registers the subscriber to receive
the event
24. Dim EventSystem
Dim EventSubscription
set EventSystem = CreateObject("EventSystem.EventSystem")
' ----------------------------------------------
' Subscription for IStockEvents.StockPriceChange
' ----------------------------------------------
set EventSubscription = CreateObject("EventSystem.EventSubscription")
EventSubscription.SubscriptionID = "{0019B161-69D9-11D1-88D1-0080C7D771BF}"
EventSubscription.SubscriptionName= "ESSample.StockPriceChange"
EventSubscription.EventClassID = "{F89859D1-6565-11D1-88C8-0080C7D771BF}"
EventSubscription.MethodName = "StockPriceChange"
EventSubscription.SubscriberCLSID = "{C658CAB0-89A2-11D1-891C-0080C7D771BF}"
'EventSubscription.PutPublisherProperty "StockSymbol", "MSFT"
EventSystem.Store "EventSystem.EventSubscription", EventSubscription
Set EventSubscription = Nothing
CREATING A SUBSCRIPTION
25. SUBSCRIPTION SUMMARY
• Subscriptions as objects are more expressive than mere
“object pointers”
• Subscriptions are added to COM+ events
• Subscriptions are managed by COM+ events
• Subscriptions are persisted by COM+ events
• Subscriptions may be queried
• Subscriptions may be secured
• Subscriptions may be shared by multiple publishers
(instances)
• Publishers and subscribers
• May be uncoupled
• Need not share life-cycles
33. COM+ EVENTS STORE
• Component-based
• Load balancing, security, transactions
• Secure
• Accessible via Windows NT® service
(COM+ event system)
• Publishes events
• EventObject added, modified, deleted
• Not required for firing events
34. COM+ EVENTS SECURITY
• Subscriber
• Subscriber components use standard COM/COM+ security to protect
against “fake” publishers
• EventClass
• COM+ role based security prevents unauthorized subscriptions from being
registered to receive secure events
• All objects in Event Store may be Secured
• Event Store
• Only accessible by Windows NT Service running as “Local system”
35. COM+ EVENTS
COMPOSITION
• COM/COM+ features:
• Interfaces
• Transactions
• Object pooling
• Just-in-time activation
• Queued components
• Deployment
• Load balancing
• Role-based security
• Windows NT features:
• MMC-based admin
• Windows NT roaming
37. MS PRODUCTS IMPLEMENTING COM+
EVENTS
• SENS - System Event Notification Service
• Publishes login/logout, network connect/disconnect, Plug and Play,
shell start/end, etc.
• SyncMgr
• Subscribes to SENS and coordinates
application synchronization
• COM+
• All COM+ components fire debug/trace
events using COM+ events
• Tools
• Support currently being added across
both our languages and tools