Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring集成JavaDSL-如何调用INTHTTP:OutboundGateway?_Java_Spring_Http_Spring Integration_Dsl - Fatal编程技术网

Spring集成JavaDSL-如何调用INTHTTP:OutboundGateway?

Spring集成JavaDSL-如何调用INTHTTP:OutboundGateway?,java,spring,http,spring-integration,dsl,Java,Spring,Http,Spring Integration,Dsl,我在流程中有一个片段,其中进行了ReST API调用: <int:channel id="requestChannel"/> <int-http:outbound-gateway request-channel="requestChannel" reply-channel="logger" url="${api.base.uri}/data"

我在流程中有一个片段,其中进行了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"/>


我试图用JavaDSL复制这个,但找不到足够的文档。任何帮助都将不胜感激。

没错,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
的示例

更新


顺便说一句:您可以随意提出一张向Java DSL添加HTTP支持的罚单。

我不理解您的疑问,是否转换为Java DSL?你是说特定领域的语言吗?@RafaelZeffa-是的,请参考:谢谢。。我不知道这个项目!伙计们,给我几分钟准备一个答案。谢谢你们的回答,效果很好。我将提出一个JIRA问题:)在发布问题之前,我确实尝试过使用HttpRequestExecutingMessageHandler(参考记录在案的HttpRequestHandlingMessagingGateway用法)。。然而,我无法对如何使用它有一个清晰的理解。是否有关于集成组件/通道的各种名称空间解析/基于java的实现的良好文档?这样我就可以和DSL一起使用它们(以防DSL不支持它们)。。。这有点棘手:1)每个模块都有自己的
AbstractIntegrationNamespaceHandler
,例如
HttpNamespaceHandler
。2) 每个名称空间组件(xml标记)都有自己的解析器,例如
HttpOutboundGatewayParser
。3) 每个解析器为应用程序上下文生成一个或多个bean,例如
HttpRequestExecutingMessageHandler
。我认为我们将在下一个版本中做一些在XSD中提到的“艰苦”工作,目标类是特定的XML标记。是的,如果能在XSD中包含这些信息那就太好了。我看到问题已经解决了。有没有一个地方可以让我看到如何在JavaDSL中使用新的?我找不到单元/集成测试或任何文档。这对您有用吗:?顺便说一句,您可以在单独的SO线程中提出任何其他问题!