Spring integration dsl outboundGateway 使用表达式设置查询参数
Spring integration dsl outboundGateway set query parameter using expression
我在 spring 集成流程中有一个休息请求。如何从 payload 中获取值或从消息中获取 header 并设置 url
的查询参数
.handle(Http.outboundGateway(UriComponentsBuilder.fromHttpUrl("localhost:8080).path("search").queryParam("order", "orderId").toUriString())
.httpMethod(HttpMethod.GET)
.expectedResponseType(Order.class))
在上面的代码中,我需要从 payload 中获取 orderId
如果你坚持要用UriComponentsBuilder
,那么可以这样:
.handle(Http.outboundGateway(m ->
UriComponentsBuilder.fromHttpUrl("localhost:8080")
.path("search")
.queryParam("order", m.getPayload())
.build())
.httpMethod(HttpMethod.GET)
.expectedResponseType(Order.class))
或者像这样:
.handle(Http.outboundGateway(m -> servieUrl + "/search?orderId={orderId}")
.uriVariable("orderId", m -> m.getPayload())
.httpMethod(HttpMethod.GET)
.expectedResponseType(Order.class))
我在 spring 集成流程中有一个休息请求。如何从 payload 中获取值或从消息中获取 header 并设置 url
的查询参数.handle(Http.outboundGateway(UriComponentsBuilder.fromHttpUrl("localhost:8080).path("search").queryParam("order", "orderId").toUriString())
.httpMethod(HttpMethod.GET)
.expectedResponseType(Order.class))
在上面的代码中,我需要从 payload 中获取 orderId
如果你坚持要用UriComponentsBuilder
,那么可以这样:
.handle(Http.outboundGateway(m ->
UriComponentsBuilder.fromHttpUrl("localhost:8080")
.path("search")
.queryParam("order", m.getPayload())
.build())
.httpMethod(HttpMethod.GET)
.expectedResponseType(Order.class))
或者像这样:
.handle(Http.outboundGateway(m -> servieUrl + "/search?orderId={orderId}")
.uriVariable("orderId", m -> m.getPayload())
.httpMethod(HttpMethod.GET)
.expectedResponseType(Order.class))