use of java.io.IOException in project camel by apache.
the class ContextScopedOnExceptionNotHandledRouteScopedErrorHandlerRefIssueTwoRoutesTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
onException(IllegalArgumentException.class).handled(false).to("mock:handled").end();
from("direct:foo").errorHandler(new ErrorHandlerBuilderRef("myDLC")).to("mock:foo").throwException(new IOException("Damn IO"));
from("direct:start").errorHandler(new ErrorHandlerBuilderRef("myDLC")).to("mock:a").throwException(new IllegalArgumentException("Damn"));
}
};
}
use of java.io.IOException in project camel by apache.
the class MultipleErrorHandlerOnExceptionIssueTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
onException(IllegalArgumentException.class).handled(true).to("mock:handled");
from("seda:a").errorHandler(deadLetterChannel("mock:dead.a").maximumRedeliveries(3).redeliveryDelay(0).retryAttemptedLogLevel(LoggingLevel.WARN).asyncDelayedRedelivery()).to("mock:a").throwException(new IllegalArgumentException("Forced A"));
from("seda:b").errorHandler(deadLetterChannel("mock:dead.b").maximumRedeliveries(2).redeliveryDelay(0).retryAttemptedLogLevel(LoggingLevel.WARN)).to("mock:b").throwException(new IOException("Some IO error"));
}
};
}
use of java.io.IOException in project camel by apache.
the class ManagedFailoverLoadBalancerTest method testManageFailoverLoadBalancer.
public void testManageFailoverLoadBalancer() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
getMockEndpoint("mock:foo").whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
throw new IOException("Forced");
}
});
MockEndpoint bar = getMockEndpoint("mock:bar");
bar.expectedMessageCount(1);
template.sendBodyAndHeader("direct:start", "Hello World", "foo", "123");
assertMockEndpointsSatisfied();
// get the stats for the route
MBeanServer mbeanServer = getMBeanServer();
// get the object name for the delayer
ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"mysend\"");
// should be on route1
String routeId = (String) mbeanServer.getAttribute(on, "RouteId");
assertEquals("route1", routeId);
String camelId = (String) mbeanServer.getAttribute(on, "CamelId");
assertEquals("camel-1", camelId);
String state = (String) mbeanServer.getAttribute(on, "State");
assertEquals(ServiceStatus.Started.name(), state);
Integer size = (Integer) mbeanServer.getAttribute(on, "Size");
assertEquals(2, size.intValue());
Boolean roundRobin = (Boolean) mbeanServer.getAttribute(on, "RoundRobin");
assertEquals(true, roundRobin.booleanValue());
Boolean sticky = (Boolean) mbeanServer.getAttribute(on, "Sticky");
assertEquals(true, sticky.booleanValue());
Integer attempts = (Integer) mbeanServer.getAttribute(on, "MaximumFailoverAttempts");
assertEquals(3, attempts.intValue());
String exceptions = (String) mbeanServer.getAttribute(on, "Exceptions");
assertEquals("java.io.IOException,java.sql.SQLException", exceptions);
String id = (String) mbeanServer.getAttribute(on, "LastGoodProcessorId");
assertEquals("bar", id);
TabularData data = (TabularData) mbeanServer.invoke(on, "exceptionStatistics", null, null);
assertNotNull(data);
assertEquals(2, data.size());
data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { false }, new String[] { "boolean" });
assertNotNull(data);
assertEquals(3, data.size());
data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { true }, new String[] { "boolean" });
assertNotNull(data);
assertEquals(5, data.size());
String json = (String) mbeanServer.invoke(on, "informationJson", null, null);
assertNotNull(json);
assertTrue(json.contains("\"description\": \"Balances message processing among a number of nodes"));
}
use of java.io.IOException in project camel by apache.
the class FailOverLoadBalanceNotInheritedErrorHandlerTest method createRouteBuilder.
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
// after failover is done, then we should be routed to dead
errorHandler(deadLetterChannel("mock:dead"));
from("direct:start").loadBalance().failover(3, false, true).throwException(new IllegalArgumentException()).throwException(new IOException()).throwException(new ConnectException()).end().end().to("mock:result");
}
};
}
use of java.io.IOException in project camel by apache.
the class FailOverLoadBalanceWrappedExceptionTest method createRouteBuilder.
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
from("direct:start").loadBalance().failover(IOException.class).to("direct:x", "direct:y", "direct:z");
from("direct:x").to("mock:x").process(new Processor() {
public void process(Exchange exchange) throws Exception {
// socket exception is an io exception
throw new CamelExchangeException("foo", exchange, new SocketException("Forced"));
}
});
from("direct:y").to("mock:y").process(new Processor() {
public void process(Exchange exchange) throws Exception {
throw new IOException("Forced");
}
});
from("direct:z").to("mock:z");
}
};
}
Aggregations