camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Val <novikov.val...@gmail.com>
Subject Re: HTTP keeps retrying after maximumRedeliveries set
Date Thu, 13 Oct 2016 15:13:02 GMT
For troubleshooting purposes, I split the route into 2, one with just sending HTTP message
and another one doing reading from file + transformations. When I call the HTTP part only,
it does try only once, like you said.

But when I run the whole route from the file: point, if exception happens during last HTTP
call – it will keep retrying 20+ times (maybe it’s infinite loop, I just didn’t wait
longer).

PS. log(“${body}”) doesn’t print HTTP reply body in case of exception, but HTTP request
body. Still didn’t figure out how to print a reply if a call failed.

                    onException(Exception.class)
                            .log("${exception.message}");
                            .log("${body}");

                    from("file:" + instructionsFolder)
                        .to("xslt:xslt/oracleerp-to-payment.xslt")
                        .split(xpath("//Payment"))
                        .marshal().xmljson()
                        .to("direct:sendPayment")
                    ;

                    from("direct:sendPayment")
                        .setHeader(Exchange.HTTP_METHOD, constant("POST"))
                        .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
                        .to("http://localhost:8100/api/v1/myendpoint")
                        .log("${body}")

It keeps repeating this message in log:

2016-10-13 07:58:27.695  WARN 63708 --- [acle-financials] o.a.c.c.file.GenericFileOnCompletion
    : Rollback file strategy: org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@3d0605e8
for file: GenericFile[test.xml]
2016-10-13 07:58:28.210  INFO 63708 --- [acle-financials] net.sf.json.xml.XMLSerializer  
         : Using default type string
2016-10-13 07:58:28.211  INFO 63708 --- [acle-financials] route1                         
         : {"MyJSON: 1212121 "}
2016-10-13 07:58:28.212  INFO 63708 --- [acle-financials] o.a.c.httpclient.HttpMethodDirector
     : I/O exception (java.net.ConnectException) caught when processing request: Connection
refused
2016-10-13 07:58:28.212  INFO 63708 --- [acle-financials] o.a.c.httpclient.HttpMethodDirector
     : Retrying request
2016-10-13 07:58:28.213  INFO 63708 --- [acle-financials] o.a.c.httpclient.HttpMethodDirector
     : I/O exception (java.net.ConnectException) caught when processing request: Connection
refused
2016-10-13 07:58:28.213  INFO 63708 --- [acle-financials] o.a.c.httpclient.HttpMethodDirector
     : Retrying request
2016-10-13 07:58:28.213  INFO 63708 --- [acle-financials] o.a.c.httpclient.HttpMethodDirector
     : I/O exception (java.net.ConnectException) caught when processing request: Connection
refused
2016-10-13 07:58:28.213  INFO 63708 --- [acle-financials] o.a.c.httpclient.HttpMethodDirector
     : Retrying request
2016-10-13 07:58:28.213  INFO 63708 --- [acle-financials] route2                         
         : Connection refused
2016-10-13 07:58:28.214 ERROR 63708 --- [acle-financials] o.a.camel.processor.DefaultErrorHandler
 : Failed delivery for (MessageId: ID-raptor-local-61354-1476370696838-0-31 on ExchangeId:
ID-raptor-local-61354-1476370696838-0-32). Exhausted after delivery attempt: 1 caught: java.net.ConnectException:
Connection refused. Processed by failure processor: FatalFallbackErrorHandler[Channel[Log(route2)[exchangeExceptionMessage]]]


Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                      
                                 Elapsed (ms)
[route1            ] [route1            ] [file://input/oracle-financials                
                               ] [        12]
[route1            ] [marshal1          ] [marshal[org.apache.camel.model.dataformat.XmlJsonDataFormat@1b320d72]
        ] [         2]
[route1            ] [log2              ] [log                                           
                               ] [         0]
[route1            ] [to2               ] [direct:sendPayment                            
                               ] [         2]
[route2            ] [setHeader1        ] [setHeader[CamelHttpMethod]                    
                               ] [         0]
[route2            ] [setHeader2        ] [setHeader[Content-Type]                       
                               ] [         0]
[route2            ] [to3               ] [http://localhost:8100/api/v1/payments         
                               ] [         2]
[                  ] [log1              ] [log                                           
                               ] [         0]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------

