Re: How to consume remote rest url and how to write given json response in a text file.

2016-10-13 Thread xenz
Hello.,

Have you looked at
http://camel.apache.org/http4.html and http://camel.apache.org/file2.html

You can use toD for the dynamic bit on the http4 consumer to add your
variables.  I am not exactly what you are looking for but hopefully this is
a good start.

- J

On Thu, 13 Oct 2016, 21:26 Gunjara  wrote:

> Hi someone can help me on this,
>
> How to consume remote rest url and how to write given json response in a
> text file.
>
> i have remote url like this
> http://yourhost.domain/path/to/rest/resource/productid=1234&date=10122016
>
> I need how to add parameters dynamically.
> and i need to consume that if i use poster give url like this
> http://localhost/path/to/rest/resource/productid=1234&date=10122016
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-consume-remote-rest-url-and-how-to-write-given-json-response-in-a-text-file-tp5788712.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: HTTP keeps retrying after maximumRedeliveries set

2016-10-13 Thread xenz
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  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]
>
>
>
>