<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    paulwong

    SPRING INTEGRATION - ENRICH

    enrich時可以發起一個子流程,取得結果后再設置回當前的對象中。

    package org.springframework.integration.stackoverflow.enricher;

    import java.util.List;
    import java.util.Map;
    import java.util.function.Function;
    import java.util.stream.Collectors;

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.context.annotation.Bean;
    import org.springframework.http.HttpMethod;
    import org.springframework.integration.dsl.IntegrationFlow;
    import org.springframework.integration.dsl.IntegrationFlows;
    import org.springframework.integration.dsl.Transformers;
    import org.springframework.integration.http.dsl.Http;
    import org.springframework.web.client.RestTemplate;

    @SpringBootApplication
    public class SpringIntegrationEnricherApplication {

        public static void main(String[] args) {
            SpringApplication.run(SpringIntegrationEnricherApplication.class, args);
        }

        @Bean
        public IntegrationFlow jsonEnricherFlow(RestTemplate restTemplate) {
            return IntegrationFlows.from(Function.class)
                    .transform(Transformers.fromJson(Map.class))
                    .enrich((enricher) -> enricher
                            .<Map<String, ?>>requestPayload((message) ->
                                    ((List<?>) message.getPayload().get("attributeIds"))
                                            .stream()
                                            .map(Object::toString)
                                            .collect(Collectors.joining(",")))
                            .requestSubFlow((subFlow) ->
                                    subFlow.handle(
                                            Http.outboundGateway("/attributes?id={ids}", restTemplate)
                                                    .httpMethod(HttpMethod.GET)
                                                    .expectedResponseType(Map.class)
                                                    .uriVariable("ids", "payload")))
                            .propertyExpression("attributes", "payload.attributes"))
                    .<Map<String, ?>, Map<String, ?>>transform(
                            (payload) -> {
                                payload.remove("attributeIds");
                                return payload;
                            })
                    .transform(Transformers.toJson())
                    .get();
        }

    }

    https://stackoverflow.com/questions/58205432/spring-integration-enrich-transform-message-using-rest-call

    https://www.tabnine.com/web/assistant/code/rs/5c781b6ae70f87000197ab9f#L312

    posted on 2021-09-21 13:40 paulwong 閱讀(268) 評論(0)  編輯  收藏 所屬分類: SPRINGSPRING INTERGRATIONSPRING BOOT

    主站蜘蛛池模板: 亚洲人6666成人观看| 亚洲一区影音先锋色资源| 成人免费在线看片| 57PAO成人国产永久免费视频| 中文字幕日韩亚洲| 亚洲AV永久无码精品| 亚洲免费视频网址| 亚洲三级在线免费观看| 男人的天堂亚洲一区二区三区 | 日韩视频免费在线| 亚洲精品成人在线| 亚洲天堂久久精品| 美女露100%胸无遮挡免费观看 | 亚洲av永久无码精品网站| 成全动漫视频在线观看免费高清版下载| 永久免费A∨片在线观看| 亚洲色成人中文字幕网站| 亚洲欧洲免费无码| 免费国产污网站在线观看15| 午夜视频在线观看免费完整版| 亚洲伊人久久精品影院| 一级毛片成人免费看免费不卡| 国产一级一片免费播放| 亚洲网红精品大秀在线观看| 亚洲αv在线精品糸列| 99re6在线精品视频免费播放| 亚洲人成电影网站| 国产免费小视频在线观看| 亚洲一区二区三区免费| 日本一道综合久久aⅴ免费| 永久免费无码日韩视频| 麻豆国产入口在线观看免费| 亚洲精品福利网站| 最好免费观看韩国+日本| 一级毛片免费播放试看60分钟| 毛片免费视频观看| 中国亚洲女人69内射少妇| 成年网站免费入口在线观看 | 黄桃AV无码免费一区二区三区| 日韩特黄特色大片免费视频| av午夜福利一片免费看久久|