Home > Store

Designing Applications with MSMQ: Message Queuing for Developers

Register your product to gain access to bonus material or receive a coupon.

Designing Applications with MSMQ: Message Queuing for Developers


  • Sorry, this book is no longer in print.
Not for Sale


  • Copyright 1998
  • Dimensions: 7-3/8" x 9-1/4"
  • Pages: 392
  • Edition: 1st
  • Book
  • ISBN-10: 0-201-32581-0
  • ISBN-13: 978-0-201-32581-2

"This book is an invaluable resource for learning about MSMQ."
--Peter Houston
MSMQ Product Manager, Microsoft Corporation

Microsoft Message Queue Server (MSMQ)--which is incorporated into the newest version of Windows NT--brings asynchronous transaction processing (TP) capabilities to the Windows platform for the first time. MSMQ combines the high performance and robustness of mainframe transaction processing with a flexibility of objects, an administrative ease-of-use, and an ability to scale. As such MSMQ is a key technology contributing to the growth of Internet commerce and intranet distributed processing.

Whether you are a Windows programmer who is new to transaction processing or a UNIX programmer who wants to learn more about MSMQ, this book will introduce you to the topic and show you how to develop transaction-processing applications using the MSMQ technology.

Designing Applications with MSMQ offers an overview of the general design of queued messaging applications and a discussion on how MSMQ can be used in two-tier, three-tier, Web, and component architecture applications. This book also provides a detailed description of MSMQ architecture, queue, and message properties, as well as a detailed description of how MSMQ interacts with other transaction technologies, such as MTS and SQL Server.

A step-by-step tutorial shows you how to write MSMQ applications using COM components, Visual Basic, Visual C++, and the MSMQ API. In addition to the tutorial, this book offers a comprehensive introduction to transaction processing and develops a full-scale application using MSMQ that illustrates the technology's power and potential for this emergent field.



Source Code

Click below for Source Code related to this title:
Source Code

Sample Content

Table of Contents

1. Distributed Architectures and Microsoft Message Queue Server (MSMQ).

Introduction to MSMQ Application Architectures.

Using MSMQ in Well-Known Distributed Application Architectures.

The Future of MSMQ.


Resources and References.

2. Overview of MSMQ Architecture and Features.

Selected Definitions.

Programming Interfaces.

Messages and Message Queues.

Sending and Receiving Messages.

MSMQ Architecture.

Integration with non-MSMQ Messaging Environments.


Resources and References.

3. Properties and Queue Names.


Queue Naming.


Resources and References.

4. An MSMQ Application Using the COM Components.

Overview of Hello World.

MSMQ COM Components.

Queue Creation.

Locating Queues.

Creating the Hello World Sender Form.

Opening Queues and Sending Messages.

Receiving Responses.

Closing Queues.

The Hello World Receiver.


Resources and References.

5. An MSMQ Application Using the MSMQ API.

Overview of Hello World.

Working with Properties in the MSMQ API.

Creating Queues.

Locating Queues.

Opening, Closing, and Deleting Queues.

Receiving Messages and Sending a Response.

The Hello World Sender.

Sample Program Output.


Resources and References.

6. MSMQ Queue and Message Design Considerations.

Hello World Program Analysis.

Queue Options.

Messages and Message Property Options.


Resources and References.

7. Solutions to Message Problems.

Converting Message and Correlation IDs to Strings.

Request and Response Correlation.

Asynchronous Message Processing.

Handling Variable-Length Messages.

Multipart Message Sequences.

Object Shipping.

Working While Off Line.


Resources and References.

8. Improving Message Tracking and Recovery.

Overview of MSMQ Facilities.

Making Messages Recoverable.

Setting Up Message and Queue Journals.

Tracing Message Routing.

Acknowledging Messages.

Recovering and Tracing Messages.


Resources and References.

9. MSMQ Security.


Message Encryption.

MSMQ Access Controls.

Managing Queue Access Programmatically.

Access Event Auditing.

Conclusion and Recommendations.

Resources and References.

10. Introduction to Transaction Processing.

Basics of Transaction Processing.

The ACID Properties.

Distributed Transaction Processing.

Transactional Queued Messaging.

When to Use On-Line or Queued Transactions.

Conclusions and Recommendations.

Resources and References.

11. Implementing Transactions and Assessing Performance.

