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
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
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
1 2 3 4 5 6 7 8 9 10 11 |
package com.mybook.loyalty.brokers; public interface BookingProcessor { //… public BookingConfirmation processBooking(Booking booking); //… } |
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
1 2 3 |
<service-activator ref=”bookingProcessor” input-channel=”bookingChannel” output-channel=”bookingConfimationChannel”/> <beans:bean id=”bookingProcessor” class=”com.mybook.loyalty.brokers.BookingProcessor”/> |
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-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
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: 13059


Tomcy John


Latest posts by Tomcy John (see all)
- A Guide to Continuous Improvement for Architects - February 2, 2023
- Cloud-first Architecture Strategy - January 26, 2023
- Architecture Strategy and how to create One - January 24, 2023
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!
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