小编Sta*_*Dev的帖子

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.
Run Code Online (Sandbox Code Playgroud)

我的理论是,由于适配器是单向组件,因此在流程的处理步骤中不会生成输出。这就是导致运行时错误的原因。但是,不知道如何定义这个简单的流程。

代码:

@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();
}
Run Code Online (Sandbox Code Playgroud)

并且,堆栈跟踪显示:

Caused by: org.springframework.beans.factory.BeanCreationException: The 'currentComponent' (MessageReceiver$$Lambda$1/1495414981@76c52298) is a one-way 'MessageHandler' and it isn't appropriate to configure 'outputChannel'. This is …
Run Code Online (Sandbox Code Playgroud)

java spring spring-integration

2
推荐指数
1
解决办法
1006
查看次数

标签 统计

java ×1

spring ×1

spring-integration ×1