ATLAsync.exe: Using MSMQEvent Events With ATL 3.0 For Asynchronous Message Notification (236587)



The information in this article applies to:

  • Microsoft Message Queue Server (MSMQ) 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:
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:

File Size Description
ATLAsync.cpp4,383Main implementation file, contains implementation for CExeModule and WinMain
ATLAsync.dsp13,092Project file
ATLAsync.dsw636Project workspace
ATLAsync.h1,303Header for main implementation file
ATLAsync.idl414IDL code for server
ATLAsync.rc4,270Resource script
ATLAsync.rgs179ATL registry information for registering server
ATLAsyncps.def250DEF file for project proxy stub
ATLAsyncps.mk466Makefile for proxy stub
ATLAsync_i.c949MIDL generated file to contain GUIDs and other data
EnterQueueForNotificationDlg.cpp266Source file for main dialog
EnterQueueForNotificationDlg.h5,393Header file for main dialog, contains the implementation for CEnterQueueForNotificationDlg
readme.txt1,590Project readme file
resource.h813Resource header
SinkMSMQEvents.cpp8,519Implementation for CSinkMSMQEvents and CQueueSinks
SinkMSMQEvents.h2,222Header for SinkMSMQEvents, contains the definition of CSinkMSMQEvents and CQueueSinks
StdAfx.cpp315Precompiled header source file
StdAfx.h1,201Precompiled header file


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.

REFERENCES

For additional information, please click the article number(s) below to view the article(s) in the Microsoft Knowledge Base:

194179 SAMPLE: AtlEvnt.exe Creates ATL Sinks Using IDispEventImpl

181277 SAMPLE: AtlSink Uses ATL to Create a Dispinterface Sink


Modification Type:MinorLast Reviewed:8/5/2004
Keywords:kbdownload kbfile kbhowto KB236587 kbAudDeveloper