/** * Program entry point */ public static void main(String[] args) throws Exception { CamelContext context = new DefaultCamelContext(); context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("stream:in").to("direct:greetings"); from("direct:greetings").to("stream:out"); } }); context.start(); context.getRoutes().forEach(r -> LOGGER.info(r.toString())); context.stop(); } }
/** * A helper method to create a list of Route objects for a given route builder */ public static List<Route> getRouteList(RouteBuilder builder) throws Exception { CamelContext context = new DefaultCamelContext(); context.addRoutes(builder); context.start(); List<Route> answer = context.getRoutes(); context.stop(); return answer; }
/** * A helper method to create a list of Route objects for a given route builder */ public static List<Route> getRouteList(RouteBuilder builder) throws Exception { CamelContext context = new DefaultCamelContext(); context.addRoutes(builder); context.start(); List<Route> answer = context.getRoutes(); context.stop(); return answer; }
private List<RouteEndpointInfo> getRoutesInfo() { return camelContext.getRoutes().stream() .map(RouteEndpointInfo::new) .collect(Collectors.toList()); }
public void stop(String endpointName) throws Exception { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Stopping proxy route at endpoint: {}", endpointName); LOGGER.debug("Route list before = {}", Arrays.toString(camelContext.getRoutes().toArray())); } camelContext.stopRoute(endpointName); camelContext.removeRoute(endpointName); endpointIds.remove(endpointName); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Route list after = {}", Arrays.toString(camelContext.getRoutes().toArray())); } }
@Override public void applyRoutes(final CamelContext camelContext) throws Exception { CamelRunner.removeRoutes(camelContext, CamelRunner.fromRoutes(camelContext.getRoutes())); } }
if (routeId != null && camelContext != null) { for (Route route : camelContext.getRoutes()) { if (route.getId().equals(routeId)) { Consumer consumer = route.getConsumer();
/** * Remove all routes from the context which are not in the new set * <p> * This is a helper method intended to be used by implementations of {@link RoutesProvider}. * </p> * * @param context * the context to work on * @param routes * the collection of new routes */ public static void removeMissingRoutes(final CamelContext context, final Collection<RouteDefinition> routes) { Objects.requireNonNull(context); Objects.requireNonNull(routes); // gather new IDs final Set<String> newRouteIds = fromDefs(routes); // eval removed final Set<String> removedRouteIds = new HashSet<>(fromRoutes(context.getRoutes())); removedRouteIds.removeAll(newRouteIds); // remove from running context removeRoutes(context, removedRouteIds); }
/** * Program entry point */ public static void main(String[] args) throws Exception { CamelContext context = new DefaultCamelContext(); context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("stream:in").to("direct:greetings"); from("direct:greetings").to("stream:out"); } }); context.start(); context.getRoutes().stream().forEach(r -> LOGGER.info(r.toString())); context.stop(); } }
/** * Program entry point */ public static void main(String[] args) throws Exception { CamelContext context = new DefaultCamelContext(); context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:origin").multicast().to("mock:foo", "mock:bar", "stream:out"); } }); ProducerTemplate template = context.createProducerTemplate(); context.start(); context.getRoutes().stream().forEach(r -> LOGGER.info(r.toString())); template.sendBody("direct:origin", "Hello from origin"); context.stop(); } }
private void ensureNoDupTriggerKey() { for (Route route : getCamelContext().getRoutes()) { if (route.getEndpoint() instanceof QuartzEndpoint) { QuartzEndpoint quartzEndpoint = (QuartzEndpoint) route.getEndpoint(); TriggerKey checkTriggerKey = quartzEndpoint.getTriggerKey(); if (triggerKey.equals(checkTriggerKey)) { throw new IllegalArgumentException("Trigger key " + triggerKey + " is already in use by " + quartzEndpoint); } } } }
@Test public void test() { Assertions.assertThat(builder).isNotNull(); Assertions.assertThat(context.getRoutes().size()).isEqualTo(1); Assertions.assertThat(context.getEndpoint("direct:start")).isNotNull(); Assertions.assertThat(context.getEndpoint("mock:result")).isNotNull(); } }
@Override public void onInit(Consumer consumer) { this.consumer = consumer; // find the route of the consumer for (Route route : consumer.getEndpoint().getCamelContext().getRoutes()) { if (route.getConsumer() == consumer) { this.routeId = route.getId(); break; } } }
List<Route> routes = camelContext.getRoutes(); List<RouteStatus> routeStatuses = new ArrayList<RouteStatus>(); for (Route r : routes) {
@Override public void sentFilesViaFTPToClient() { CamelContext context = new DefaultCamelContext(); try { context.addRoutes(new FTPToClientRouteBuilder()); context.start(); while (true) { if (CollectionUtils.isEmpty(context.getRoutes())) { LOG.info("Finished sending files via FTP."); context.stop(); break; } } } catch (Exception e) { throw new RuntimeException("Couldn't FTP files", e); } finally { try { context.stop(); } catch (Exception e) { //ignore exception } } }
@Override protected void doStart() throws Exception { LOG.info(Thread.currentThread().getName()); // if (taskSession == null){ taskSession = new OCamelTaskSession(); taskSession.setOTask(config); taskSession.setCallback(callback); Object deleteOnFinish = config.getDocument().field(OTask.Field.AUTODELETE_SESSIONS.fieldName()); taskSession.setDeleteOnFinish(deleteOnFinish!=null?(Boolean)deleteOnFinish:false); taskSession.setConfig(config.getDocument().getIdentity().toString()); taskSession.setFinalProgress(context.getRoutes().size()); taskSession.start(); // } super.doStart(); }
for (Route route : camelContext.getRoutes()) { Endpoint endpoint = route.getEndpoint(); if (endpoint instanceof DelegateEndpoint) {
for (Route route : camelContext.getRoutes()) { Endpoint endpoint = route.getEndpoint(); if (endpoint instanceof DelegateEndpoint) {
List<Route> routes = context.getRoutes(); for (Route route : routes) { if ( !route.getId().startsWith("mina")) {
List<Route> routes = context.getRoutes();