当我使用httpGet方法时,spring集成dsl groovy http返回null

当我使用httpGet方法时,spring集成dsl groovy http返回null,spring,groovy,spring-integration,Spring,Groovy,Spring Integration,我使用SpringIntegration4.1.4和SpringIntegrationDSLGroovy1.1.0 我在依赖项中包括了spring集成核心和http 当我执行spring集成dsl groovy http示例时,它在控制台中抛出空值。我不确定我错过了什么 这是我的代码看起来像 IntegrationBuilder builder = new IntegrationBuilder("http"); def flow = builder.messageFlow {

我使用SpringIntegration4.1.4和SpringIntegrationDSLGroovy1.1.0

我在依赖项中包括了spring集成核心和http

当我执行spring集成dsl groovy http示例时,它在控制台中抛出空值。我不确定我错过了什么

这是我的代码看起来像

IntegrationBuilder builder = new IntegrationBuilder("http");

def flow = builder.messageFlow {
        transform {"http://www.google.com/finance/info?q=$it"}          
        httpGet(url:{"${it}"},responseType:String)
    }

Object result = flow.sendAndReceive("vmw");

有人能帮我吗?

什么版本的DSL?您需要从构建以与Spring Integration 4.1.x配合使用

我要警告您,groovy DSL几年来很少受到关注;它从未在社区中真正获得任何吸引力


优先考虑以下因素:;它得到了积极的维护和增强。

我刚刚测试了您的案例,没有看到任何
空值,但是出现了另一个类似这样的错误:

Caused by: java.lang.IllegalStateException: 'uriExpression' evaluation must result in a 'String' or 'URI' instance, not: class org.codehaus.groovy.runtime.GStringImpl
所以,这真的是一个错误,你可以随意提出一张罚单,很快就会得到解决

请从另一个角度,让我问你们一个问题:当我们已经有了这些不稳定的、没有维护的东西时,我们为什么要使用这些东西。另一方面,我们可以使用常规Spring Groovy配置支持中的任何Spring集成命名空间,例如:

beans {
    xmlns([si: 'http://www.springframework.org/schema/integration'])

    def headers = environment.getProperty('headers')
    def parser = new JsonSlurper()
    def result = parser.parseText(headers)

    si.channel(id:'input')
    si.channel(id:'output')

    si.'header-enricher'('input-channel':'input','output-channel':'output') {
        result.each {k,v->
            si.'header'(name:k,expression:v)
        }
    }
}

这已固定在主分支上。同时,需要一个简单的解决方法

url:{"http://www.google.com/finance/info?q=$it".toString()}


比兰:是的,你是对的!当我最初运行这个示例时,它抛出了错误“原因:java.lang.IllegalStateException:'uriExpression'…”为了解决这个问题,我在httpGet之前添加了transform,这就是我在控制台中得到null的地方,这不会有帮助。因为问题的根源是
ClosureInvokingMessageProcessor
,它在评估后返回
GString
,但我们无法在最新SI版本的基础上构建
URL
。因此,必须在Groovy DSL项目中提供修复。这就是我邀请你来吉拉的原因。谢谢加里·拉塞尔的意见。
url:{"http://www.google.com/finance/info?q=$it" as String}