java.net.ConnectException: Connection refused
	at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_72]
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_72]
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_72]
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_72]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_72]
	at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_72]
	at java.net.Socket.connect(Socket.java:538) ~[na:1.8.0_72]
	at java.net.Socket.<init>(Socket.java:434) ~[na:1.8.0_72]
	at java.net.Socket.<init>(Socket.java:286) ~[na:1.8.0_72]
	at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
~[commons-httpclient-3.1.jar:na]
	at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
~[commons-httpclient-3.1.jar:na]
	at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707) ~[commons-httpclient-3.1.jar:na]
	at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
~[commons-httpclient-3.1.jar:na]
	at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
~[commons-httpclient-3.1.jar:na]
	at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
~[commons-httpclient-3.1.jar:na]
	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) ~[commons-httpclient-3.1.jar:na]
	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) ~[commons-httpclient-3.1.jar:na]
	at org.apache.camel.component.http.HttpProducer.executeMethod(HttpProducer.java:257) ~[camel-http-2.18.0.jar:2.18.0]
	at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:152) ~[camel-http-2.18.0.jar:2.18.0]
	at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
~[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145) [camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:120) [camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:83) [camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62) [camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145) [camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:120) [camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:83) [camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:681)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:609)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:238) [camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.Splitter.process(Splitter.java:108) [camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:120) [camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:83) [camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:460)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:227)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:191)
[camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:175) [camel-core-2.18.0.jar:2.18.0]
	at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:102) [camel-core-2.18.0.jar:2.18.0]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_72]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_72]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
[na:1.8.0_72]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
[na:1.8.0_72]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_72]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_72]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_72]



On 2016-10-13, 01:59, "xenz" <jmaguire.evo@gmail.com> wrote:

    Hello,
    
    You shouldn't need to set the max retry count to 0 as it is the default.
    If that is the full log I suspect that is one try,  try enabling debug
    logging or checking the Web servers access togs to confirm. The first two
    are info then the error stating it tried once. Exhausted after delivery
    attempt: 1
    
    Can you add log("$(body)") in the onexception definition to print the body?
    I am not sure it will print the response body, I would be surprised if it
    didn't.
    
    - J
    
    On Thu, 13 Oct 2016, 21:25 Val <val@fispan.com> wrote:
    
    > Hello,
    >
    >
    >
    > Could you please advise why automatic retries happen even if I set
    > maximumRedeliveries to 0? Basically I just want to disable retries.
    >
    >
    >
    > And also, how do I print HTTP response body in case it’s an error code?
    > ${exception} only has a short description that HTTP call to my URL failed
    > with error code. Server returns details in HTTP response.
    >
    >
    >
    > onException(Exception.class)
    >
    >     .maximumRedeliveries(0);
    >
    >
    >
    > from("direct:send")
    >
    > .setHeader(Exchange.HTTP_METHOD, constant("POST"))
    >
    > .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
    >
    > .to("http://localhost:8100/")
    >
    > .log("${body}");
    >
    >
    >
    > In 3 different cases (URL is not available, server code 400 or 500) I get
    > numerous retries before it finally stop:
    >
    >
    >
    > 2016-10-12 13:11:57.397  INFO 58522 --- []
    > route2                                   : HTTP operation failed invoking
    > http://localhost:8100/ with statusCode: 400
    >
    > 2016-10-12 13:11:57.397  INFO 58522 --- [] route2
    >                                   :
    > org.apache.camel.http.common.HttpOperationFailedException: HTTP operation
    > failed invoking http://localhost:8100/ with statusCode: 400
    >
    > 2016-10-12 13:11:57.399 ERROR 58522 --- []
    > o.a.camel.processor.DefaultErrorHandler  : Failed delivery for (MessageId:
    > ID-raptor-local-64577-1476303106751-0-11 on ExchangeId:
    > ID-raptor-local-64577-1476303106751-0-12). Exhausted after delivery
    > attempt: 1 caught:
    > org.apache.camel.http.common.HttpOperationFailedException: HTTP operation
    > failed invoking http://localhost:8100/  with statusCode: 400. Processed
    > by failure processor:
    > FatalFallbackErrorHandler[Pipeline[[Channel[Log(route2)[exchangeExceptionMessage]],
    > Channel[Log(route2)[exchangeException]]]]]
    >
    >
    >
    >
    



Mime
View raw message