Introduction to Enterprise Integration Patterns

smater-hiers
Reading Time: 3 minutes

Enterprise Integration Patterns are a collection of typical solutions to integration difficulties. EIP’s specify how distinct components of a system can communicate with one another regardless of platform, operational systems, programming language, or technology stack and If we want to build a messaging system, you must understand the fundamental concepts of The Enterprise Pattern.

We can use EIP’s in the following scenarios :

  • Information Portals: A single query or business function must communicate with multiple systems.
  • Data Replication: Many business systems rely on the same data.
  • Shared Business Functions: Several business functions necessitate the same functionality.
  • Service-Oriented Architectures: corporate service administration and “bus” communication.
  • Distributed Business Processes: Multiple systems should handle the same business transaction.
  • Business-to-Business Integration: communication alignments between systems from various firms.

Lets now discuss the top EIP’s:

  1. AGGREGATOR
  2. SPLITTER
  3. Routing Slip
  4. Dynamic Router
  5. Load Balancer

AGGREGATOR EIP

The Aggregator aggregates several relevant incoming messages into a single aggregated message. The Aggregator accepts a stream of messages, finds those that are similar, and aggregates them into a single unified message. Following the occurrence of a completion condition, the aggregated message goes to the output channel for further processing.

When implementing the Aggregator, we must pay close attention to the following three settings. Failure to do so will result in Camel failing to start and reporting an error about the missing configuration:

  • Correlation identifier — An expression used to detect which inbound messages are related.
  • Completion condition — Time-based condition that determines when the result message should be issued.
  • Aggregation strategy — An Aggregation Strategy indicates how the messages will combine into a single message.

SPLITTER EIP

Messages travelling via an integration solution may have several items, such as an order with more than one line item. Each line in the order may require different treatment, thus you’ll need a method that processes the entire order while handling each line item separately. The Splitter EIP is the answer to this problem.

The Splitter divides an incoming message into several smaller messages.It functions similarly to a large iterator that iterates through a list of entries and processes each one.

When using the Splitter, we must configure an Expression which we evaluate whenever a message arrives and the evaluation result is utilised to generate java.util.Iterator. The Splitter then employs the iterator until no more data is available and each message sent by the iterator is a copy of the original message with the message body replaced.

  • Exchange.SPLIT_INDEX – The index for the currently processed message. The index is based on a value of zero.
  • Exchange.SPLIT_SIZE – The total number of messages into which the original message will be divided.
  • Exchange.SPLIT_COMPLETE – Whether this is the last message to be analyzed.

Routing Slip EIP

Sometimes we want to route messages dynamically. We might have an architecture that requires incoming messages to go through a series of processing steps and business rule validations and because the processes and validations differ so greatly, each step can be a distinct filter. The filter serves as a model structure for enforcing business rules and validations. therefore the best way to do this is by using the ROUTING SLIP EIP.

The Routing Slip functions as a dynamic router, dictating the next step a message should take.

Dynamic Router EIP

We already know that the Routing Slip pattern functions as a dynamic router. What is the distinction between Routing Slip and Dynamic Router EIPs? The difference is minor: the Routing Slip must compute the slip ahead of time, but the Dynamic Router will choose where the message should travel next on the go.

The Dynamic Router, like the Routing Slip, requires us to specify logic that determines where the message should go. Such logic is easy to implement using Java code, and we have complete control over where the message should move next.

Load Balancer EIP

Load balancing is a technique for dividing workload across computers or other resources in order to “achieve optimal resource utilisation, boost throughput, decrease reaction time, and minimise overload.” This service can be provided as a physical device or as software, such as Camel’s Load Balancer EIP

The Load Balancer EIP provides methods for adding and removing processors that we can use in load balancing. The load balancer can balance anything you can declare in your Camel routes because it uses processors instead of endpoints. You must choose a balancing approach while utilising the Load Balancer EIP and The round-robin technique is a typical and understandable strategy that involves taking turns between services.

Load-balancing strategies provided by Camel

  • Random – Picks a processor at random.
  • Round Robin – Selects a processor in a round-robin method, distributing the load evenly.
  • Sticky – An expression to calculate a correlation key, which determines the processor. Consider this to be the HTTP session ID.
  • Topic – The message goes to all processors. This is equivalent to sending to a JMS topic.

Conclusion

In this blog, we learnt about Enterprise Integration Patterns and we also saw different types of EIP techniques.

Stay tuned for more tech blogs: https://blog.knoldus.com/