【发布时间】:2025-12-17 06:50:01
【问题描述】:
您好,我正在使用 Spring 集成并将网关注入到 RestController
<int:gateway id="reportsService"
service-interface="me.service.MyReportingGateway"
default-request-channel="reportsRequestChannel" />
<int:channel id="reportsRequestChannel" >
<int:dispatcher task-executor="reportServiceExecutor" /></int:channel>
<task:executor id="reportServiceExecutor" pool-size="5" />
<int:service-activator input-channel="reportsRequestChannel" output-channel="reportRouterChannel">
<bean id="reportServiceExecutor" class="me.service.SpecReporting"/>
</int:service-activator>
<int:channel id="reportRouterChannel" />
<int:router input-channel="reportRouterChannel" method="routeReport" ref="reportRouter"></int:router>
<bean class="me.service.ReportRequestRouter" id="reportRouter">
</bean>
<int:channel id="report01Channel">
<int:queue capacity="10"></int:queue>
</int:channel>
<int:channel id="report02Channel">
<int:queue capacity="10"></int:queue>
</int:channel>
<!-- for the channels -->
<int:poller default="true" fixed-delay="1000" id="poller"></int:poller>
<int:service-activator input-channel="report01Channel"
output-channel="CallbackChannel" ref="filewriter" method="writeFile">
</int:service-activator>
<int:service-activator input-channel="report02Channel"
output-channel="CallbackChannel" ref="filewriter" method="writeFile">
</int:service-activator>
<bean class="me.service.CsvFileWriter" id="filewriter"></bean>
<int:channel id="CallbackChannel" />
<int-http:outbound-gateway id="httpOutbound"
request-channel="CallbackChannel"
http-method="GET"
url="http://localhost:8080/services/ping" />
我的 RestController 注入网关:
@Autowired
MyReporting reportsService;
并调用控制器方法内的方法
HttpStatus httpStatus = HttpStatus.OK;
ReportingResponse arr = new ReportingResponse();
AppError ae = new AppError();
ae.setCode("ANP-SM-1000");
ae.setDescription("Everything Criss!!");
arr.setErrors(ae);
logger.debug("Invoking: reportsService.createReport...");
// Async - this will start the report generation process
reportsService.createReport(reportId,rInput);
return new ResponseEntity<ReportingResponse>(arr, httpStatus);
由于我配置了一个带有 void return 的 executor-executor 通道,我如何在这个线程中继续到下一个通道,即 reportRouterChannel?
【问题讨论】:
标签: spring asynchronous spring-integration integration gateway