Common Endpoints
We have touched upon one of the common endpoints in an earlier
chapter—Service Activators. In this section, we will discuss this in
detail, and other endpoints, too. First, make sure that you have the
integration namespace declared in your
XML file for these endpoints:
... xmlns:int="http://www.springframework.org/schema/integration" xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsd" ...
Service Activator
The Service Activator is a generic endpoint which invokes a method on a bean whenever a message arrives on the channel. If the method has a return value, then the value will be sent to an output channel if the channel is configured.
Configuring the activator using the namespace is relatively
straightforward. Use the service-activator element, setting input-channel and a ref to the bean:
<int:service-activator input-channel="positions-channel" ref="newTradeActivator" method="processNewPosition"> </int:service-activator> <bean id="newTradeActivator" class="com.madhusudhan.jsi.endpoints.common.NewTradeActivator" />
Any message arriving at positions-channel will be passed on to a
NewTradeActivator (which the
attribute ref points to) and the
processNewPosition method is invoked
which is declared using the method attribute. If the bean class has only one method, then you do not have to declare the method attribute—the framework resolves it as the service method and invokes it appropriately. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access