Basics of Transactional Messaging.

External Transactions.

Internal Transactions.

In-Order Delivery.


Resources and References.

Appendix A: COM Component and MSMQ API Reference.

COM Components.

MSMQ API Functions.

Queue and Message Properties.

Appendix B: Configuring Visual C++ and Visual Basic for MSMQ.

Creating and Configuring a Project in Visual C++.

Creating and Configuring a Project in Visual Basic.

Appendix C: MSMQ Performance.

Messaging Performance.

Conclusions and Recommendations.

Index. 0201325810T04062001


There may be no more fascinating arena to work in these days than the computing industry. We seem to be continually challenged by technological and design revolutions and counterrevolutions, especially in the area of distributed processing. Today software architectures are evolving, and new languages compete for mind share and market acceptance. Processor speeds and network technologies accelerate to accommodate increased distribution.

The world is witnessing several shifts in the way it develops distributed applications.

  • Windows NT is already becoming the middle-tier platform of choice. It will not displace mainframes or UNIX, but we will see its acceptance as a high-performance platform in the next several years.
  • Object-oriented concepts are being adopted within application architectures as they grow to support previously unimaginable degrees of distribution and granularity.
  • Technologies that make distribution possible are setting new standards for ease of use.

Into this space Microsoft has introduced two key technologies: Transaction Server and Message Queue Server. Microsoft Transaction Server (MTS) adds transactions to the object model defined by Microsoft's Component Object Model (COM). Message Queue Server (MSMQ) supports asynchronous transaction processing, whereby applications exchange messages through a message queue. Although less understood by the developers of smaller, two-tier applications, queued messaging has provided the bulk of transaction processing in non-Windows environments for decades.

But MSMQ stands apart from queued messaging technologies of the past. It combines the high-performance communications and reliability of mainframe transaction processing technologies with the flexibility of objects and the large-scale distribution of intranets and the Internet.

Great! MSMQ is an exciting new technology. But why would you be interested in this book? Simply stated, this book offers a lot to various groups of readers.

  • Queued messaging and MSMQ are new to Windows developers. This book will help them to design and to develop messaging applications by using Message Queue Server (MSMQ).
  • Distributed transactional, component systems are emerging as the preferred way to implement Internet and intranet systems on Windows and other platforms. MSMQ is presented in that context.
  • Developers are not the only individuals who must venture into the world of distributed transactional components. Executives and midlevel managers also need to understand the benefits and issues associated with distributed processing and transaction processing (TP).

Although this book has an MSMQ and COM orientation, I have attempted to convey information that is useful outside those contexts. Selected chapters, sections, and paragraphs will be of value to readers who use other messaging environments or other component frameworks.

About This Book

If you are a programmer who will be developing MSMQ applications, I assume that you are proficient in Visual Basic or C/C++. In addition, you should be familiar with Windows as a user. This text does not assume Windows programming knowledge, but that knowledge certainly helps. Also, information systems executives and managers need not be developers to derive value from this book.

This book does not go step by step through MSMQ Enterprise, Site, Server, and Client setup. I discuss design trade-offs in Chapter 2 and demonstrate creation of queues in Chapter 4. However, MSMQ makes setting up an Enterprise, Sites, Servers, and Clients straightforward. It does not warrant duplication here.

This book also ignores the creation of e-mail and connector applications. I would be interested in hearing from readers as to whether they want these or other topics covered in a future release of this book.

Organization of This Book

Chapter 1 tells how queued messaging is similar and different from other forms of communications. Then it describes how MSMQ can be used in two-tier, three-tier, Web, and component architectures. This chapter will be useful to IS executives, development managers, and programmers with limited backgrounds in distributed applications or object-oriented concepts.

MSMQ delivers terrific deployment flexibility and administrative ease of use. These features are highlighted in Chapter 2 as part of a detailed overview of the MSMQ architecture. Level 8 Systems technologies are also described, since most companies will need to integrate non-Windows resources with MSMQ (and vice versa).

Any MSMQ application needs to understand how queues can be configured and messages can be exchanged. In an MSMQ architecture, queues and messages are modeled as objects and have properties associated with them. Chapter 3 introduces queue and message properties. It also describes the kinds of queue names that MSMQ applications must use.

