MSMQEvent

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

The MSMQEvent object provides an Arrived event that is fired when a message arrives at an associated queue and an MSMQEvent.ArrivedError event that is fired when an error occurs while the message is being delivered or, for asynchronously read messages, when the message is not retrieved before a time-out period elapses. The MSMQEvent object can be used to implement a single event handler that can support multiple queues.

Events

The following table lists the events of the MSMQEvent object.

Event Description
MSMQEvent.Arrived Fired when a message is found or arrives at the applicable position in the specified queue.
MSMQEvent.ArrivedError Fired when an error is generated by Message Queuing for a message arriving at the applicable position in the specified queue.

Each instance of MSMQEvent can be associated with any number of queues. This allows receiving applications to have one generic event handler that can treat all common tasks identically, using the different queue handles passed to the event handler for special-case situations.

The formal parameter passed to the MSMQEvent.Arrived event is of type Object (this is required because event firing is implemented through IDispatch), which means that the event handler uses COM late-binding by default instead of early-binding. However, early-binding is more efficient, and the applications may choose to assign the formal parameter to a local variable of type MSMQQueue to regain the benefits of early-binding.

The MSMQEvent object is implemented in terms of callbacks, and is limited to 64 callbacks per process. Internally, Message Queuing uses the WaitForMultipleObjects function which is limited to 64 objects per process.

Requirements

Windows NT/2000/XP: Included in Windows NT 4.0 SP3 and later.

Windows 95/98/Me: Included in Windows 95 and later.

Header: Declared in Mqoai.h.

Library: Use Mqoa.lib.

See Also

Message Queuing COM Components
MSMQQueue