gpt4 book ai didi

java - 如何在 Camel 配置中定义公共(public)路由体?

转载 作者:行者123 更新时间:2023-11-30 08:50:56 24 4
gpt4 key购买 nike

我在 Camel 配置中有两条路线

路线1

    <route>
<from uri="cxf:bean:soapProxy1?dataFormat=PAYLOAD" />
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<setHeader headerName="Contents-type">
<constant>application/octet-stream</constant>
</setHeader>
<setHeader headerName="SOAPAction">
<constant>vc</constant>
</setHeader>
<setHeader headerName="Accept">
<constant>application/xml</constant>
</setHeader>

<to uri="bean:samlWsBean" />

<choice>
<when>
<simple>${in.header.isvalid} contains "true"</simple>
<to uri="cxf:bean:backendService?dataFormat=PAYLOAD"/>
</when>
<otherwise>
<to uri="velocity:file:///path/samlerrorresponse.vm"/>
</otherwise>
</choice>
</route>

路线2

    <route>
<from uri="cxf:bean:soapProxy2?dataFormat=PAYLOAD" />
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<setHeader headerName="Contents-type">
<constant>application/octet-stream</constant>
</setHeader>
<setHeader headerName="SOAPAction">
<constant>vc</constant>
</setHeader>
<setHeader headerName="Accept">
<constant>application/xml</constant>
</setHeader>

<to uri="bean:samlWsBean" />

<choice>
<when>
<simple>${in.header.isvalid} contains "true"</simple>
<to uri="cxf:bean:backendService?dataFormat=PAYLOAD"/>
</when>
<otherwise>
<to uri="velocity:file:///path/samlerrorresponse.vm"/>
</otherwise>
</choice>
</route>

两条线路仅相差一条线。

有这个

<from uri="cxf:bean:soapProxy1?dataFormat=PAYLOAD" />

另一个有这个

<from uri="cxf:bean:soapProxy2?dataFormat=PAYLOAD" />

那么我可以将公共(public)主体放在配置的其他地方并在两条 route 引用吗?

最佳答案

当没有人回答我的问题时,我又开始在线搜索,我找到了这样的解决方案

<camel:route id="myCommonPartOfFlow">
<camel:from uri="direct-vm:common-in"/>
[common part]
</camel:route>

然后你可以像这样调用

<camel:to uri="direct-vm:common-in/>

如需更多帮助,请参阅 thisthis ,希望这可以帮助别人。

关于java - 如何在 Camel 配置中定义公共(public)路由体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30754300/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com