首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Spring集成中使用JAVA配置创建http入站通道适配器?

如何在Spring集成中使用JAVA配置创建http入站通道适配器?
EN

Stack Overflow用户
提问于 2021-08-31 21:03:51
回答 1查看 85关注 0票数 1

我有以下http入站通道适配器。如何使用Java Config或Spring DSL进行此配置?

代码语言:javascript
复制
<int-http:inbound-channel-adapter
    channel="api_app_integration_request_channel" 
    supported-methods="PUT" 
    path="/process/ticket"
    request-payload-type="*.model.Ticket"
    header-mapper="headerMapper"
    error-channel="internal-client-rest-ticket-error-channel"
>
<int-http:request-mapping consumes="application/json" />
</int-http:inbound-channel-adapter>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-31 21:31:43

参见Spring Integration Reference Manual:

Java DSL:https://docs.spring.io/spring-integration/docs/current/reference/html/dsl.html#java-dsl

HTTP模块规范:https://docs.spring.io/spring-integration/docs/current/reference/html/http.html#http-java-config

您的特定示例可以转换为此IntegrationFlow

代码语言:javascript
复制
    @Bean
    public IntegrationFlow myHttpFlow() {
        return IntegrationFlows
                .from(Http.inboundChannelAdapter("/process/ticket")
                        .requestMapping(r -> r
                                .methods(HttpMethod.PUT)
                                .consumes("application/json"))
                        .requestPayloadType(model.Ticket.class)
                        .headerMapper(headerMapper))
                .channel("api_app_integration_request_channel")
                ...
                .get();
    }

您可以添加集成端点来构建处理这些请求的逻辑,而不是添加...

在同一个HTTP章节中,您可以找到如何将HttpRequestHandlingMessagingGateway配置为纯@Bean

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69005281

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档