2
我必須在流程定義中丟失一些非常基本的東西。收到此錯誤Spring DSL:將錯誤消息發送到JMS隊列。獲取'單向'MessageHandler'錯誤,並且不適合配置'outputChannel''
is a one-way 'MessageHandler' and it isn't appropriate to configure 'outputChannel'. This is the end of the integration flow.
我的理論是,由於適配器是單向的成分,也沒有在流動的手柄一步生成的輸出。這就是爲什麼這會導致運行時錯誤。但是,不知道如何定義這個簡單的流程。
代碼:
@Autowired
private JmsMessagingTemplate jmsMessagingTemplate;
@Bean
public Queue errorQueue() {
return new ActiveMQQueue(fatalQueue);
}
@Bean
public DirectChannel errorChannel() {
return new DirectChannel();
}
@Bean
public IntegrationFlow handleErrors() {
return IntegrationFlows
.from(errorChannel())
.handle(x -> System.out.println("error handling invoked.x="+x))
.handle(Jms.outboundAdapter(jmsMessagingTemplate.getConnectionFactory()).destination(fatalQueue))
.get();
}
而且,堆棧跟蹤說:
Caused by: org.springframework.beans.factory.BeanCreationException: The 'currentComponent' (MessageReceiver$$Lambda$1/[email protected]) is a one-way 'MessageHandler' and it isn't appropriate to configure 'outputChannel'. This is the end of the integration flow.
at org.springframework.integration.dsl.IntegrationFlowDefinition.registerOutputChannelIfCan(IntegrationFlowDefinition.java:2630) ~[spring-integration-java-dsl-1.1.0.RELEASE.jar:na]
at org.springframework.integration.dsl.IntegrationFlowDefinition.register(IntegrationFlowDefinition.java:2554) ~[spring-integration-java-dsl-1.1.0.RELEASE.jar:na]
at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:1136) ~[spring-integration-java-dsl-1.1.0.RELEASE.jar:na]
at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:1116) ~[spring-integration-java-dsl-1.1.0.RELEASE.jar:na]
at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:863) ~[spring-integration-java-dsl-1.1.0.RELEASE.jar:na]