Reputation:
Understanding spring integration basics from tutorials and trying to implement a small exam result process. In the below code, the service-activator gets invoked for input-channel="exam"
and the output-channel set on the same service activator is output-channel="result"
but it never gets called as a result the <int:outbound-channel-adapter>
also never gets called.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd">
<bean id="written" class="com.example.nora.service.ExamService"/>
<int:inbound-channel-adapter channel="exam" ref="hallticket" method="check">
<int:poller fixed-delay="1000"/>
</int:inbound-channel-adapter>
<int:channel id="exam"/>
<int:service-activator input-channel="exam" output-channel="result" ref="written" method="write"/>
<int:service-activator input-channel="result" ref="sc" method="testScservice"/>
<int:outbound-channel-adapter channel="result" ref="resultServic" method="test">
</int:outbound-channel-adapter>
<int:channel id="result"/>
<bean id="hallticket" class="com.example.nora.service.Hallticket"/>
<bean id="resultServic" class="com.example.nora.service.ResultService"/>
<bean id="sc" class="com.example.nora.service.ScService"></bean>
</beans>
So, Basically it tries to invoke another service-activator from the output-channel set on one service-activator. Please let me understand this behavior.
Upvotes: 0
Views: 303
Reputation: 121552
First of all your write
method must return something which is going to become a reply message payload to be sent to that result
channel .
Secondly, if you want to have that message to be processed in both next service-activator and outbound-channel-adapter, the result
channel must be a publish-subscribe-channel
instead of direct one as it is by default. In your current case the messages are processed in round-robin manner , so the first message goes to the service-activator, the second to the outbound-channel-adapter and so on flipping on each message appeared in the result
channel.
See docs about those channels nature :
Upvotes: 1