2

我基本上有两个流程:

  1. HTTP 入站端点接收批处理 XML,拆分为单独的部分并将其暂存到 JMS 队列。
  2. 从 JMS 队列中读取暂存的 XML 并处理消息。

我需要使用 Rest 调用(即)控制上面的流程 2 的执行,流程 2 应该仅在收到 HTTP 入站调用时运行。我正在使用 Mule 版本 3.2.2

以下是流程:

         <flow name="flow-stage-input">
           <http:inbound-endpoint   host="localhost" 
                        port=   "8082" 
                        path=   "test/order"
                        exchange-pattern=   "request-response"
                                    >

           </http:inbound-endpoint>
          <object-to-string-transformer></object-to-string-transformer>
          <splitter evaluator="xpath" expression="//Test/TestNode" enableCorrelation="ALWAYS"/>
          <custom-transformer class="org.testing.transformers.DocumentToString"></custom-transformer>

          <pooled-component>
                <spring-object bean="receiver"></spring-object>
          </pooled-component>

          <!-- DECIDE SUCCESS OR FAILURE --> 
          <choice>
                <when expression="//Test/TestNode" evaluator="xpath">
            <jms:outbound-endpoint queue="stagingQueue" exchange-pattern="one-way" connector-ref="jmsConnector" />
            </when>
            <otherwise>
                <logger message="Skipped staging message due to errors" level="ERROR" /> 
            </otherwise>
          </choice>
          <collection-aggregator></collection-aggregator>
          <custom-transformer class="org.testing.transformers.ListOfStringsToString"></custom-transformer>
          <!-- RESPONSE SENT BACK TO CALLER -->
        </flow>




        <flow name="flow-process-jms-input" > 
           <jms:inbound-endpoint  queue="stagingQueue" exchange-pattern="one-way" connector-ref="jmsConnector" />
           <pooled-component>
            <spring-object bean="processor"></spring-object>
           </pooled-component>
           <!-- DECIDE SUCCESS OR FAILURE  -->
           <choice>
                 <when expression="//ErrorCondition/Path" evaluator="xpath">
                <jms:outbound-endpoint queue="errorQueue" exchange-pattern="one-way" connector-ref="jmsConnector" />
             </when>
             <otherwise>
                <logger message="Message processed successfully" level="ERROR" /> 
             </otherwise>
           </choice>
         </flow>
4

1 回答 1

2

在流程 2 中使用 Groovy 脚本从队列中请求一条 JMS 消息,使用:

muleContext.client.request("jms://stagingQueue", 0)

如果队列为空,这将返回null,否则会返回包含 JMS 消息的 Mule 消息。

于 2012-10-26T20:44:59.653 回答