0
votes

I have spent the past few hours trying to get until-successful to work properly, but to no avail even after following the model here: "http://blogs.mulesoft.org/meet-until-successful-store-and-forward-for-mule/". The main flow that uses until-successful is SEND_TO_POST_SERVICE. I want until-successful to continue running the referenced flow until the max retries. Below are my flows and relevant information. The internal Mule server version is 3.4, and the Mule Studio version is 3.4.0

################## Flow
<?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>
################## Endpoints
<?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>
################## Connectors
<?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>
1
Your current config will only retry if an exception is thrown. Is an exception being thrown from the referenced flow?Ryan Carter
@RyanCarter, java.net.ConnectException and java.net.SocketTimeoutException are being thrown.FearlessFuture

1 Answers

2
votes

The flow you are flow-refing (ie CONNECT_TO_POST_SERVICE) is a private flow not a sub-flow.

This means that exceptions thrown in it will not be propagated to the caller. Change it to a sub-flow and it should work.

PS. Also remove the processor-chain in CONNECT_TO_POST_SERVICE: it's completely useless.