我有弹簧配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int-stream="http://www.springframework.org/schema/integration/stream"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd">
<!-- message producer / a Spring Integration wrapped Java Standard input
stream -->
<int-stream:stdin-channel-adapter id="producer"
channel="messageChannel" />
<!-- a pair of message consumers / a pair of Spring Integration wrapped
Java Standard output streams -->
<int-stream:stdout-channel-adapter
id="consumer1" channel="messageChannel" append-newline="true" />
<int-stream:stdout-channel-adapter
id="consumer2" channel="messageChannel" append-newline="true" />
<int-stream:stdout-channel-adapter
id="consumer3" channel="messageChannel" append-newline="true" />
<int:poller id="defaultPoller" default="true"
max-messages-per-poll="5" fixed-rate="200" />
<!-- a pub/sub message channel -->
<!-- <int:publish-subscribe-channel id="messageChannel" /> -->
<!-- a direct channel without the queue, a pollable channel with the queue -->
<int:channel id="messageChannel">
<!-- <int:queue capacity="2" /> -->
</int:channel>
</beans>
使用java源代码:
public class Startup {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/si-components.xml");
while (true) {
}
}
}
但是,当我运行上面的代码并从stdin提供输入时,我只在stdout中得到一个响应。我究竟做错了什么。源代码来自:
https://www.intertech.com/Blog/spring-integration-part-1-understanding-channels/
由于
答案 0 :(得分:0)
我的错误。
以下内容被注释掉:
<!-- a pub/sub message channel -->
<!-- <int:publish-subscribe-channel id="messageChannel" /> -->