我的 Spring 集成流程有些问题
some problem with my Spring Integration flow
我正在使用 spring boot 2.3.0 版本和 Spring Integration 5.3.0,但不知何故我无法启动以下代码 working.The 应用程序,没有错误,但是当控制进入 nextChannelFlow()
方法时,没有任何事情发生或打印。有人可以告诉我我错过了什么吗?任何帮助表示赞赏。谢谢
@Configuration
@EnableIntegration
@EnableRetry
Class MyIntegrationFlow
.
.
@Bean
public IntegrationFlow upstreamFlow(){
return IntegrationFlows.from(someChannel())
.handle(srcDirectory(), "receive")
.filter(onlyCsvfiles())
.handle(targetDirectory())// returns a FileWritingMessageHandler
.channel(nextChannel()) //this is downstream
.get();
}
@Bean
public MessageHandler targetDirectory() throws IOException {
FileWritingMessageHandler handler = new FileWritingMessageHandler(targetFolder.getFile());
handler.setExpectReply(false);
return handler;
}
@Bean
public DirectChannel nextChannel(){
return new DirectChannel();
}
@Bean
public IntegrationFlow nextChannelFlow() {
//the below is that last line that gets printed in console. After this line, nothing gets printed and I see no errors too.
System.out.println("inside nextChannel method ");
return IntegrationFlows.from (nextChannel())
.handle((GenericHandler<String>) (payload, headers) -> {
System.out.println("inside handle 1");
callSomeMethod();
System.out.println("inside handle 2");
return payload;
})
.log(Level.INFO, new LiteralExpression("came out of handle.")) //was trying to see if I can see any logs/errors at this line , but nothing displayed.
.channel(checkXFBFlowChannel())//control doesn't go to this channel as well.
.get();
}
@Retryable(value={IllegalStateException.class}, maxAttempts=5,backoff=@Backoff(delay=3000))
public void callSomeMethod() {
System.out.println("simulate sample retry method");
throw new IllegalStateException() ;
}
.handle(returns MessageHandler)
如果它是一个普通的MessageHandler
,那么它之后确实不会发生任何事情。它 returns 什么都没有(无效),因此之后没有回复继续进行。
考虑改用 handle(GenericHandler)
。
我正在使用 spring boot 2.3.0 版本和 Spring Integration 5.3.0,但不知何故我无法启动以下代码 working.The 应用程序,没有错误,但是当控制进入 nextChannelFlow()
方法时,没有任何事情发生或打印。有人可以告诉我我错过了什么吗?任何帮助表示赞赏。谢谢
@Configuration
@EnableIntegration
@EnableRetry
Class MyIntegrationFlow
.
.
@Bean
public IntegrationFlow upstreamFlow(){
return IntegrationFlows.from(someChannel())
.handle(srcDirectory(), "receive")
.filter(onlyCsvfiles())
.handle(targetDirectory())// returns a FileWritingMessageHandler
.channel(nextChannel()) //this is downstream
.get();
}
@Bean
public MessageHandler targetDirectory() throws IOException {
FileWritingMessageHandler handler = new FileWritingMessageHandler(targetFolder.getFile());
handler.setExpectReply(false);
return handler;
}
@Bean
public DirectChannel nextChannel(){
return new DirectChannel();
}
@Bean
public IntegrationFlow nextChannelFlow() {
//the below is that last line that gets printed in console. After this line, nothing gets printed and I see no errors too.
System.out.println("inside nextChannel method ");
return IntegrationFlows.from (nextChannel())
.handle((GenericHandler<String>) (payload, headers) -> {
System.out.println("inside handle 1");
callSomeMethod();
System.out.println("inside handle 2");
return payload;
})
.log(Level.INFO, new LiteralExpression("came out of handle.")) //was trying to see if I can see any logs/errors at this line , but nothing displayed.
.channel(checkXFBFlowChannel())//control doesn't go to this channel as well.
.get();
}
@Retryable(value={IllegalStateException.class}, maxAttempts=5,backoff=@Backoff(delay=3000))
public void callSomeMethod() {
System.out.println("simulate sample retry method");
throw new IllegalStateException() ;
}
.handle(returns MessageHandler)
如果它是一个普通的MessageHandler
,那么它之后确实不会发生任何事情。它 returns 什么都没有(无效),因此之后没有回复继续进行。
考虑改用 handle(GenericHandler)
。