Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通过.handle()为service activator配置输出通道_Java_Spring_Spring Integration_Spring Integration Dsl - Fatal编程技术网

Java 通过.handle()为service activator配置输出通道

Java 通过.handle()为service activator配置输出通道,java,spring,spring-integration,spring-integration-dsl,Java,Spring,Spring Integration,Spring Integration Dsl,已编辑 我是Spring集成的新手,我正在尝试将数据从服务激活器(通过handle方法)传递到通道 @Bean public IntegrationFlow processFileFlow() { return IntegrationFlows .from("fileInputChannel") .transform(fileToStringTransformer()) .handle("fileProcessor"

已编辑 我是Spring集成的新手,我正在尝试将数据从服务激活器(通过handle方法)传递到通道

@Bean
public IntegrationFlow processFileFlow() {
    return IntegrationFlows
            .from("fileInputChannel")
            .transform(fileToStringTransformer())
            .handle("fileProcessor", "process")
            .channel("xmlChannel")
            .get();
}

@Bean
public DirectChannel fileInputChannel(){
    return new DirectChannel();
}

@Bean
public DirectChannel xmlChannel(){
    return new DirectChannel();
}

@Bean
public FileProcessor fileProcessor() {
    return new FileProcessor();
}

@Bean
public IntegrationFlow enrichDataFlow() {
    return IntegrationFlows
            .from("xmlChannel")
            .handle("enricher", "enrichProduct")
            .channel("bvChannel")
            .get();
}

@Bean
public Enricher enricher() {
    return new Enricher();
}
这是FileProcessor类

public class FileProcessor {

    @ServiceActivator(outputChannel = "xmlChannel")
    public String process(Message<String> msg) {
        String content = msg.getPayload();
        return content;
    }
}
公共类文件处理器{
@ServiceActivator(outputChannel=“xmlChannel”)
公共字符串进程(消息消息消息){
字符串内容=msg.getPayload();
返回内容;
}
}
这是Enricher类: 公共类Enricher{

    public void enrichProduct(Message<String> msg) {
        System.out.println("Enriching product " + msg);
    }
}
public void enrichProduct(消息msg){
System.out.println(“浓缩产品”+msg);
}
}

“丰富产品…”的信息没有被打印出来,我也不确定到底出了什么问题。

.channel(“xmlChannel”)
对你有用吗

这绝对是通过消息通道从一个端点到另一个端点组合集成流的正确方法


我想说的是,
@ServiceActivator
中的
outputChannel=“xmlChannel”
不起作用,因为没有
inputChannel
。更多关于
.handle()
的内容将忽略所有这些属性,直接处理
fileProcessor.process()
方法

为此,我推断.channel(“xmlChannel”)不起作用,因为在同一个文件中定义了另一个集成流。我将相应地编辑问题中的详细信息。是否仍调用了
fileoraccessor
?您可以打开
org.springframework.integration
类别的调试日志记录,以查看消息如何在流中传播