Spring integration 如何更改代码以使http://uri 动态的还是参数化的?
我有一个用于post消息的spring集成流:Spring integration 如何更改代码以使http://uri 动态的还是参数化的?,spring-integration,Spring Integration,我有一个用于post消息的spring集成流: @Bean public IntegrationFlow httpPost() { return IntegrationFlows .from("requestChannel") .handle(Http.outboundGateway("http://uri") .httpMethod(HttpMethod.POST) .extractPayload(true))
@Bean
public IntegrationFlow httpPost() {
return IntegrationFlows
.from("requestChannel")
.handle(Http.outboundGateway("http://uri")
.httpMethod(HttpMethod.POST)
.extractPayload(true))
.get();
}
如何更改代码以使动态化或参数化
/**
* Create an {@link HttpMessageHandlerSpec} builder for request-reply gateway
* based on provided {@code Function} to evaluate target {@code uri} against request message.
* @param uriFunction the {@code Function} to evaluate {@code uri} at runtime.
* @param <P> the expected payload type.
* @return the HttpMessageHandlerSpec instance
*/
public static <P> HttpMessageHandlerSpec outboundGateway(Function<Message<P>, ?> uriFunction) {
return outboundGateway(new FunctionExpression<>(uriFunction));
}
或者,您可以使用SpEL表达式。Good;看,这会帮助别人。
.handle(Http.outboundGateway(message -> message.getHeaders().get("someHeaderWithURI"))