Arrived
MSMQEvent

The Arrived event is fired when EnableNotification has been called and some message is found in the queue.

Syntax

object_Arrived(byval Queue as Object)
 
Syntax Element Description
object Instance of event (MSMQEvent) object used for the event handler.
Queue Queue (MSMQQueue) object that represents an open instance of the queue where the message arrived.

Remarks

The Arrived event is fired by an instance of the MSMQEvent object. Every queue that has called EnableNotification triggers an instance of the MSMQEvent object when a message arrives in the queue (this includes existing messages in the queue when EnableNotification is first called).

There is no association between an Arrived event and a specific message. The arrived event only means that some message arrived in the queue.

Although an Arrived event is fired for each message, there is no guarantee that the message that triggered the event will still be there when the event handler tries to use the message. Queues are dynamic, and another application may have already removed the message that triggered the Arrived event.

EnableNotification must be explicitly reset after each Arrived event is fired.

Example

This example assumes that queues q1 and q2 are open and that they are not being shared by another application. EnableNotification is called, and then the label of the first message in the queue (if messages are already in the queue), or the first message sent to the queue, is displayed.

Dim WithEvents qevents as MSMQEvent
Dim q1 as MSMQQueue
Dim q2 as MSMQQueue
 
Sub Enable
    'Assuming q1 and q2 are open.
    q1.EnableNotification
    q2.EnableNotification
End Sub
 
Sub event_Arrived (byval q as Object)
    'Generic event handler
    Dim qArrive as MSMQQueue
    Set qArrive = q                'Cast Object reference to MSMQQueue

    'This example assumes the message has not been removed 
    'by another application.
    msgbox "Message in following queue: " + qArrive.QueueInfo.Label
    qArrive.EnableNotification Event       'Reenables notification.
End Sub
 

QuickInfo

  Windows NT: Requires version 4.0 SP3 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in mqoai.h.
  Import Library: Use mqoa.lib.
  Unicode: Defined only as Unicode.

See Also

EnableNotification, MSMQQueue