Getting started with messaging patterns

Messaging is a reliable technique that is used for interconnecting applications using the concept of packets called messages. These packets are sent to channels, which are logical pathways providing interconnection between the various applications. These channels are also called queues. Several messages can be queued up in a channel and can be made accessible to multiple applications at the same point in time. There are two main types of applications in messaging, they are:

  • Sender/producer
  • Receiver/consumer

A sender is an application that sends a message to the channel. A receiver is an application that reads the message that is sent to the channel. Messaging is an asynchronous mode of communication, meaning it is not necessary that the receiver should read the message from the channel as soon as it reaches the channel.

A message could be any kind of data structure, such as an array, string, or object. Every message contains two parts:

  • Header
  • Body

The header contains metadata about the message, such as details of the sender, receiver, timestamp, and so on. This information is used by the messaging system but is usually ignored by the applications. The message body contains the actual data that is sent by the application. The body of the message is ignored by the messaging system but is used by the applications.

Messaging capabilities are provided to a system by a specialized software application called message-oriented middleware (MOM). MOM is also called a messaging system. MOM is required to ensure smooth transmission of messages across applications. One of the main reasons for the existence of MOM is the unreliable state of networks that interconnect the systems. Even if a message is sent by an application, it is not necessary that it reaches the intended destination if the network is not proper. MOM helps to overcome this network-related limitation and other limitations, and ensures that a message is repeatedly transmitted until it reaches its destination. The communication of applications through messaging is depicted in the following diagram:

The following are the five steps involved in message transmission:

In each of these steps, the following activities are performed:

  1. Create: In this step, the sender or producer adds a header and data and creates the message
  2. Send: In this step, the sender sends out the message to the channel
  1. Deliver: In this step, MOM moves the message from the sender's system to the receiver's system making the message available for the receiver
  2. Receive: In this step, the receiver or consumer reads the message from the channel
  3. Process: In this step, the receiver extracts the data from the message

In the next section, we will examine the prominent messaging patterns that are used in the design of enterprise systems.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset