Designing Applications with MSMQ: Message Queuing for Developers
Authors: Alan Dickman
Venue:  (1998)

From the Book: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 revolutionsand counter revolutions, 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 developer 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 mid level 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 message scan 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: www.microsoft.com/NTServer/Basics/AppServices/MSMQ/ 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: www.psw.com/ For information about connecting MSMQ to non-Windows platforms, visit the Web site of Level 8 Systems for information about their message queuing solutions: www.level8.com/ When all else fails, you can communicate via e-mail. Please address questions to: alan@psw.com Thanks 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.