use of org.apache.camel.Route in project camel by apache.
the class HazelcastRoutePolicy method startAllStoppedConsumers.
private synchronized void startAllStoppedConsumers() {
try {
for (Route route : suspendedRoutes) {
LOGGER.debug("Starting consumer for {} ({})", route.getId(), route.getConsumer());
startConsumer(route.getConsumer());
}
suspendedRoutes.clear();
} catch (Exception e) {
handleException(e);
}
}
use of org.apache.camel.Route in project camel by apache.
the class CollectionOfCustomRoutesTest method xtestGuice.
public void xtestGuice() throws Exception {
Injector injector = Guice.createInjector(new MyModule());
CamelContext camelContext = injector.getInstance(CamelContext.class);
List<Route> list = camelContext.getRoutes();
assertEquals("size of " + list, 2, list.size());
GuiceTest.assertCamelContextRunningThenCloseInjector(injector);
}
use of org.apache.camel.Route in project camel by apache.
the class AbstractTransactionTest method getConditionalExceptionProcessor.
protected ConditionalExceptionProcessor getConditionalExceptionProcessor() {
Route route = context.getRoutes().get(0);
assertNotNull(route);
return getConditionalExceptionProcessor(route);
}
use of org.apache.camel.Route in project camel by apache.
the class ScheduledJob method execute.
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
SchedulerContext schedulerContext;
try {
schedulerContext = jobExecutionContext.getScheduler().getContext();
} catch (SchedulerException e) {
throw new JobExecutionException("Failed to obtain scheduler context for job " + jobExecutionContext.getJobDetail().getName());
}
ScheduledJobState state = (ScheduledJobState) schedulerContext.get(jobExecutionContext.getJobDetail().getName());
Action storedAction = state.getAction();
Route storedRoute = state.getRoute();
List<RoutePolicy> policyList = storedRoute.getRouteContext().getRoutePolicyList();
for (RoutePolicy policy : policyList) {
try {
if (policy instanceof ScheduledRoutePolicy) {
((ScheduledRoutePolicy) policy).onJobExecute(storedAction, storedRoute);
}
} catch (Exception e) {
throw new JobExecutionException("Failed to execute Scheduled Job for route " + storedRoute.getId() + " with trigger name: " + jobExecutionContext.getTrigger().getFullName(), e);
}
}
}
use of org.apache.camel.Route in project camel by apache.
the class CamelJob method lookupQuartzEndpoint.
private QuartzEndpoint lookupQuartzEndpoint(CamelContext camelContext, String endpointUri, Trigger trigger) throws JobExecutionException {
String targetTriggerName = trigger.getName();
String targetTriggerGroup = trigger.getGroup();
LOG.debug("Looking up existing QuartzEndpoint with trigger {}.{}", targetTriggerName, targetTriggerGroup);
try {
// as we prefer to use the existing endpoint from the routes
for (Route route : camelContext.getRoutes()) {
Endpoint endpoint = route.getEndpoint();
if (endpoint instanceof DelegateEndpoint) {
endpoint = ((DelegateEndpoint) endpoint).getEndpoint();
}
if (endpoint instanceof QuartzEndpoint) {
QuartzEndpoint quartzEndpoint = (QuartzEndpoint) endpoint;
String triggerName = quartzEndpoint.getTrigger().getName();
String triggerGroup = quartzEndpoint.getTrigger().getGroup();
LOG.trace("Checking route trigger {}.{}", triggerName, triggerGroup);
if (triggerName.equals(targetTriggerName) && triggerGroup.equals(targetTriggerGroup)) {
return (QuartzEndpoint) endpoint;
}
}
}
} catch (Exception e) {
throw new JobExecutionException("Error lookup up existing QuartzEndpoint with trigger: " + trigger, e);
}
// fallback and lookup existing from registry (eg maybe a @Consume POJO with a quartz endpoint, and thus not from a route)
if (camelContext.hasEndpoint(endpointUri) != null) {
return camelContext.getEndpoint(endpointUri, QuartzEndpoint.class);
} else {
LOG.warn("Cannot find existing QuartzEndpoint with uri: {}. Creating new endpoint instance.", endpointUri);
return camelContext.getEndpoint(endpointUri, QuartzEndpoint.class);
}
}
Aggregations