已编辑 我是 Spring 集成的新手,我正在尝试将数据从服务激活器(通过句柄方法)传递到通道。
@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;
}
}
这是 Enricher 类: public class Enricher {
public void enrichProduct(Message<String> msg) {
System.out.println("Enriching product " + msg);
}
}
消息“丰富产品..”没有被打印出来,我不确定出了什么问题。