In this blog entry we will go through some of Enterprise Integration Patterns. These are known design patterns that aims to solve integration challenges. After reading this one would get a head start in designing integration solutions.
EIPs (in short) are known design patterns that provide solutions to issues/problems faced during application integration. The obvious question that comes to mind is, what are those issues/problems that we need to deal while integrating applications?
- Applications are heterogeneous in nature, they are developed using different languages, runs on different OS’es, understand different data formats.
- Applications undergo a lot of change, they are subjected to upgrades, and their API’s change over time.
- They need to exchange data over networks in a reliable and secure manner.
EIPs are classified in the following categories. Adjacent to these, notations that are used to refer these patterns is also specified.
In this mode applications exchange information using files, files are shared at some common location.
Here applications use a common database schema.
An entity mediates between applications that want to exchange data. It does the job of accepting messages from producers and then delivering to the consumers. Messaging helps to achieve loose coupling while integrating applications. It isolates the connecting applications from API changes/upgrades that happens over time.
In this an application exposes its functionality using interfaces, the caller needs to be aware of those and invokes them using stubs. Except RPC all the three mechanisms above are asynchronous in nature.
Next set of patterns talk about Messaging Systems:
Structure of a message is well defined by the messaging system used. It usually contains header and body sections.
Channels are the mediums where messages are produced. They are the usual queue and topics.
Pipes and Filters
This pattern is useful when one needs to process messages before they are delivered to consumer applications.
When the sender application does not know on which channel the receiver
is subscribed to. A router is used in between for delivering messages on the
correct channel. It has routing rules that decides where the messages
shall be delivered.
Translators are used to change the format of message. The sender application might send CSV data while the receiver application understands XML, in that case we need to have a translator before the receiving application that does the job of CSV to XML conversion.
Endpoint is a component that helps an application interact with
messaging systems.They have the protocol built in for communication with
the messaging systems.They are the message producers and the consumers.
Channel patterns: These patterns talk about attributes of messaging channels.
Peer 2 Peer
Channels that deliver a message to a single consumer. Example is a queue
Channels that broadcast a message to all subscribing consumers. Topics are of pub-sub nature.
Dead Letter Channel
Channels used for moving messages which cannot be processed. Cases when the consumer can’t understand or messages get expired. This is important from the point of monitoring & management.
These are the channel adapters that bridges different messaging systems. Consider a case when there are two enterprise systems, one uses Mircosoft’s MQ while the other uses IBM’s MQ server. There you need a bridge that can connect these.
Persistent channels are used to guarantee message delivery. In case the message system crashes, it would lose all messages present in memory. So usually channels are backed up a persistent store where all messages in the channel are stored.
Message Construction Patterns: These patterns are used to specify the intent of the messages. What should the receiver do after getting the message?
These specify a method or a function that the receiver should invoke. Consider the case when XML is being used, the root node may specify the method name while the child elements specify the arguments for method invocation.
When the sender passes data but it does not know what the receiver should do with it.
Sender sends notification messages about changes happening on its end.
Here the receiver may choose to ignore or react to it.
In this the sender expects a reply back. Message might be composed of two parts, one contains the request and other is populated by the receiver i.e. the response.
If the responses are received asynchronously, an id used to correlate the
responses with its corresponding requests.
Content Based Routing
Messages are inspected for determining the correct channel. Where XML is used, rules are written in XPath.
When a receiver is only interested in messages having certain properties, then it needs to apply a filter. This capability is generally comes in built with messaging systems.
In case when messages arrive in a batch. A splitter is required to break the message into parts that can be processed individually.
An aggregator does the opposite job of a splitter. It correlates and combines similar messages.
An enricher does the job of adding extra information to a message.
This is required in case all the data to process the message is not present.
The Content Filter does the opposite it removes unwanted data from a message.
A normalizer does the job of converting messages arriving in different
formats to a common format. Your application needs the ability to accept
data in JSON, XML, CSV etc but the processing logic only understands XML, in that case you need a normalizer.
A transaction client helps in coordinating with external transaction services.
Message dispatcher is a pattern where the receiver dispatches the arriving messages to workers. The workers have the job of processing the message.
Event Driven Consumer
In this the receiver registers an action on the messaging system;
on receiving a message the messaging systems calls that action.
System Management Patterns: These specify ways to monitor and manage systems efficiently.
As the name specifies, the path of the message is changed for doing activities such as validation, logging etc. This extra processing is control based, which can be turned off for performance reasons.
Here the message is copied to a channel and is later retrieved for inspection or analysis.
As the message is passed on from the receiver to the processing unit, the whole message or parts of it (some properties from header or message body) are stored in a central location.
To dive in more details check eaipatterns.com which has elaborated these patterns in-depth. In coming blog entries we will also look into Apache Camel that provides implementation to many of these patterns.
Java Platform, Enterprise Edition is a widely used platform for enterprise server programming in the Java programming language.
This book covers exciting recipes on securing, tuning and extending enterprise applications using a Java EE 6 implementation.The book starts with the essential changes in Java EE 6. Then they will dive into the implementation of some of the new features of the JPA 2.0 specification, and look at implementing auditing for relational data stores.They will then look into how they can enable security for their software system using Java EE built-in features as well as using the well-known Spring Security framework. They will then look at recipes on testing various Java EE technologies including JPA, EJB, JSF, and Web services.Next they will explore various ways to extend a Java EE environment with the use of additional dynamic languages as well as frameworks.At the end of the book, they will cover managing enterprise application deployment and configuration, and recipes that will help you debug problems and enhance the performance of your applications.