Spring integration Spring集成路线可以';发送消息

Spring integration Spring集成路线可以';发送消息,spring-integration,router,spring-integration-dsl,message-channel,Spring Integration,Router,Spring Integration Dsl,Message Channel,所以,问题在于路由器。 当路由器尝试向通道发送消息时,我收到错误:Dispatcher没有通道“newTypingNotificationHandler.input”的订户。但是我有这个频道名称的集成流防御 @Bean 公共集成流路由ecminomerq(抽象消息路由器类型通知路由器){ 返回IntegrationFlows.from(从_通道) .routeToRecipients(r->r .recipientFlow(p->p输入通知的实例), f->f.路由(类型通知路由器) ) .de

所以,问题在于路由器。 当路由器尝试向通道发送消息时,我收到错误:Dispatcher没有通道“newTypingNotificationHandler.input”的订户。但是我有这个频道名称的集成流防御

@Bean
公共集成流路由ecminomerq(抽象消息路由器类型通知路由器){
返回IntegrationFlows.from(从_通道)
.routeToRecipients(r->r
.recipientFlow(p->p输入通知的实例),
f->f.路由(类型通知路由器)
)
.defaultOutputChannel(默认\u服务\u通道)
).get();
}
@豆子
公共摘要消息路由器类型通知路由器(IncomeRepository IncomeRepository){
返回新的AbstractMessageRouter(){
@凌驾
受保护的集合确定GetChannel(消息){
TypingNotificationDto messagePayload=(TypingNotificationDto)message.getPayload();
如果(!incomeRepository.existsById(StringUtil.ecdfileidtouid(messagePayload.getEcdDocumentImage().getDocumentSource())){
return Collections.singleton(MessageChannels.direct(“newTypingNotificationHandler.input”).get();
}否则{
return Collections.singleton(MessageChannels.direct(“existsTypingNotificationHandler.input”).get();
}
}
};
}
@豆子
公共集成流newTypingNotificationHandler(){
返回f->f.log(“需求创造新收入”);
}
@豆子
公共集成流存在StypingNotificationHandler(){
返回f->f.log(“存在收入流程”);
}
原因:

org.springframework.integration.MessageDispatchingException: Dispatcher目前没有订阅服务器 org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:139) ~[spring-integration-core-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatcher(UnicastingDispatcher.java:106) ~[spring-integration-core-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:73) ~[spring-integration-core-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:461) ~[spring-integration-core-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:403) ~[spring-integration-core-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:187) ~[spring-messaging-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:166) ~[spring-messaging-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:47) ~[spring-messaging-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:109) ~[spring-messaging-5.2.6.RELEASE.jar:5.2.6.RELEASE]at org.springframework.integration.router.AbstractMessageRouter.doSend(AbstractMessageRouter.java:206) ~[spring-integration-core-5.2.6.RELEASE.jar:5.2.6.RELEASE]


您每次都返回一个新频道,而不是Spring管理的频道

MessageChannels.direct("newTypingNotificationHandler.input").get();
使用


相反。但是,最好在解析后进行缓存,而不是为每条消息返回一个新集合。

我不认为这种逻辑有理由实现整个
AbstractMessageRouter
。只要有一个自定义POJO服务,该服务的方法为这些频道名称返回
String
。然后在
路由(objectservice,stringmethodname)
dslapi中使用这个方法。我决定只在一个服务中处理这两种情况,而不发送到单独的通道。
return Collections.singleton(getChannelResolver().resolveDestination("newTypingNotificationHandler.input"));