【问题标题】:Mule ESB Until-Successful Not Working ProperlyMule ESB 直到成功无法正常工作
【发布时间】:2014-08-14 06:14:40
【问题描述】:

在过去的几个小时里,我一直在尝试直到成功才能正常工作,但即使遵循此处的模型:“http://blogs.mulesoft.org/meet-until-successful-store-and-forward-for-mule/”也无济于事。使用 until-successful 的主要流程是 SEND_TO_POST_SERVICE。我希望直到成功继续运行引用的流,直到最大重试次数。以下是我的流程和相关信息。内部Mule服务器版本为3.4,Mule Studio版本为3.4.0

################## 流动
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json"
      xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
      xmlns:http="http://www.mulesoft.org/schema/mule/http"
      xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
      xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper"
      xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
      xmlns:spring="http://www.springframework.org/schema/beans"
      xmlns:core="http://www.mulesoft.org/schema/mule/core"
      version="EE-3.4.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">

<choice-exception-strategy name="Post_Exception_Strategy">
    <catch-exception-strategy when="exception.causedBy(java.net.SocketTimeoutException) or exception.causedBy(java.net.ConnectException)" doc:name="Catch Exception Strategy">
        <logger message="Network exception occurred" level="INFO" doc:name="Logger"/>
    </catch-exception-strategy>
    <catch-exception-strategy when="exception.causedBy(java.lang.Throwable)" doc:name="Catch Exception Strategy">
        <logger message="General exception occurred" level="INFO" doc:name="Logger"/>
    </catch-exception-strategy>
</choice-exception-strategy>

    <flow name="compositeFlow1"
          doc:name="compositeFlow1">
        <composite-source doc:name="Comp Source">
            <inbound-endpoint doc:name="DTCOM"
                              ref="SUBMISSION_REQUEST_EP"/>
        </composite-source>
        <byte-array-to-string-transformer doc:name="Byte Array to String"/>
        <flow-ref name="POST_TO_SERVICES"
                  doc:name="POST_TO_SERVICES_ref"/>
        <exception-strategy ref="Post_Exception_Strategy"
                            doc:name="Reference Exception Strategy"/>
    </flow>

    <flow name="POST_TO_SERVICES" doc:name="POST_TO_SERVICES" processingStrategy="synchronous">
        <!-- Send to the POST Service -->
        <async>
            <flow-ref name="SEND_TO_POST_SERVICE" doc:name="SEND_TO_POST_SERVICE_ref"/>
        </async>        
        <outbound-endpoint ref="HTTP_EP_1" doc:name="HTTP_EP_1"/>
        <byte-array-to-string-transformer doc:name="Byte Array to String"/>

        <set-variable variableName="statusCode" value="#[message.inboundProperties['http.status']]" doc:name="statusCode"/>
        <json:object-to-json-transformer doc:name="Object to JSON"/>

        <logger message="Data submitted to Endpoint HTTP_STATUS_CODE: #[statusCode]" level="INFO" doc:name="Logger"/>
        <exception-strategy ref="Post_Exception_Strategy" doc:name="Reference Exception Strategy"/>
    </flow>

    <spring:beans>
        <spring:bean id="myListableObjectStore" class="org.mule.util.store.SimpleMemoryObjectStore"/>
    </spring:beans>
    <flow name="SEND_TO_POST_SERVICE" doc:name="Send to POST Service">
        <choice doc:name="Choice">
            <when expression="${send_to_post} == 'true'">
                <until-successful objectStore-ref="myListableObjectStore" maxRetries="3" secondsBetweenRetries="2" doc:name="Until_Success">
                    <flow-ref name="CONNECT_TO_POST_SERVICE" doc:name="CONNECT_TO_POST_SERVICE_ref"/>
                </until-successful>
            </when>
            <otherwise>
                <logger message="NOT Posting to SERVICE" level="DEBUG" doc:name="Send_Logger"/>
            </otherwise>
        </choice>
    </flow>

    <flow name="CONNECT_TO_POST_SERVICE" doc:name="CONNECT_TO_POST_SERVICE">
        <logger message="$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$In Until-Successful for POST" level="INFO" doc:name="USLogger"/>
        <processor-chain doc:name="Processor Chain">
            <logger message="Sending JSON to POST Service" level="INFO" doc:name="JSON_POST_Logger"/>
            <byte-array-to-string-transformer doc:name="Byte Array to String"/>
            <message-properties-transformer doc:name="Message Properties">
                <add-message-property key="Content-Type" value="application/json"/>
            </message-properties-transformer>
            <outbound-endpoint ref="POST_SERVICE_EP" doc:name="POST_SERVICE" exchange-pattern="request-response"></outbound-endpoint>
            <byte-array-to-string-transformer doc:name="Byte Array to String"/>
            <logger message="Status Code response from Sending POST JSON = #[message.inboundProperties['http.status']]" level="INFO" doc:name="StatusCodeLog"/>
            <logger message="Message from POST Service for #[payload]" level="INFO" doc:name="LoggerMessageOutput"/>
        </processor-chain>
    </flow>