Chapter 4 uses Visual Basic to teach basic queued messaging. In this chapter we implement a version of the well-known Hello World application, using COM components. In Chapter 5 the exercise is repeated, using Visual C++ and the MSMQ (C language) API. COM components can be used in C++ programs and Java applets. (The COM examples contained in Chapter 4 and other chapters could easily be converted to those languages.)

Chapter 6 begins with a critique of the Hello World applications developed in Chapters 4 and 5. Using those applications, we illustrate queue and messaging architectures that satisfy various project goals, requirements, and assumptions.

Several processing scenarios are common in messaging environments. For example, client applications usually need to correlate a request and a response. Also, servers may want to conserve processing resources by triggering processing only when a message is available. These and other processing requirements are implemented in Chapter 7.

One of the differences between queued messaging and on-line kinds of communication, such as remote procedure calls (RPCs), is that they provide much richer failure handling. Messages can be made recoverable and can be copied to journal queues on the source and destination machines. You also have the ability to trace the route that the message takes through a network and can receive acknowledgments that a message reached a receiver or its target queue. Chapter 8 demonstrates how to use these facilities in your program and suggests how they may be used in administrative programs.

MSMQ security is particularly attractive. Chapter 9 discusses MSMQ administrative and programmatic security features. Administrative operations, including configuring access control and auditing, are demonstrated. Program-to-program authentication and message encryption are implemented.

Chapter 10 introduces transaction processing concepts. It begins by describing the value of transaction processing. Atomicity, consistency, isolation, and durability are explained. Then the chapter elaborates on several issues relating to distributed transaction processing. It examines the strengths and weaknesses of on-line distributed transaction processing systems and queued messaging. Compensating transactions and the two-phase commit protocol are also reviewed.

A transactional queued messaging application is developed in Chapter 11. It illustrates how to transactionally send and receive messages, as well as how to combine these operations with other transactional operations, such as database updates.

Appendix A provides a brief reference to COM components and the MSMQ API. Appendix B describes how to set up MSMQ projects in Visual C++ and Visual Basic. MSMQ performance test results are described in Appendix C, and hints are offered.

Gaining Additional Help

The industry is still in the early stages of delivering infrastructures for the development of distributed transactional object systems. Likewise the art of developing distributed transactional object applications is in its infancy. This book attempts to address many basic questions a reader might ask. Complete coverage is a noble goal but is one that no author can hope to achieve.

Luckily resources are available to help you solve your problems. Microsoft does a great job of making its products accessible to users through the Web. You can expect to see Microsoft place white papers on its Web site. Information related to MSMQ can be found at:


PSW Technologies also has several resource pages devoted to MSMQ, transaction processing on Windows NT, and porting applications from UNIX to Windows. Please visit our Web site at:


For information about connecting MSMQ to non-Windows platforms, visit the Web site of Level 8 Systems for information about their message queuing solutions:


When all else fails, you can communicate via e-mail. Please address questions to:



Writing a book is challenging and tiring. Above all, it is a humbling experience. I have benefited in so many ways from numerous people.

My book reviewers were terrific. Thanks to Oran Bodner, Ilan Caron, and Alexander Dadiomov at Microsoft, who helped me sort through a lot of technical details. Melodi Gates, Jay Lang, Ken Walker, and Gene Belitski offered great suggestions and practical insights.

Others at Microsoft were very helpful, too! Peter Houston made human and intellectual resources available to me. Amnon Horowitz, Doran Juster, Nir Katz, and Syed Yousef contributed a lot of time. I owe a tremendous debt to Dr. Frank King, as well as to Brian Baisley, Bill Cason, Dennis Thompson, Christine Kungl, Mike McCown and others of PSW Technologies for giving me the time to explore MSMQ and the resources to write. Thanks to Reid Spencer of PSW Technologies for reviewing parts of this book. Also, thanks to several readers of Microsoft's MSMQ newsgroups for sharing their questions and experience.

Special thanks to Carter Shanklin, Elizabeth Spainhour, Genevieve Rajewski, John Fuller, Krysia Bebick, and others who have made working with Addison-Wesley such a pleasant experience.

Finally, my family and friends stayed out of my way when I was working and distracted me when I needed a break.

--Alan Dickman
PSW Technologies, Inc.



Submit Errata

More Information

Unlimited one-month access with your purchase
Free Safari Membership