在我的 Spring Boot 应用程序中,我有以下入站网关(Java DSL):
@Bean
public IntegrationFlow upperCaseFlow() {
return IntegrationFlows
.from(
Http.inboundGateway("/conversions/upperCase")
.requestMapping(r -> r.methods(HttpMethod.POST).consumes("text/plain"))
.requestPayloadType(String.class)
.id("upperCaseGateway")
)
.<String>handle((p, h) -> p.toUpperCase())
.get();
}
我认为.id ("upperCaseGateway")是为网关设置“id”的部分。
另一方面,我正在尝试以稍微不同的 DSL 样式实现另一个 HTTP 入站网关,如下所示:
@Bean
public IntegrationFlow httpGetFlow() {
return IntegrationFlows.from(httpGetGate()).channel("httpGetChannel").handle("personEndpoint", "get").get();
}
@Bean
public MessagingGatewaySupport httpGetGate() {
HttpRequestHandlingMessagingGateway handler = new HttpRequestHandlingMessagingGateway();
handler.setRequestMapping(createMapping(new HttpMethod[]{HttpMethod.GET}, "/persons/{personId}"));
handler.setPayloadExpression(parser().parseExpression("#pathVariables.personId"));
handler.setHeaderMapper(headerMapper());
return handler;
}
@Bean
public HeaderMapper<HttpHeaders> headerMapper() {
return new DefaultHttpHeaderMapper();
}
我的问题: 在创建 http 入站网关的第二种方式中,如何为网关设置一个 ID,值为“ getPersonsGateway ”?我看到在第一种风格中,这可以通过简单的.id("upperCaseGateway")调用来实现。
任何指导将不胜感激!
真诚的,巴拉特