Microsoft KB Archive/236587

= ATLAsync.exe: Using MSMQEvent Events With ATL 3.0 For Asynchronous Message Notification =

Article ID: 236587

Article Last Modified on 8/5/2004

-

APPLIES TO


 * Microsoft Message Queue Server 1.0

-



This article was previously published under Q236587



SUMMARY
ATLAsync.exe is a sample that demonstrates using ATL 3.0 to sink MSMQEvent events.

This sample uses IDispEventImpl to sink the events for the MSMQEvent co-class. In order to compile and run this sample you must have ATL 3.0 or higher and the MSMQ SDK installed.



MORE INFORMATION
The following files are available for download from the Microsoft Download Center:

ATLAsync.exe

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. The following table describes the files necessary for the ATLAsync.exe application:

This project demonstrates how to sink MSMQEvent events using ATL 3.0. The IDispEventImpl class in ATL allows your class (in this case CSinkMSMQEvents) to sink IDispatch events. The actual event sink is set up with both the sink map:

BEGIN_SINK_MAP(CSinkMSMQEvents) SINK_ENTRY_EX(0, DIID__DMSMQEventEvents, 0, Arrived) SINK_ENTRY_EX(0, DIID__DMSMQEventEvents, 1, ArrivedError) END_SINK_MAP and the call to DispEventAdvise in CSinkMSMQEvents::AdviseSource.

In addition CSinkMSMQEvents contains an instance of the MSMQEvent object and a reference to the MSMQQueue object passed to CMSMQEvents::AdviseSource. All of the event sinks (CSinkMSMQEvents objects) are contained in a Standard Template Library (STL) list which is contained in a CQueueSinks object. An instance of this class is contained in the CEnterQueueForNotificationDlg dialog class. This is used to set up the event sinks.

This example will allow you to set up notifications on any number of queues and send test messages to see the notifications work. To set up notifications on a queue, enter the name in the upper edit box of the dialog box. The second edit is used to enter the name of the queue to which you want to send test messages to.

When you notify on a queue, the sample code will propagate the path name of the queue to the send test message edit box. If you attempt to notify on a queue that does not exist, the sample will attempt to create that queue.

