Spring DSL 的 Apache Camel bean 参数绑定问题
Apache Camel bean parameter binding issue with Spring DSL
我 运行 遇到了 Apache Camel 和 Spring DSL 的 st运行ge 问题。这是我的 Spring 定义路线的摘录:
<route>
<from uri="direct:process-xml"/>
<setHeader headerName="documentRootOid">
<method bean="foo.bar.util.TranslatorUtil" method="extractDocumentRootOid"/>
</setHeader>
<setHeader headerName="organization">
<method bean="foo.bar.util.OrgServices" method="getOrganizationByOid(*,${header.documentRootOid})"/>
</setHeader>
<setHeader headerName="organizationStyleSheet">
<method bean="foo.bar.util.TranslatorUtil" method="extractStyleSheetAttributeFromOrganization(*,${header.organization})"/>
</setHeader>
<bean beanType="foo.bar.util.Utils" method="transformBodyUsingStyleSheet(*,${header.organizationStyleSheet}"/>
....
</route>
在我发布的最后一行之前一切正常。 extractDocumentRootOid(Exchange exchange)
java方法执行,结果存储到documentRootOidheader.
执行getOrganizationByOid(Exchange exchange, String oid)
java方法,结果存储到组织header.
执行extractStyleSheetAttributeFromOrganization(Exchange exchange, Organization organization)
java方法,结果存储到organizationStyleSheetheader.
一旦进入 transformBodyUsingStyleSheet
方法,事情就会变得很奇怪。这是我的方法声明:
public void transformBodyUsingStyleSheet(Exchange exchange, String styleSheet)
我在方法的第一行放置了一个调试器,styleSheet
值总是显示为交换 body,而不是我试图传递给 [=19= 的值].
如果我通过调试器查看 headers,我会看到我的 organizationStyleSheet header 和我期望的值,所以我在猜测我的 bean 参数绑定有问题吗?以前有其他人 运行 参与过吗?
P.S。我尝试用 ${exchange}
替换 *
但出现了一些错误
org.apache.camel.ExpressionEvaluationException:
Cannot create/evaluate simple expression:
${exchange} to be bound to parameter at index: 0 on method"
这似乎是由于 "transformBodyUsingStyleSheet" 方法中缺少右括号引起的。我修复了它并解决了我的问题。
我 运行 遇到了 Apache Camel 和 Spring DSL 的 st运行ge 问题。这是我的 Spring 定义路线的摘录:
<route>
<from uri="direct:process-xml"/>
<setHeader headerName="documentRootOid">
<method bean="foo.bar.util.TranslatorUtil" method="extractDocumentRootOid"/>
</setHeader>
<setHeader headerName="organization">
<method bean="foo.bar.util.OrgServices" method="getOrganizationByOid(*,${header.documentRootOid})"/>
</setHeader>
<setHeader headerName="organizationStyleSheet">
<method bean="foo.bar.util.TranslatorUtil" method="extractStyleSheetAttributeFromOrganization(*,${header.organization})"/>
</setHeader>
<bean beanType="foo.bar.util.Utils" method="transformBodyUsingStyleSheet(*,${header.organizationStyleSheet}"/>
....
</route>
在我发布的最后一行之前一切正常。 extractDocumentRootOid(Exchange exchange)
java方法执行,结果存储到documentRootOidheader.
执行getOrganizationByOid(Exchange exchange, String oid)
java方法,结果存储到组织header.
执行extractStyleSheetAttributeFromOrganization(Exchange exchange, Organization organization)
java方法,结果存储到organizationStyleSheetheader.
一旦进入 transformBodyUsingStyleSheet
方法,事情就会变得很奇怪。这是我的方法声明:
public void transformBodyUsingStyleSheet(Exchange exchange, String styleSheet)
我在方法的第一行放置了一个调试器,styleSheet
值总是显示为交换 body,而不是我试图传递给 [=19= 的值].
如果我通过调试器查看 headers,我会看到我的 organizationStyleSheet header 和我期望的值,所以我在猜测我的 bean 参数绑定有问题吗?以前有其他人 运行 参与过吗?
P.S。我尝试用 ${exchange}
替换 *
但出现了一些错误
org.apache.camel.ExpressionEvaluationException:
Cannot create/evaluate simple expression:
${exchange} to be bound to parameter at index: 0 on method"
这似乎是由于 "transformBodyUsingStyleSheet" 方法中缺少右括号引起的。我修复了它并解决了我的问题。