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 classic, as relevant as ever. Over 90,000 copies sold.

Software Architect Elevator book cover

The Software Architect Elevator
Learn how architects can play a critical role in IT transformation by applying their technical, communication, and organizational skills.

Cloud Strategy book cover

Cloud Strategy
Fill the large gap between high-level goals and product details by understanding decision trade-offs.