在mule esb中開發示例bookstare,並使用mysql作爲數據庫。我的數據庫有一個名爲'Stock'的表,其中有2個屬性(isbn和數量),用於我在表單上提供的註冊書籍。我想要的是檢查客戶要求的書籍數量,不要增加我的數據庫上存在的書籍(數量)來完成訂單。在會話變量中保存來自數據庫的值Mule esb
我有流量:
<flow name="Facturacion" doc:name="Facturacion">
<composite-source doc:name="Composite Source">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8086" doc:name="HTTP" path="Facturacion" transformer-refs="HttpToPedido"/>
<file:inbound-endpoint responseTimeout="10000" doc:name="File" moveToDirectory="tmp" path="tmp/pedidos"/>
</composite-source>
<component doc:name="Generar Pedido" class="org.mule.components.GenerarPedido"/>
<set-session-variable variableName="dataTemp" value="#[message.payload.cantidadPedida]" doc:name="Session Variable"/>
<db:select config-ref="MySQL_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[SELECT cantidad FROM stock WHERE isbn = #[payload.isbn]]]></db:parameterized-query>
</db:select>
<collection-splitter doc:name="Collection Splitter"/>
<choice doc:name="Choice">
<when expression="#[sessionVars['dataTemp'] >= payload.cantidadPedida]">
<vm:outbound-endpoint exchange-pattern="one-way" path="procesarPedido" doc:name="Procesar Pedido Disponible"/>
</when>
<otherwise>
<vm:outbound-endpoint exchange-pattern="one-way" path="rechazarStock" doc:name="Rechazar por falta en Stock"/>
</otherwise>
</choice>
<collection-aggregator failOnTimeout="true" doc:name="Collection Aggregator"/>
<set-payload value="#[payload];" doc:name="Set Payload"/>
</flow>
任何解決這個問題?我需要的是根據我的數據庫中的有效負載與我的「庫存表」中的值來比較本書數量的值。
謝謝!
感謝您的響應。但是我需要的是比較muy訂購數量(我從有效載荷中得到的價值)和我的數據庫的「stock」表中的值來接受訂單。 – 2015-02-10 11:50:54