java - 如何向有效负载表达式添加两个路径变量?

标签 java spring-integration

我有带有路径和一个 pathVariables 的入站 channel 适配器,但现在我想添加第二个变量,但无法找到它在有效负载中的外观。

我找到了这个解决方案,但我不希望我的变量出现在标题中:

<int-http:inbound-gateway id="restCall"
                          request-channel="jobRunner"
                          supported-methods="POST"
                          path="/etl/{jobName}/{currentCustomer}">
    <int-http:header name="jobName" expression="#pathVariables.jobName"/>
    <int-http:header name="currentCustomer"/>
 </int-http:inbound-gateway>

我需要类似的东西:

 <int-http:inbound-gateway id="restCall"
                          request-channel="jobRunner"
                          supported-methods="POST"
                          path="/etl/{jobName}/{currentCustomer}"
                          payload-expression = 
 "#pathVariables.jobName,#pathVariables.currentCustomer">                              
  </int-http:inbound-gateway>

最佳答案

有效负载是单个对象;不可能是两个。

您可以将其中一个变量添加到 <header/>相反,或者创建一些 POJO 并使用

"new com.foo.MyVariableContainer(#pathVariables.jobName, #pathVariables.currentCustomer)"

关于java - 如何向有效负载表达式添加两个路径变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56662443/

相关文章:

exception - Spring Integration-自定义errorChannel-仅记录第一个异常

java - 使用 <int-jpa :outbound-channel-adapter 保留实体列表

spring-integration - Spring 集成 Handle 与 Transform

java - 部署到 openshift WildFly

java - 如何在 JDL 中定义带有字符串值的枚举器?

java - 如何使用 OpenNLP 创建自定义模型?

java - 在 Toast 中使用字符串资源

java - java查看mysql查询结果

java - 针对不同事件的 Spring Integration 自定义轮询器

java - 如何使用 Spring Integration 将 bean 的返回值传递给 XML 属性?最有可能涉及 SpEL