Naughter Software Logo

MSMQWrappers v1.10 A set of C++ classes to provide a complete C++ encapsulation of MSMQ (Microsoft Message Queuing)

The classes provided are: MSMQ::CCursor, MSMQ::CQueue, CMSMQ::CSearch, MSMQ::CSecurityContext, ATL::CComPropVariant, ATL::ComPropVariant2, & MSMQ::CPropVariantAutoFree.

CCursor provides a class based encapsulation of a cursor as returned via MQCreateCursor.

CQueue provides a class based encapsulation of a queue as returned via MQOpenQueue.

CSearch provides a class based encapsulation of a search as returned via MQLocateBegin.

CSecurityContext provides a class based encapsulation of a security context as returned via MQGetSecurityContextEx.

CComPropVariant provides a class based encapsulation of a SDK PROPVARIANT structure with automatic lifetime management of the resources which a PROPVARIANT can contain. Internally MSMQ makes extensive use of this structure which is similar to the good old COM VARIANT structure. I would have expected there to be a built in ATL class to do this wrapping but there isn't one I could find. This class is modeled upon the ATL CComVariant class and as such I decided to put it in the "ATL" namespace instead of "MSMQ". This class is self contained in its own right and should prove useful in ATL COM development when dealing with the PROPVARIANT structure.

CComPropVariant2 is similar to CComPropVariant except that the lifetime management of the resources which the PROPVARIANT can contain is left up to client code to manage. This is the memory model primarily adopted by MSMQ. Similar to CComPropVariant class, it makes initializing the VARTYPE and various union elements of a PROPVARIANT much easier to code and understand.

CPropVariantAutoFree is another wrapper for the PROPVARIANT structure which provides automatic cleanup of memory allocated via MSMQ via MQFreeMemory in its destructor. Again this C++ encapsulation reduces the amount of boilerplate code you need to write when programming to the MSMQ API. For various examples of using this class in addition to the CComPropVariant(2) classes please see the MSMQDemo.cpp source code module.

Going forward I may add additional wrapper classes to make dealing with the various array structures such as MQQUEUEPROPS, MQMSGPROPS, MQMGMTPROPS etc used in MSMQ easier to program to as well as reducing the boilerplate code required to setup each of these structures. Please let me know your thoughts on this. The development of MSMQWrappers took a number of weeks of hard work researching, developing and testing and hopefully you should find them useful in your C++ MSMQ programming efforts.

 

Features

 

The enclosed zip file contains the MSMQWrappers source code and a VC 2017 console based application which exercises all of the various classes functionality. You will of course need to have MSMQ installed on your machine. To fully exercise some of the functionality in the demo app you will need to have your computer joined to a corporate AD environment.

 

Copyright

 

Updates

v1.10 (19 May 2023)

v1.09 (19 February 2022)

v1.08 (31 October 2021)

v1.07 (12 February 2020)

v1.06 (18 December 2019)

v1.05 (15 September 2019)

v1.04 (20 April 2019)

v1.03 (22 September 2018)

v1.02 (19 December 2017)

v1.01 (22 November 2015)

v1.0 (5 May 2014)