Accessibility

Flex Article

 

Introduction to the Flex Message Service


Table of Contents

Comments

The publish-subscribe message pattern

Asynchronous messaging has formed the basis of enterprise systems for decades, not only in the form of MOM used for enterprise integration, but also in the underpinnings of client-server technology; in application servers from Java to .NET; and even in RPC mechanisms from CORBA and synchronous SOAP, which may be viewed as special cases of messaging.

The core premise is simple: a producer creates a message and sends it to some logical destination, while a consumer attaches itself to the destination and listens for messages sent to it. Producers and consumers, commonly known as message agents, perform actions and otherwise collaborate by exchanging messages through a common hub, which is the destination.

The system must know the structural definition of a message, although that structure may be translated across a variety of protocols and represented in a variety of formats along the way. Similarly, the system must know the message semantics to some degree—wherever message contents cause business logic to execute across all the platforms a message may touch during its journey. The producer must be able to receive acknowledgment that its messages were reliably received; the destination must be able to correlate messages and potentially persist them in order to reliably and durably route them to all the interested consumers; and there are a variety of protocols, mechanisms, and design policies that add or detract from the quality of service provided by message publication and consumption. The core producer-destination-consumer relationship that supports message passing is the gist of the pattern.

Figure 1 shows an illustration of publish-subscribe messaging.

Publish-subscribe messaging

Figure 1. Publish-subscribe messaging

In simple RPC applications of messaging, there may be no consumers at all. Instead, a producer may publish a message and receive an acknowledgement which, in addition to informing the producer that the message was received, also contains information that can be interpreted as some sort of logical result of a synchronous remote invocation. In fact, this is the case with the three Flex RPC services: HttpService, WebService, and RemoteObject. The Flex Message Service, however, uses both producers and consumers. Since the Flex data service is a subclass of the Message Service, it also leverages producers and consumers.

Publish-subscribe messaging is not the only common message pattern in the enterprise: Point-to-point topologies are also prevalent. The difference between the publish-subscribe pattern and point-to-point messaging is that in the latter, messages are queued in the destination and delivered only to one consumer. This pattern is very useful in system-to-system use cases. You can tailor publish-subscribe messaging so that your application delivers a message to zero or only one consumer, based on the evaluation of message criteria that connected consumers may establish. But fundamentally, publish-subscribe messaging links many consumers to the same logical destination, while point-to-point topologies ensure that only one consumer receives any given message. The Flex Message Service focuses on publish-subscribe messaging to link rich clients to one another and to common enterprise back ends.