use of org.apache.camel.impl.EventDrivenConsumerRoute in project camel by apache.
the class StreamResequencerTest method doTestStreamResequencerType.
protected void doTestStreamResequencerType() throws Exception {
List<Route> list = getRouteList(createRouteBuilder());
assertEquals("Number of routes created: " + list, 1, list.size());
Route route = list.get(0);
EventDrivenConsumerRoute consumerRoute = assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
Channel channel = unwrapChannel(consumerRoute.getProcessor());
assertIsInstanceOf(DefaultErrorHandler.class, channel.getErrorHandler());
assertIsInstanceOf(StreamResequencer.class, channel.getNextProcessor());
}
use of org.apache.camel.impl.EventDrivenConsumerRoute in project camel by apache.
the class AbstractTransactionTest method getConditionalExceptionProcessor.
/**
* By default routes should be wrapped in the {@link DeadLetterChannel} so
* lets unwrap that and return the actual processor
*/
protected ConditionalExceptionProcessor getConditionalExceptionProcessor(Route route) {
// the following is very specific (and brittle) and is not generally
// useful outside these transaction tests (nor intended to be).
EventDrivenConsumerRoute consumerRoute = assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
Processor processor = findProcessorByClass(consumerRoute.getProcessor(), ConditionalExceptionProcessor.class);
return assertIsInstanceOf(ConditionalExceptionProcessor.class, processor);
}
use of org.apache.camel.impl.EventDrivenConsumerRoute in project camel by apache.
the class ErrorHandlerTest method testEndpointConfiguration.
public void testEndpointConfiguration() throws Exception {
SpringCamelContext context = applicationContext.getBeansOfType(SpringCamelContext.class).values().iterator().next();
List<Route> list = context.getRoutes();
assertEquals("Number routes created" + list, 2, list.size());
for (Route route : list) {
EventDrivenConsumerRoute consumerRoute = assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
Channel channel = unwrapChannel(consumerRoute.getProcessor());
DeadLetterChannel deadLetterChannel = assertIsInstanceOf(DeadLetterChannel.class, channel.getErrorHandler());
RedeliveryPolicy redeliveryPolicy = deadLetterChannel.getRedeliveryPolicy();
assertEquals("getMaximumRedeliveries()", 1, redeliveryPolicy.getMaximumRedeliveries());
assertEquals("isUseExponentialBackOff()", true, redeliveryPolicy.isUseExponentialBackOff());
}
}
use of org.apache.camel.impl.EventDrivenConsumerRoute in project camel by apache.
the class CamelContextFactoryBeanTest method testXMLRouteLoading.
public void testXMLRouteLoading() throws Exception {
applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
CamelContext context = applicationContext.getBean("camel2", CamelContext.class);
assertNotNull("No context found!", context);
List<Route> routes = context.getRoutes();
LOG.debug("Found routes: " + routes);
assertNotNull("Should have found some routes", routes);
assertEquals("One Route should be found", 1, routes.size());
for (Route route : routes) {
Endpoint key = route.getEndpoint();
EventDrivenConsumerRoute consumerRoute = assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
Processor processor = consumerRoute.getProcessor();
assertNotNull(processor);
assertEndpointUri(key, "seda://test.c");
}
}
use of org.apache.camel.impl.EventDrivenConsumerRoute in project camel by apache.
the class DefaultManagementLifecycleStrategy method onRoutesAdd.
public void onRoutesAdd(Collection<Route> routes) {
for (Route route : routes) {
// enabled, then enlist the route as a known route
if (getCamelContext().getStatus().isStarting() || getManagementStrategy().getManagementAgent().getRegisterAlways() || getManagementStrategy().getManagementAgent().getRegisterNewRoutes()) {
// register as known route id
knowRouteIds.add(route.getId());
}
if (!shouldRegister(route, route)) {
// avoid registering if not needed, skip to next route
continue;
}
Object mr = getManagementObjectStrategy().getManagedObjectForRoute(camelContext, route);
// skip already managed routes, for example if the route has been restarted
if (getManagementStrategy().isManaged(mr, null)) {
LOG.trace("The route is already managed: {}", route);
continue;
}
// and set me as the counter
if (route instanceof EventDrivenConsumerRoute) {
EventDrivenConsumerRoute edcr = (EventDrivenConsumerRoute) route;
Processor processor = edcr.getProcessor();
if (processor instanceof CamelInternalProcessor && mr instanceof ManagedRoute) {
CamelInternalProcessor internal = (CamelInternalProcessor) processor;
ManagedRoute routeMBean = (ManagedRoute) mr;
CamelInternalProcessor.InstrumentationAdvice task = internal.getAdvice(CamelInternalProcessor.InstrumentationAdvice.class);
if (task != null) {
// we need to wrap the counter with the camel context so we get stats updated on the context as well
if (camelContextMBean != null) {
CompositePerformanceCounter wrapper = new CompositePerformanceCounter(routeMBean, camelContextMBean);
task.setCounter(wrapper);
} else {
task.setCounter(routeMBean);
}
}
}
}
try {
manageObject(mr);
} catch (JMException e) {
LOG.warn("Could not register Route MBean", e);
} catch (Exception e) {
LOG.warn("Could not create Route MBean", e);
}
}
}
Aggregations