Enterprise Integration Patterns
Messaging Patterns
HOME PATTERNS RAMBLINGS ARTICLES TALKS DOWNLOAD BOOKS CONTACT
Messaging Patterns
Introduction to Simple Messaging ExamplesIntroduction to Simple Messaging ExamplesMessaging Patterns » Interlude: Simple Messaging

So far, we’ve introduced a lot of patterns. We’ve seen the basic Messaging Components, such as Message Channel, Message, and Message Endpoint. We’ve also seen detailed patterns for Messaging Channels and for Message Construction.

So how do all of these patterns fit together? How does a developer integrate applications using these patterns? What does the code look like, and how does it work?

This is the chapter where we really get to see the code. We have two examples:

These two simple examples should get you started on how add messaging to your own applications.

Request/Reply Example

This is a simple but powerful example, transmitting a request and transmitting back a reply. It consists of two main classes:

These two simple classes sending simple messages illustrate a number of the patterns:

The example code also demostrates a couple of patterns from the Messaging Endpoints chapter later in the book:

While this book is technology-, product-, and language-neutral, code cannot be. So we’ve choosen two messaging programming platforms to implement this example:

The same request/reply example is implemented in both platforms. So choose your favorite platform as an example of how messaging works. If you’d like to see how messaging works on the other platform, even if you don’t know how to write code for that platform, you should be able to figure out how that code works by comparing it to the code in the language you already know.

Publish/Subscribe Example

This example explores how to implement the Observer pattern using a Publish-Subscribe Channel. It considers distribution and threading issues and discusses how messaging greatly simplifies these issues. The example shows how to implement both the push and pull models of notification and compares the consequences of each. It also explores how to design an adaquate set of channels needed for a complex enterprise with numerous subjects notifing numerous observers.

The discussion and sample code will illustrate several patterns:

The example code also demostrates a couple of patterns from the Messaging Endpoints chapter later in the book:

This example is implemented in Java using JMS because JMS supports Publish-Subscribe Channel as an explicit feature of the API through its Topic interface. .NET does not provide a similar level of support for using the publish/subscribe semantics in MSMQ; when it does, the techniques in the JMS example should be readily applicable to .NET programs as well.

Enterprise Integration Patterns book cover

Enterprise Integration Patterns
The de-facto language for designing asynchronous, distributed systems. Over 100,000 copies sold.

Software Architect Elevator book cover

The Software Architect Elevator
Rethink the role of architects as a connecting element across organizational layers. Acquire the technical, communication, and organizational skills to succeed in this new role.

Cloud Strategy book cover

Cloud Strategy
Make your cloud migration a success by translating high-level goals into conscious decisions with well-understood trade-offs.

Platform Strategy book cover

Platform Strategy
Platforms can boost innovation through harmonization, but they aren't easy to build. Learn from over a decade of designing and rolling out IT platforms.