Re: Camel Timeout on a route

2012-10-29 Thread ravi.4indra
I am still having that problem.I had removed responseContext,RequestContext
from the inMessage and added a requestContext with a new ClientPolicy .Do i
to remove any other headers?

below is the code snippet 

exchange.getIn().removeHeader(Client.RESPONSE_CONTEXT);
exchange.getIn().removeHeader(Client.REQUEST_CONTEXT);
 MapString, Object requestContext = new HashMapString, Object();
 HTTPClientPolicy clientPolicy = new HTTPClientPolicy();
 clientPolicy.setReceiveTimeout(1);
 requestContext.put(HTTPClientPolicy.class.getName(), clientPolicy);
exchange.getIn().setHeader(Client.REQUEST_CONTEXT , requestContext);

Thanks
Ravi



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Timeout-on-a-route-tp5721576p5721692.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel Timeout on a route

2012-10-29 Thread Willem jiang
I just wrote a test and verified I can set the timeout value on the second cxf 
endpoint without any trouble.
What's the error did you get?

BTW, you should get the socket read time out as you set the receive time out to 
1 mill second. 

-- 
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
  http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang





On Monday, October 29, 2012 at 2:16 PM, ravi.4indra wrote:

 I am still having that problem.I had removed responseContext,RequestContext
 from the inMessage and added a requestContext with a new ClientPolicy .Do i
 to remove any other headers?
 
 below is the code snippet 
 
 exchange.getIn().removeHeader(Client.RESPONSE_CONTEXT);
 exchange.getIn().removeHeader(Client.REQUEST_CONTEXT);
 MapString, Object requestContext = new HashMapString, Object();
 HTTPClientPolicy clientPolicy = new HTTPClientPolicy();
 clientPolicy.setReceiveTimeout(1);
 requestContext.put(HTTPClientPolicy.class.getName(), clientPolicy);
 exchange.getIn().setHeader(Client.REQUEST_CONTEXT , requestContext);
 
 Thanks
 Ravi
 
 
 
 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Camel-Timeout-on-a-route-tp5721576p5721692.html
 Sent from the Camel - Users mailing list archive at Nabble.com 
 (http://Nabble.com).





Re: Camel Timeout on a route

2012-10-28 Thread ravi.4indra
Hi,

I am using camel-CXF component.I am suspecting that the request context is
being cached somewhere in the cxf/camel code thats the reason new timeout
value is not honored.

can you please provide a solution for this?

Thanks
Ravi



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Timeout-on-a-route-tp5721576p5721678.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel Timeout on a route

2012-10-28 Thread ravi.4indra
Hi Willem,

I was able to set the timeout Dynamically FirstTime. But when i tried change
the client policy somwhere in  my route its not picking up the new value.

is this the expected behaviour?

Tanks
Ravi



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Timeout-on-a-route-tp5721576p5721675.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel Timeout on a route

2012-10-28 Thread Willem jiang
Oh, there is a thing I didn't point out ,  when we set the time out value on 
through the message header, CXF will do a merge with the default configuration 
and take the min one.
So it could be better you setup a big time out  value on the default.

-- 
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
  http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang





On Monday, October 29, 2012 at 5:52 AM, ravi.4indra wrote:

 Hi,
 
 I am using camel-CXF component.I am suspecting that the request context is
 being cached somewhere in the cxf/camel code thats the reason new timeout
 value is not honored.
 
 can you please provide a solution for this?
 
 Thanks
 Ravi
 
 
 
 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Camel-Timeout-on-a-route-tp5721576p5721678.html
 Sent from the Camel - Users mailing list archive at Nabble.com 
 (http://Nabble.com).





Re: Camel Timeout on a route

2012-10-28 Thread Willem jiang
Hi Ravi,

The default connection timeout is 3(ms), default receive timeout is 
6(ms).
You can find more information here[1]
And you can change the default setting like this[2]

[1]http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-The%7B%7Bclient%7D%7Delement
[2]https://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml


-- 
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
  http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang





On Monday, October 29, 2012 at 11:08 AM, ravi.4indra wrote:

 Thanks willem. I think by default timeout is 3 (ms). Can you point me to
 way to set a default timeout on cxf endpoint?
 
 Thanks
 Ravi
 
 
 
 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Camel-Timeout-on-a-route-tp5721576p5721683.html
 Sent from the Camel - Users mailing list archive at Nabble.com 
 (http://Nabble.com).





Re: Camel Timeout on a route

2012-10-28 Thread ravi.4indra
Also i dont have any default configuration. so the first time i set the
timeout it will remain as my default timeout for all the endpoints? 

bean(mapper,changeTimeOut)
to(cxf://webservice1)
bean(mapper,changeTimeOut)
to(cxf://webservice2)

I noticed that webservice2 is using the timeout value set during the first
step. can you explain this behaviour?

Thanks
Ravi



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Timeout-on-a-route-tp5721576p5721684.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel Timeout on a route

2012-10-28 Thread Willem jiang
Hi, 
It dependents on how you setup the  client request context header.
You may need to clean up the header if you don't want to the setting affect the 
next camel-cxf producer.

By default camel-cxf endpoint will copy the message headers from the in message 
to the out message,
 which means the client request header will still effect on the second 
camel-cxf endpoint.

-- 
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
  http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang





On Monday, October 29, 2012 at 11:19 AM, ravi.4indra wrote:

 Also i dont have any default configuration. so the first time i set the
 timeout it will remain as my default timeout for all the endpoints? 
 
 bean(mapper,changeTimeOut)
 to(cxf://webservice1)
 bean(mapper,changeTimeOut)
 to(cxf://webservice2)
 
 I noticed that webservice2 is using the timeout value set during the first
 step. can you explain this behaviour?
 
 Thanks
 Ravi
 
 
 
 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Camel-Timeout-on-a-route-tp5721576p5721684.html
 Sent from the Camel - Users mailing list archive at Nabble.com 
 (http://Nabble.com).





Re: Camel Timeout on a route

2012-10-28 Thread ravi.4indra
Hi Willem,

Thanks for sharing the information. I have two webservices call in a camel
route. I am noticing that the timeout i have set for the first call is being
used for the second web service call. even though i have changed the timeout
in 3 step to less than the default timeout it is always taking the timeout
that is set first step.

1 to(bean:addTimeout)
2 to(cxf:webservice1)
3 to(bean:changeTimeout)
4 to(cxf:webservice2)

to change the timeout for the second web service call I removed the request
context from the header and added back the request context(client Policy)
with new timeout value. 

can you please suggest?

Thanks
Ravi



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Timeout-on-a-route-tp5721576p5721690.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel Timeout on a route

2012-10-27 Thread ravi.4indra
Hi,

Is there a way to set timeout dynamically in camel-cxf component?.

So do the total timeout of 60 seconds, if the first webservice call took 10
seconds then the timeout of second webservice call is 60-10 seconds.

for this i need to set the timeout using exchange header. is it possible to
do? 

Thanks
Ravi



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Timeout-on-a-route-tp5721576p5721640.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel Timeout on a route

2012-10-27 Thread Willem jiang
Hi, 

I just add an unit test to show how to set the HttpClientPolicy dynamically.
You can set the receive timeout through the message header like this[1]

http://svn.apache.org/viewvc?rev=1402926view=rev 

-- 
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
  http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang





On Sunday, October 28, 2012 at 12:18 AM, ravi.4indra wrote:

 Hi,
 
 Is there a way to set timeout dynamically in camel-cxf component?.
 
 So do the total timeout of 60 seconds, if the first webservice call took 10
 seconds then the timeout of second webservice call is 60-10 seconds.
 
 for this i need to set the timeout using exchange header. is it possible to
 do? 
 
 Thanks
 Ravi
 
 
 
 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Camel-Timeout-on-a-route-tp5721576p5721640.html
 Sent from the Camel - Users mailing list archive at Nabble.com 
 (http://Nabble.com).





Re: Camel Timeout on a route

2012-10-26 Thread ravi.4indra
Hi Raul,

can you please provide your inputs on the below piece of code. 

This method the uses the producer template asyncCallback to call the
commonRoute.and i used the future handle to get the response.

  public void getDataUsingProducerTemplate(Exchange exchange) throws
TimeoutException, InterruptedException, ExecutionException {
ProducerTemplate template = camelContext.createProducerTemplate();
FutureExchange future = template.asyncCallback(direct:commonRoute,
exchange, new  SynchronizationImpl());
// Retrieve the reply from the main thread, specifying a timeout
try {
future.get(2, TimeUnit.SECONDS);
}catch (TimeoutException e) {
//exchange.setException(e);
future.cancel(true);
Thread.sleep(1000)
throw e;
}
}

Without the thread sleep my global exception handler (On Exception) is not
able to catch the exception.

Thanks
Ravi




--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Timeout-on-a-route-tp5721576p5721623.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel Timeout on a route

2012-10-25 Thread Raul Kripalani
Many Camel components support specifying timeouts, e.g. JMS, CXF, Jetty,
etc.

What does commonRoute do? Could you post its code so we can help you
further?

Thanks.

Sent from a mobile device
On 26 Oct 2012 01:32, ravi.4indra ravi.4in...@gmail.com wrote:

 Hi,

 Is there a way to specify timeout on a route.

 Example
 from(direct:route1)
 .to(bean:dosomething)
 .to(direct:commonRoute)

 now if the commonRoute takes more than n milliseconds i want to get a
 timeout exception.

 FYI I tried seda component I got the timeout exception after n seconds but
 the commonRoute continued its processing(may be it runs on  different
 thread).


 Any help is appreciated.

 Thanks
 R



 --
 View this message in context:
 http://camel.465427.n5.nabble.com/Camel-Timeout-on-a-route-tp5721576.html
 Sent from the Camel - Users mailing list archive at Nabble.com.