Spring Book – Chapter 20 – Spring Integration

Service Activator

It is an endpoint which calls the service method and then wraps the result of execution in a response message. It is basically an outbound gateway for invoking the bean method.

In EAI, service activator can be pictorially represented as shown in Figure 22-18 below.

Figure 22-18. Service Activator

Figure 22-18. Service Activator

The actual working of service activator endpoint can be pictorially represented as shown in Figure 22-19 below.

Figure 22-19. Working of service activator endpoint

Figure 22-19. Working of service activator endpoint

In our sample application, for dealing with booking we have another class namely BookingProcessor as shown in Listing 22-11 below.

Listing 22-11. BookingProcessor class

The service activator is defined in Spring configuration file namely applicationContext.xml as shown in Listing 22-12 below.

Listing 22-12. Service activator declaration in Spring configuration file

Similar to gateway declaration using Java annotations, service activator can also be created using Java annotation @ServiceActivator. Also “void” and null-returning methods are also supported and in that case no return message required.

Router

In modern day enterprise application this endpoint is the one which cannot be avoided and plays a vital role. The router endpoint consumes messages from the message channel and then according to defined set of conditions routes it through different message channel as the case may be.

In EAI, message router can be pictorially represented as shown in Figure 22-20 below.

Figure 22-20. Router

Figure 22-20. Router

Figure 22-21 below shows a typical routing use case in which the message is routed according to its content.

Figure 22-21. A typical use of router message endpoint

Figure 22-21. A typical use of router message endpoint

Routers can determine target channel based on the following:

  • Payload Type
  • Property Value
  • Header Attribute

Spring Integration provides out-of-the-box following router implementations (We will be covering these in following sections of this chapter):

  • org.springframework.integration.router.PayloadTypeRouter
  • org.springframework.integration.router.HeaderValueRouter
  • org.springframework.integration.router.RecepientListRouter
  • org.springframework.integration.router.ErrorMessageExceptionTypeRouter

Note: Routers according to whether it is within or outside the chain behaves differently and also have differences in configurations.

Page Visitors: 13313

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 *