Spring integration 如何为http入站网关(DSL样式)设置ID?
在我的Spring Boot应用程序中,我有以下入站网关(Java DSL):Spring integration 如何为http入站网关(DSL样式)设置ID?,spring-integration,spring-integration-dsl,spring-integration-http,Spring Integration,Spring Integration Dsl,Spring Integration Http,在我的Spring Boot应用程序中,我有以下入站网关(Java DSL): @Bean 公共集成流upperCaseFlow(){ 返回积分流 .来自( Http.inboundGateway(“/conversions/upperCase”) .requestMapping(r->r.methods(HttpMethod.POST).consumes(“text/plain”)) .requestPayloadType(String.class) .id(“大写网关”) ) .handle
@Bean
公共集成流upperCaseFlow(){
返回积分流
.来自(
Http.inboundGateway(“/conversions/upperCase”)
.requestMapping(r->r.methods(HttpMethod.POST).consumes(“text/plain”))
.requestPayloadType(String.class)
.id(“大写网关”)
)
.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();
}
@Bean
公共集成流httpGetFlow(){
返回IntegrationFlows.from(httpGetGate()).channel(“httpGetChannel”).handle(“personedpoint”,“get”).get();
}
@豆子
公共消息网关支持httpGetGate(){
HttpRequestHandlingMessagingGateway处理程序=新建HttpRequestHandlingMessagingGateway();
setRequestMapping(createMapping(新的HttpMethod[]{HttpMethod.GET},“/persons/{personId}”);
setPayloadExpression(parser().parseExpression(“#pathVariables.personId”);
setHeaderMapper(headerMapper());
返回处理程序;
}
@豆子
公共HeaderMapper HeaderMapper(){
返回新的DefaultHttpHeaderMapper();
}
我的问题:
在创建http入站网关的第二种方式中,如何将值设置为“getPersonsGateway”的网关id?
我发现在第1种样式中,通过一个简单的.id(“upperCaseGateway”)调用就可以实现这一点
任何指导都将不胜感激
真诚地,
Bharathid只是一个bean名称;对于复合组件(使用者),它是使用者端点bean名称,消息处理程序获取
.handler
对于简单的消息驱动组件,如http入站适配器,它只是bean名称。因此,恰当地命名您的bean
或者
@Bean("upperCaseGateway")
public MessagingGatewaySupport httpGetGate() {
或者,简单地说
@Bean
public MessagingGatewaySupport upperCaseGateway() {
id
只是一个bean名称;对于复合组件(使用者),它是使用者端点bean名称,消息处理程序获取.handler
对于简单的消息驱动组件,如http入站适配器,它只是bean名称。因此,恰当地命名您的bean
或者
@Bean("upperCaseGateway")
public MessagingGatewaySupport httpGetGate() {
或者,简单地说
@Bean
public MessagingGatewaySupport upperCaseGateway() {
谢谢你的解决方案,加里!谢谢你的解决方案,加里!