Matthew
Matthew

Reputation: 453

Mule ESB simple http request with rollback exception strategy

I'm trying to do the following:

  1. Call an api that doesn't exist
  2. Try to redeliver the original request 5 times
  3. Print a message when delivery is exhausted

I have the following flow:

<http:request-config name="HTTP_Request_Configuration" host="localhost" port="80" doc:name="HTTP Request Configuration"/>
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="exceptionTestFlow">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
    <flow-ref name="exceptionTestSubFlow" doc:name="Flow Reference"/>
</flow>
<flow name="exceptionTestSubFlow">
    <http:request config-ref="HTTP_Request_Configuration" path="/hello/" method="GET" doc:name="HTTP"/>
    <rollback-exception-strategy doc:name="Rollback Exception Strategy" maxRedeliveryAttempts="5">
        <logger message="redelivering..." level="INFO" doc:name="Logger"/>
        <on-redelivery-attempts-exceeded>
            <logger message="redelivery exhausted" level="INFO" doc:name="Logger"/>
        </on-redelivery-attempts-exceeded>
    </rollback-exception-strategy>
</flow>

But I get the following output:

ERROR 2015-03-02 14:15:34,820 [[exceptiontest].HTTP_Listener_Configuration.worker.01] org.mule.exception.RollbackMessagingExceptionStrategy:


Message : Response code 404 mapped as failure. Message payload is of type: BufferInputStream

Code : MULE_ERROR--2

Exception stack is: 1. Response code 404 mapped as failure. Message payload is of type: BufferInputStream (org.mule.module.http.internal.request.ResponseValidatorException)

org.mule.module.http.internal.request.SuccessStatusCodeValidator:37 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/module/http/internal/request/ResponseValidatorException.html)

Root Exception stack trace: org.mule.module.http.internal.request.ResponseValidatorException: Response code 404 mapped as failure. Message payload is of type: BufferInputStream at org.mule.module.http.internal.request.SuccessStatusCodeValidator.validate(SuccessStatusCodeValidator.java:37) at org.mule.module.http.internal.request.DefaultHttpRequester.innerProcess(DefaultHttpRequester.java:202) at org.mule.module.http.internal.request.DefaultHttpRequester.process(DefaultHttpRequester.java:166) + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)


INFO 2015-03-02 14:15:34,820 [[exceptiontest].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: redelivering... ERROR 2015-03-02 14:15:34,822 [[exceptiontest].HTTP_Listener_Configuration.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy:


Message : Response code 404 mapped as failure. Message payload is of type: BufferInputStream

Code : MULE_ERROR--2

Exception stack is: 1. Response code 404 mapped as failure. Message payload is of type: BufferInputStream (org.mule.module.http.internal.request.ResponseValidatorException)

org.mule.module.http.internal.request.SuccessStatusCodeValidator:37 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/module/http/internal/request/ResponseValidatorException.html)

Root Exception stack trace: org.mule.module.http.internal.request.ResponseValidatorException: Response code 404 mapped as failure. Message payload is of type: BufferInputStream at org.mule.module.http.internal.request.SuccessStatusCodeValidator.validate(SuccessStatusCodeValidator.java:37) at org.mule.module.http.internal.request.DefaultHttpRequester.innerProcess(DefaultHttpRequester.java:202) at org.mule.module.http.internal.request.DefaultHttpRequester.process(DefaultHttpRequester.java:166) + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)


I'm expecting it to try to redeliver 5 times, but it doesn't seem to work. Am I doing something terribly wrong? Many Thanks.

ps I've tried wrapping the sub flow in a transactional block, but that doesn't work either

Upvotes: 1

Views: 1867

Answers (2)

Mohan
Mohan

Reputation: 520

as HTTP call is a stateless object, defining roll back doesn't seems a good option. Define you required failure condition over until-successful scope and the corresponding retry times seems a good option to achieve your requirement.

for reference UntilSuccessful component to poll http endpoint till condition is met

Upvotes: 1

afelisatti
afelisatti

Reputation: 2835

I would instead use an Until Successful Scope since I believe HTTP does not support redelivery (see the doc for Rollback Exception Strategy).

Upvotes: 2

Related Questions