use of org.apache.camel.ExchangeTimedOutException in project camel by apache.
the class EtcdKeysProducer method processGet.
private void processGet(EtcdClient client, String path, Exchange exchange) throws Exception {
EtcdKeyGetRequest request = client.get(path);
setRequestTimeout(request, exchange);
setRequestRecursive(request, exchange);
try {
exchange.getIn().setHeader(EtcdConstants.ETCD_NAMESPACE, getNamespace());
exchange.getIn().setBody(request.send().get());
} catch (TimeoutException e) {
throw new ExchangeTimedOutException(exchange, configuration.getTimeout());
}
}
use of org.apache.camel.ExchangeTimedOutException in project camel by apache.
the class EtcdKeysProducer method processDel.
private void processDel(EtcdClient client, String path, boolean dir, Exchange exchange) throws Exception {
EtcdKeyDeleteRequest request = client.delete(path);
setRequestTimeout(request, exchange);
setRequestRecursive(request, exchange);
if (dir) {
request.dir();
}
try {
exchange.getIn().setHeader(EtcdConstants.ETCD_NAMESPACE, getNamespace());
exchange.getIn().setBody(request.send().get());
} catch (TimeoutException e) {
throw new ExchangeTimedOutException(exchange, configuration.getTimeout());
}
}
use of org.apache.camel.ExchangeTimedOutException in project camel by apache.
the class SetHeaderInDoCatchIssueTest method createRegistry.
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry registry = new JndiRegistry(createJndiContext());
registry.bind("A", new Processor() {
public void process(Exchange exchange) throws Exception {
log.info("A headers " + exchange.getIn().getHeaders());
}
});
registry.bind("B", new Processor() {
public void process(Exchange exchange) throws Exception {
log.info("B headers " + exchange.getIn().getHeaders());
if ("ExchangeTimedOutException".equals(exchange.getIn().getBody(String.class))) {
throw new ExchangeTimedOutException(exchange, 1);
} else if ("Exception".equals(exchange.getIn().getBody(String.class))) {
throw new Exception();
}
}
});
registry.bind("C", new Processor() {
public void process(Exchange exchange) throws Exception {
log.info("C headers " + exchange.getIn().getHeaders());
}
});
return registry;
}
use of org.apache.camel.ExchangeTimedOutException in project camel by apache.
the class SetHeaderInDoCatchIssueTest method testExchangeTimedOutException.
public void testExchangeTimedOutException() {
Exchange exchange = template.request("direct:start", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody("ExchangeTimedOutException");
}
});
assertEquals("TimeOut", exchange.getOut().getHeader("Status"));
}
use of org.apache.camel.ExchangeTimedOutException in project camel by apache.
the class VmInOutChainedTimeoutTest method testVmInOutChainedTimeout.
public void testVmInOutChainedTimeout() throws Exception {
StopWatch watch = new StopWatch();
try {
template2.requestBody("vm:a?timeout=1000", "Hello World");
fail("Should have thrown an exception");
} catch (CamelExecutionException e) {
// the chained vm caused the timeout
ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause());
assertEquals(200, cause.getTimeout());
}
long delta = watch.stop();
assertTrue("Should be faster than 1 sec, was: " + delta, delta < 1100);
}
Aggregations