Spring Book – Chapter 20 – Spring Integration

RecipientListRouter

The messages received by the RecipientListRouter will be sent to a statically defined list of Message Channels. Listing 22-27 shows the configuration for setting up a recipient list router in the Spring configuration file.

Listing 22-27. Configuring recipient list router

Listing 22-28. Using the Spring Integration namespace to do the configuration for recipient list router

ErrorMessageExceptionTypeRouter

Spring Integration also provides a special type-based router called ErrorMessageExceptionTypeRouter for routing Error Messages. It is a special type of PayloadTypeRouter in which messages with payload of type java.lang.Throwable is routed accordingly. The ErrorMessageExceptionTypeRouter navigates the hierarchy of ‘exception causes’ to find the most specific Throwable type/channel mappings and do the routing accordingly. Listing 22-29 below shows declartion of this router in the Spring configuration file.

Listing 22-29. Declaring ErrorMessageExceptionTypeRouter using Spring Integration namespace

MessagingTemplate

In line with other templates provided by Spring Framework, Spring Integration also provides a template class for doing integration of your application with utmost ease and without developer having to worry about the core Spring Integration API’s. It resides in org.springframework.integration.core package and acts as a central class for invoking message exchange operations across 

s using Spring Integration. It supports one-way send and receive calls as well as request/reply. Listing 22-30 below shows a sample code snippet showing the declaration and usage of MessagingTemplate.

Listing 22-30. Declaration and usage of MessagingTemplate helper class in Spring Integration

As and when required we will noe use this template class to do operations in sections which are explained below in this Chapter.

External Integration

Before covering the various Spring Integration support in the following section, I would like to reiterate two important components that you should get yourself familiarize in all aspects. They are:

  • Messaging Gateway
  • Channel Adapter

Messaging Gateway

Messaging gateways are used to encapsulate access to the messaging system from the rest of your application. I would not like to write my own definition of Messaging Gateway, rather I would like to quote the definition as written in the book “Enterprise Integration Pattern”, by Gregor Hohpe and Bobby Woolf:

The Messaging Gateway encapsulates messaging-specific code (e.g., the code required to send or receive a message) and separates it from the rest of the application code. This way, only the Messaging Gateway code knows about the messaging system; the rest of the application code does not. The Messaging Gateway exposes a business function to the rest of the application so that instead of requiring the application to set properties like Message.MessageReadPropertyFilter.AppSpecific, a Messaging Gateway exposes methods such as GetCreditScore that accept strongly typed parameters just like any other method. A Messaging Gateway is a messaging-specific version of the more general Gateway pattern.

Pictorially messaging gateway can be represented as shown in Figure 22-30 below.

 

Figure 22-30. Function of a Messaging Gateway

Figure 22-30. Function of a Messaging Gateway

Page Visitors: 11707

The following two tabs change content below.
Tomcy John

Tomcy John

Blogger & Author at javacodebook
He is an Enterprise Java Specialist holding a degree in Engineering (B-Tech) with over 10 years of experience in several industries. He's currently working as Principal Architect at Emirates Group IT since 2005. Prior to this he has worked with Oracle Corporation and Ernst & Young. His main specialization is on various web technologies and acts as chief mentor and Architect to facilitate incorporating Spring as Corporate Standard in the organization.
Tomcy John

Latest posts by Tomcy John (see all)

2 thoughts on “Spring Book – Chapter 20 – Spring Integration

  1. Hi,
    Thanks for this blog and information sharing!
    I have one question from Spring Integration. Just thought of checking with you.
    I have SimplewebserviceOutBoundGateway. I need to send a document / attachment to the webservice. How will i achieve that?
    This is my current gateway configuration:

    Please let me know, if you can throw some light in this area.
    Thanks in Advance!

  2. Hi,
    Thank you for your information sharing.
    I have one doubt,could you please suggest me the correct frameworks to address that issue.

    My requirement is I would like to get and process files using spring and camel.

    Thanks,
    Madhu

Leave a Reply

Your email address will not be published. Required fields are marked *