Java Spring集成尚未为端点定义轮询器
嗨,我很难解决我的xml配置 以下是我的spring集成配置xml:Java Spring集成尚未为端点定义轮询器,java,spring,spring-integration,poller,Java,Spring,Spring Integration,Poller,嗨,我很难解决我的xml配置 以下是我的spring集成配置xml: <context:annotation-config /> <context:component-scan base-package="hk.com.test.spring.integration" /> <int:channel id="orders" /> <int:channel id="drinks" /> <int:channe
<context:annotation-config />
<context:component-scan base-package="hk.com.test.spring.integration" />
<int:channel id="orders" />
<int:channel id="drinks" />
<int:channel id="hotDrink">
<int:queue capacity="5" />
</int:channel>
<int:channel id="coldDrink">
<int:queue capacity="10" />
</int:channel>
<bean id="drinkRouter" class="hk.com.test.spring.integration.DrinkRouter" />
<bean id="orderSplitter" class="hk.com.test.spring.integration.OrderSplitter" />
<bean id="barista" class="hk.com.test.spring.integration.Barista" />
<int:gateway id="cafe" service-interface="hk.com.test.spring.integration.Cafe" />
<int:splitter input-channel="orders" ref="orderSplitter"
method="split" output-channel="drinks" />
<int:router input-channel="drinks" ref="drinkRouter" method="resolveItemChannel" />
<int:service-activator input-channel="coldDrink"
ref="barista" method="prepareColdDrink" />
<int:service-activator input-channel="hotDrink"
ref="barista" method="preparehotDrink" />
这是我的主要课程::
public class Main {
public static void main(String args[]) {
System.out.println("Hello");
// load the Spring context
ApplicationContext context = new ClassPathXmlApplicationContext(
"spring-config2.xml");
Cafe cafe = (Cafe) context.getBean("cafe");
for (int i = 1; i <= 100; i++) {
Order order = new Order(i);
order.addItem(DrinkType.LATTE, false);
order.addItem(DrinkType.MOCHA, true);
cafe.placeOrder(order);
}
}
}
公共类主{
公共静态void main(字符串参数[]){
System.out.println(“你好”);
//加载Spring上下文
ApplicationContext上下文=新类路径XmlApplicationContext(
“spring-config2.xml”);
Cafe Cafe=(Cafe)context.getBean(“Cafe”);
对于(int i=1;i您有多个queue
通道。要从它们接收消息,您应该配置
:全局通道,或为订阅这些队列的每个组件配置:
更新:
全球民意调查:
<int:poller default="true" fixed-delay="50"/>
队列通道是拆分器、路由器和服务激活器,对吗
不,频道是频道,它们不处理任何消息,当然是从很大的高度。消息是通过端点
s从频道获取的。在队列
的情况下,应该是轮询消费者
,例外情况正好说明了这一点。因此,您必须:或添加全局轮询器,但在这种情况下,所有端点都将轮询我通过相同规则发送消息,或为每个端点配置
。在您的情况下,它们是将这些队列作为输入通道的组件,用于定义全局默认池器:
@Bean(name = PollerMetadata.DEFAULT_POLLER)
public PollerMetadata defaultPoller() {
PollerMetadata pollerMetadata = new PollerMetadata();
pollerMetadata.setTrigger(new PeriodicTrigger(10));
return pollerMetadata;
}
通过以下步骤解决此问题-
右键单击eclipse中的项目
然后Maven>更新项目
注意:确保您也有xsd和jar
<int-stream:stdin-channel-adapter id="producer" channel="messageChannel" >
<int:poller id="defaultPoller" default="true" fixed-rate="200" />
</int-stream:stdin-channel-adapter>
Hi Artem,感谢您的回复,您能否指导mo如何添加或配置全局轮询器…另一个问题,如果我错了,请纠正我,队列通道是拆分器、路由器和服务激活器,对吗?如果是,每个通道都需要有自己的轮询吗?我明白了,所以所有队列通道都有输入通道。非常感谢Artem爵士。我还有一个问题,它给了我一个错误->cvc复杂类型。3.2.2:属性“fixed delay”不允许出现在元素“int:poller”中。像你这样的疯子在Spring Integration上使用的是非常旧的版本:…谢谢Artem爵士,我现在使用的是2.2.3.RELEASE,哈哈,我改变了我的版本,然后在我让它工作后更新你假设IDE抱怨该属性,或者在运行时类路径中有多个版本。
<int-stream:stdin-channel-adapter id="producer" channel="messageChannel" >
<int:poller id="defaultPoller" default="true" fixed-rate="200" />
</int-stream:stdin-channel-adapter>