【发布时间】:2019-09-27 12:13:05
【问题描述】:
我目前收到此错误:
DestinationResolutionException:
no output-channel or replyChannel header available .
我有一个注入控制器的文件网关
@MessagingGateway
public interface FileGateway {
@Gateway(requestChannel = "router.input", replyChannel = "output")
FileRequestResponse requestFile(FileRequestRequest fileFetchRequest);
}
以及向各自通道发送消息的路由器
@Bean
IntegrationFlow routeFileRequest() {
return IntegrationFlows.from("router.input")
.<FileRequestRequest, FileType>route(m -> m.getParameters().getFileType(), m -> m
.channelMapping(FileType.CONTRACT, "contract.transform")
.channelMapping(FileType.INVOICE, "invoice.tranform"))
// .channelMapping(FileType.USAGE, "usageChannel"))
.get();
}
这里是我的转换器 bean,将消息转换为字符串并发送到 contract.input channel,我可以在日志中看到消息到达 contract,input channel,但是在处理程序方法中的响应后我得到:
org.springframework.messaging.core.DestinationResolutionException:
no output-channel or replyChannel header available.
变压器:
@Transformer(inputChannel = "contract.transform", outputChannel = "contract.input")
public Message<String> transformContractMessage(Message<FileRequestRequest> request) {
/**
*
* @param request
* @return contractId
*/
FileRequestRequest frr = request.getPayload();
return MessageBuilder.
withPayload(request.
getPayload().getContractId()).
setHeader("fileType", "CONTRACT").build();
}
下面是将消息发送回 router.output 的服务激活器,但是我在上面遇到了那个异常。
@ServiceActivator(inputChannel = "contract.input" ,outputChannel = "output")
public FileRequestResponse res(Message<String> message){
log.info(" Retrieving File With Contract ID {} ",message.getPayload());
ContractRsp contractResponse = contractFetchService.retrieveContract(message.getPayload());
log.info(" Contract File Received {} ",contractResponse);
return FileRequestResponse.builder().build();
}
@Bean
public DirectChannel output(){
DirectChannel channel = new DirectChannel();
return channel;
}
我的目的是在响应后将消息返回到 FileGateway 界面。
【问题讨论】:
标签: spring-boot spring-integration spring-integration-dsl