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

ID: Q236587


The information in this article applies to:
  • Microsoft Message Queue Server version 1.0


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. Click the file names below to download the files:

ATLAsync.exe
For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center. The following table describes the files necessary for the ATLAsync.exe application:

File Size Description
ATLAsync.cpp 4,383 Main implementation file, contains implementation for CExeModule and WinMain
ATLAsync.dsp 13,092 Project file
ATLAsync.dsw 636 Project workspace
ATLAsync.h 1,303 Header for main implementation file
ATLAsync.idl 414 IDL code for server
ATLAsync.rc 4,270 Resource script
ATLAsync.rgs 179 ATL registry information for registering server
ATLAsyncps.def 250 DEF file for project proxy stub
ATLAsyncps.mk 466 Makefile for proxy stub
ATLAsync_i.c 949 MIDL generated file to contain GUIDs and other data
EnterQueueForNotificationDlg.cpp 266 Source file for main dialog
EnterQueueForNotificationDlg.h 5,393 Header file for main dialog, contains the implementation for CEnterQueueForNotificationDlg
readme.txt 1,590 Project readme file
resource.h 813 Resource header
SinkMSMQEvents.cpp 8,519 Implementation for CSinkMSMQEvents and CQueueSinks
SinkMSMQEvents.h 2,222 Header for SinkMSMQEvents, contains the definition of CSinkMSMQEvents and CQueueSinks
StdAfx.cpp 315 Precompiled header source file
StdAfx.h 1,201 Precompiled 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:

Q194179 SAMPLE: AtlEvnt.exe Creates ATL Sinks Using IDispEventImpl
Q181277 SAMPLE: AtlSink Uses ATL to Create a Dispinterface Sink

Additional query words: MSMQ Events ATL

Keywords : kbfile kbMSMQ kbMSMQ100 kbGrpPlatform kbDSupport
Version : winnt:1.0
Platform : winnt
Issue type : kbhowto


Last Reviewed: January 13, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.