我有下面给我的微不足道的 Spring IntegrationFlow org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers
。
这似乎与Flow的最后一步有关,这是一个log
步骤。如果我删除该log
步骤或在该步骤之后放置另一个身份转换,Dispatcher has no subscribers
则不会抛出。
我想了解log
最后一步有什么问题。
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
try (ConfigurableApplicationContext ctx = SpringApplication.run(DemoApplication.class, args)) {
final Gateway gateway = ctx.getBean(Gateway.class);
final String rs = gateway.send("hello");
System.out.println(rs);
}
}
@MessagingGateway(defaultRequestChannel = "flow.input")
public interface Gateway {
String send(String msg);
}
@Bean
public IntegrationFlow flow() {
return f -> f
.transform((String p) -> p + ", world")
.log(LoggingHandler.Level.INFO, "kljkh"); // throws Dispatcher has no subscribers
}
}
以下两个选项有效,但为什么不是log
最后一步?
@Bean
public IntegrationFlow flow() {
return f -> f
.transform((String p) -> p + ", world")
.log(LoggingHandler.Level.INFO, "kljkh")
.transform(Function.identity()); // works
}
@Bean
public IntegrationFlow flow() {
return f -> f
.transform((String p) -> p + ", world"); // works
}