我想将PayloadTypeRouter
用作Spring Integration DSL的一部分,如下所示:
jmsFlowsUtils.jmsXmlInputFlow(queue, loggingChannel)
.<Object, Class<?>>route(Object::getClass, incomingMsg -> incomingMsg
.subFlowMapping(SomeClass.class.getName(), firstFlow -> firstFlow
.<SomeClass>handle(handler1::handle))
// and so on
.subFlowMapping(AnotherClass.class.getName(), secondFlow -> secondFlow
.<AnotherClass>handle(handler2::handle)))
// and so on
.get();
我将xml消息发送到队列后,SI抱怨
org.springframework.messaging.MessagingException:
Dispatcher failed to deliver Message;
nested exception is org.springframework.messaging.MessagingException:
unsupported return type for router [class java.lang.Class]
知道应用哪种解决方法?
答案 0 :(得分:2)
.<Object, String>route(p -> p.getClass().toString(), incomingMsg -> incomingMsg
或者已经在Spring Integration 4.3.1
中使用Spring Integration Java DSL 1.2。已将Class<?>
作为路由密钥修复为https://jira.spring.io/browse/INT-4057。
因此,您不需要使用.toString()
进行课程。项目测试的样本:
@Bean
public IntegrationFlow payloadTypeRouteFlow() {
return f -> f
.<Object, Class<?>>route(Object::getClass, m -> m
.channelMapping(String.class, "stringsChannel")
.channelMapping(Integer.class, "integersChannel"));
}