【发布时间】:2017-02-02 10:14:30
【问题描述】:
我正在尝试将 Spring Integration 流程从 XML 重写为 Java。我想路由通过通道发送的数据:
@Bean(name = "sendData")
public MessageChannel getSendData() {
return MessageChannels.direct()
.get();
}
进入另外两个渠道:
@Bean(name = "sendDataA")
public MessageChannel getSendDataA() {
return MessageChannels.direct()
.get();
}
@Bean(name = "sendDataB")
public MessageChannel getSendDataB() {
return MessageChannels.direct()
.get();
}
取决于他们的可用性。
我有一个RoundRobinRouter 类来确定使用哪个输出通道。它有一个方法route,返回输出通道名称,如:
@Component
class RoundRobinRouter {
public String route(Object payload) {
/* implementation */
}
}
请注意,route 方法实现实际上并不使用payload 对象。它以前放在 XML 配置中:
<int:router method="route" input-channel="sendData"
default-output-channel="sendDataA">
<bean
class="com.example.RoundRobinRouter"/>
</int:router>
我已经尝试过使用 Java DSL IntegrationFlow:
@Bean
@ServiceActivator(inputChannel = "sendData",
outputChannel = "sendDataA")
public IntegrationFlow routeRoundRobin() {
return router -> router.route(roundRobinRouter, "route");
}
但我在sendData.send(payload) 调用时收到错误“调度程序没有订阅者”,显然是由以下原因引起的:
org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 8):方法调用:方法配置(com.example.DataType) 在 com.example.Integration$$Lambda$1/1018103616 类型上找不到
路由器是我的集成类中唯一的 lambda。
【问题讨论】:
标签: java spring spring-integration spelevaluationexception