我想使用 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]
知道要应用什么解决方法吗?
最佳答案
.<Object, String>route(p -> p.getClass().toString(), incomingMsg -> incomingMsg
或者使用 Spring Integration Java DSL 1.2 已经与 Spring Integration 4.3.1
。 Class<?>
作为路由键已在 https://jira.spring.io/browse/INT-4057 中修复.
这样你就不需要使用 .toString()
用于类(class)。项目测试样本:
@Bean
public IntegrationFlow payloadTypeRouteFlow() {
return f -> f
.<Object, Class<?>>route(Object::getClass, m -> m
.channelMapping(String.class, "stringsChannel")
.channelMapping(Integer.class, "integersChannel"));
}
关于spring-integration - Spring Integration DSL、PayloadTypeRouter、路由器不支持的返回类型 [class java.lang.Class],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39447100/