0

I have a question about "How to set CAMEL rest services 's timeout" Not the httpclient's timeout setting. Ex:

rest("/say")
  .get("/hello").to("direct:hello")

from("direct:hello")
**//start action**
   .setHeader(Exchange.HTTP_METHOD, constant("GET"))
   .process(new Processor() {      
           public void process(Exchange exchange) throws Exception {
            ...   
            exchange.getOut().setBody(answer);     
        }
    });
  .some check function
  .toD("http4://xxxxxx")
  .transform().XXX
  .setHeader(xxxx);
**//end action**

If someone call the GET../say/hello, the time from start action to end action may be take too long. this service will cancel the request itself. (So I need to set the timeout time ,and than to handle the response's massage).

I don't know how to do it or any keyword/component that I can use.

Can someone help me out with this? Thanks

doo
  • 1
  • 1
  • 2
  • You should probably enable some exception handling, see https://camel.apache.org/manual/latest/exception-clause.html – R.Groote Feb 04 '20 at 06:51
  • Hi ,I set onException(xxxException.class) is work, but I don't know how to set the time and trigger the Exception. – doo Feb 05 '20 at 13:13
  • Did you try going through the Saga EIP. This might be a good use case for that to implement within a route, and that has the timeout option. – Camel Dev Feb 06 '20 at 21:30
  • I can't figure out how to do with Saga. I try this [link](https://stackoverflow.com/questions/49308074/apache-camel-timeout-synchronous-route) in process(), but it will block at 'future get' . by the way, I use component(servlet) to start route ,it seems no timeout option. – doo Mar 25 '20 at 01:53

0 Answers0