</mule>
################## 端点
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
    xmlns:https="http://www.mulesoft.org/schema/mule/https"
    xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd 
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">

    <http:endpoint name="POST_SERVICE_EP" exchange-pattern="request-response" address="http://127.0.0.1:8900/post/service/"  connector-ref="http_connector" contentType="application/json" doc:name="HTTP"/>
    <http:endpoint name="HTTP_EP_1" method="PUT" contentType="application/json" connector-ref="http_connector_2" address="http://127.0.0.1:8900/put/service/" doc:name="HTTP"/>
</mule>
################## 连接器
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns:https="http://www.mulesoft.org/schema/mule/https"
    xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="EE-3.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd 
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">

    <http:connector name="http_connector" clientSoTimeout="1000000"  serverSoTimeout="1000000" doc:name="http_connector" keepAlive="true">
        <receiver-threading-profile maxThreadsActive="10" doThreading="true" threadWaitTimeout="-1" maxBufferSize="10000" maxThreadsIdle="5" poolExhaustedAction="WAIT"/> 
        <dispatcher-threading-profile maxThreadsActive="10" doThreading="true" threadWaitTimeout="-1" maxBufferSize="10000" maxThreadsIdle="5" poolExhaustedAction="WAIT"/> 
    </http:connector>

    <http:connector name="http_connector_2"  doc:name="http_connector" keepAlive="true">
        <receiver-threading-profile maxThreadsActive="10" doThreading="true" threadWaitTimeout="-1" maxBufferSize="10000" maxThreadsIdle="5" poolExhaustedAction="WAIT"/> 
        <dispatcher-threading-profile maxThreadsActive="10" doThreading="true" threadWaitTimeout="-1" maxBufferSize="10000" maxThreadsIdle="5" poolExhaustedAction="WAIT"/> 
    </http:connector>
</mule>

【问题讨论】:

  • 您当前的配置只有在抛出异常时才会重试。是否从引用的流中抛出异常?
  • @RyanCarter、java.net.ConnectException 和 java.net.SocketTimeoutException 被抛出。

标签: mule esb mule-studio


【解决方案1】:

flow-refing(即CONNECT_TO_POST_SERVICE)的流是私有流而不是子流。

这意味着其中抛出的异常不会传播给调用者。将其更改为sub-flow,它应该可以工作。

PS。还要去掉CONNECT_TO_POST_SERVICE中的processor-chain:完全没用。

【讨论】:

  • 将其更改为子流程解决了我的问题。谢谢!
  • 您可以使用私有流,只要事件是同步的,或者在私有流上处理策略 =“同步”。并且鉴于没有异常策略来捕获您要重试的异常。
猜你喜欢
  • 1970-01-01
  • 2015-08-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-21
  • 1970-01-01
  • 2020-10-12
相关资源
最近更新 更多