如何在MULE CE中编写依赖查询?

时间:2015-06-01 20:35:17

标签: mule esb mule-component

我听说我们不能在一个流中写入两个入站端点,但下面是我的要求,第二个选择查询需要第一个查询有效负载值。当我运行这个例外时。如果有其他方式可以写这个,请告诉我。

<flow name="Some">
<jdbc:inbound-endpoint queryKey="SelectSome"
connector-ref="ProConnector" doc:name="SomeFromPro"

pollingFrequency="10000" queryTimeout="-1">
<jdbc:transaction action="NONE" timeout="10" />
<jdbc:query key="SelectSome"
value="SELECT top 1 * from table1 where IsProcessed = 0" />
<jdbc:query key="SelectSome.ack"
value="update table1 set IsProcessed=1 where ID = #[map-payload:ID] " />
</jdbc:inbound-endpoint>    
<jdbc:inbound-endpoint queryKey="SelectSomeBR"
connector-ref="ProConnector" doc:name="SomeBRFromPro"
pollingFrequency="1000" queryTimeout="-1">
<jdbc:transaction action="NONE" timeout="10" />
<jdbc:query key="SelectSomeBR"
    value="SELECT * from table2 where IsProcessed = 0 and ParentID = #[map-payload:ID]" />
<jdbc:query key="SelectSomeBR.ack"
value="update table2 set IsProcessed=1 where ParentID = #[map-payload:ID] " />
</jdbc:inbound-endpoint>
.
.
.
.
</flow>

任何帮助将不胜感激。 谢谢。

1 个答案:

答案 0 :(得分:0)

您需要为第二个查询使用出站选择查询,例如:

<jdbc:outbound-endpoint queryKey="SelectSomeBR"
  connector-ref="ProConnector" doc:name="SomeBRFromPro"
  pollingFrequency="1000" queryTimeout="-1"
  exchange-pattern="request-response">
  <jdbc:transaction action="NONE" timeout="10" />
  <jdbc:query key="SelectSomeBR"
    value="SELECT * from table2 where IsProcessed = 0 and ParentID = #[map-payload:ID]" />
  <jdbc:query key="SelectSomeBR.ack"
value="update table2 set IsProcessed=1 where ParentID = #[map-payload:ID] " />
</jdbc:outbound-endpoint>

参考:https://developer.mulesoft.com/docs/display/current/JDBC+Transport+Reference#JDBCTransportReference-OutboundSELECTQueries

PS。这个旧的表达式语法已过时:#[map-payload:ID]使用MEL代替:#[message.payload.ID]"(假设消息有效负载是一个名为ID的密钥的映射。)

相关问题