Oce*_*lot 4 java dsl spring http spring-integration
我在流程中进行了ReST API调用:
<int:channel id="requestChannel"/>
<int-http:outbound-gateway request-channel="requestChannel"
                           reply-channel="logger"
                           url="${api.base.uri}/data"
                           http-method="PUT"
                           expected-response-type="java.lang.String"/>
<int:logging-channel-adapter id="logger"
                             logger-name="logger"
                             expression="payload"
                             level="INFO"/>
我正在尝试使用Java DSL复制此文件,但找不到足够的文档。任何帮助将非常感激。
正确,Spring Integration Java DSL尚未提供HTTP的命名空间工厂。
无论如何,我们可以继续使用其通用组件来做到这一点:
    @Bean
    public MessageHandler logger() {
        LoggingHandler loggingHandler = new LoggingHandler("INFO");
        loggingHandler.setLoggerName("logger");
        // This is redundant because the default expression is exactly "payload"
        // loggingHandler.setExpression("payload");
        return loggingHandler;
    }
    @Bean
    public MessageHandler httpGateway(@Value("${api.base.uri}/data") URI uri) {
        HttpRequestExecutingMessageHandler httpHandler = new HttpRequestExecutingMessageHandler(uri);
        httpHandler.setExpectedResponseType(String.class);
        httpHandler.setHttpMethod(HttpMethod.PUT);
        return httpHandler;
    }
    @Bean
    public IntegrationFlow httpFlow(MessageHandler httpGateway) {
        return IntegrationFlows.from("requestChannel")
                .handle(httpGateway)
                .handle(logger())
                .get();
    }
从另一面看,上述文档演示了适用于HttpRequestHandlingMessagingGateway... 的样本。
更新
顺便说一句:随意提出JIRA票证以向Java DSL添加HTTP支持。
| 归档时间: | 
 | 
| 查看次数: | 3168 次 | 
| 最近记录: |