In my Spring Boot application, I have the following inbound-gateway (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();
}
The .id("upperCaseGateway"), I assume, is the part where an "id" is being set to the gateway.
On the other hand, I am trying to implement another HTTP inbound gateway in a slightly different DSL style as follows:
@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();
}
My question: In the 2nd style of creating the http inbound gateway, how do I set an id to the gateway with value as "getPersonsGateway"? I see that in the 1st style, this is possible with a simple .id("upperCaseGateway") call.
Any guidance will be greatly appreciated!
Sincerely, Bharath
The id
is simply a bean name; for composite components (consumers), it is the consumer endpoint bean name and the message handler gets <id>.handler
.
For simple message-drive components such as the http inbound adapter it's simply the bean name. So name your bean appropriately.
Either
@Bean("upperCaseGateway")
public MessagingGatewaySupport httpGetGate() {
or, simply
@Bean
public MessagingGatewaySupport upperCaseGateway() {