@Override public void configure() throws Exception { from(inputPath) .routeId(getRouteId()) .split(body().tokenize("\n")) .convertBodyTo(UpdateInventoryInput.class) .to("direct:update"); }
@Override public void configure() { // load file orders from src/data into the JMS queue from("file:src/data?noop=true").to("jms:incomingOrders"); // content-based router from("jms:incomingOrders") .wireTap("jms:orderAudit") .choice() .when(header("CamelFileName").endsWith(".xml")) .to("jms:xmlOrders") .when(header("CamelFileName").regex("^.*(csv|csl)$")) .to("jms:csvOrders") .otherwise() .to("jms:badOrders"); } });
@Override public void configure() throws Exception { logger.info("Configure Recurrent Route 'To Target'"); RouteDefinition rtDef; if (RouterConstants.CONFIG_TYPE_KAFKA.equals(configType)) { rtDef = from((KafkaEndpoint) getEndpointURI(RouterConstants.DIRECTION_TO, RouterConstants.DIRECT_IMPORT_DEPOSIT_BUFFER)); } else { rtDef = from((String) getEndpointURI(RouterConstants.DIRECTION_TO, RouterConstants.DIRECT_IMPORT_DEPOSIT_BUFFER)); } rtDef.choice() .when(header(RouterConstants.HEADER_FAILED_MESSAGE).isNull()) .unmarshal(jacksonDataFormat) .process(unomiStorageProcessor) .otherwise() .log(LoggingLevel.DEBUG, "Failed message, skip processing!") .end() .aggregate(constant(true), new ArrayListAggregationStrategy()) .completionPredicate(exchangeProperty("CamelSplitComplete").isEqualTo("true")) .eagerCheckCompletion() .process(importRouteCompletionProcessor) .to("log:org.apache.unomi.router?level=DEBUG"); }
.validate(body().isInstanceOf(Message.class)) .validate((Predicate) simple( "${body.state} == ${type:org.openhubframework.openhub.api.entity.MsgStateEnum.IN_QUEUE}")) .when(header(NO_EFFECT_PROCESS_HEADER).isEqualTo(Boolean.TRUE)) .end() .validate(exchangeProperty(Exchange.EXCEPTION_CAUGHT).isNotNull()) .validate(header(MSG_HEADER).isNotNull()) .to(AsynchConstants.URI_CONFIRM_MESSAGE); .validate(header(MSG_HEADER).isNotNull()) .to(AsynchConstants.URI_CONFIRM_MESSAGE) .bean(ROUTE_BEAN, "sendMailToAdmin").id("sendEmail"); + "- '${property." + Exchange.EXCEPTION_CAUGHT + ".message}'") .choice() .when(body().isInstanceOf(ExternalCall.class)) .when(header(MSG_HEADER).isNull()) .validate(body().isInstanceOf(ExternalCall.class)) .setHeader(MSG_HEADER).mvel("request.body.message") .endChoice() .filter(body().isInstanceOf(ExternalCall.class))
.choice() .when(PredicateBuilder.and( header(WonCamelConstants.MESSAGE_HEADER).isNotNull(), not(new IsResponseMessagePredicate()))) .to("direct:sendSuccessResponse") header(WonCamelConstants.OUTBOUND_MESSAGE_HEADER).isNotNull()) header(WonCamelConstants.ORIGINAL_MESSAGE_HEADER).isNotNull(), new IsSystemMessageToOwnerPredicate())) header(WonCamelConstants.DIRECTION_HEADER).isEqualTo(URI.create(WONMSG.TYPE_FROM_OWNER_STRING)), PredicateBuilder.and( header(WonCamelConstants.MESSAGE_HEADER).isNotNull(), new ShouldCallFacetImplForMessagePredicate()))) .choice() .when(header("methodName").isEqualTo("register")) .to("bean:ownerManagementService?method=registerOwnerApplication") .when(header("methodName").isEqualTo("getEndpoints")) .to("bean:queueManagementService?method=getEndpointsForOwnerApplication") .otherwise() .choice() .when(header(WonCamelConstants.MESSAGE_TYPE_HEADER).isEqualTo(URI.create(WONMSG.TYPE_HINT.getURI().toString())))
@Override public void configure() { // load file orders from src/data into the JMS queue from("file:src/data?noop=true").to("jms:incomingOrders"); // content-based router from("jms:incomingOrders") .choice() .when(header("CamelFileName").endsWith(".xml")) .to("jms:xmlOrders") .when(header("CamelFileName").endsWith(".csv")) .to("jms:csvOrders"); // test that our route is working from("jms:xmlOrders").process(new Processor() { public void process(Exchange exchange) throws Exception { System.out.println("Received XML order: " + exchange.getIn().getHeader("CamelFileName")); } }); from("jms:csvOrders").process(new Processor() { public void process(Exchange exchange) throws Exception { System.out.println("Received CSV order: " + exchange.getIn().getHeader("CamelFileName")); } }); } });
.split(body()) .choice() .when(body().method("shouldBeKept").isEqualTo(false)).to(direct("removeMetadata")) .otherwise().to(direct("getMetadataArtifacts")) .endChoice(); .aggregate(body().method("getDbKey"), new SuitesAggregationStrategy()) .completionSize(header(SuiteAggregationCounter.NAME_KEY).method("getSuitesToAggregate")) .completionTimeout(60000L).forceCompletionOnStop() .to(direct("removeArtifacts"));
public void exposeAnnotatedBeans() { for (Map.Entry<String, Object> bean : findBeansWithRestOperations(routeBuilder.getContext().getRegistry()).entrySet()) { for (Method method : findRestOperations(bean.getValue().getClass())) { String uri = "/" + bean.getKey() + "/" + method.getName(); boolean isGet = true; int parametersCount = method.getParameterCount(); if (parametersCount > 0) { Class<?> lastParameterType = method.getParameterTypes()[parametersCount - 1]; if (lastParameterType != String.class && lastParameterType != Character.class && lastParameterType != char.class && lastParameterType != Integer.class && lastParameterType != int.class && lastParameterType != Long.class && lastParameterType != long.class && lastParameterType != Float.class && lastParameterType != float.class && lastParameterType != Double.class && lastParameterType != double.class) { isGet = false; parametersCount--; } } for (int i = 0; i < parametersCount; i++) { uri += "/{p" + i + "}"; } routeBuilder.rest(uri).verb(isGet ? "GET" : "POST").route().process(restParametersBindingProcessor()). to("bean:" + bean.getKey() + "?method=" + method.getName() + "&multiParameterArray=true"). choice().when(routeBuilder.header("CAMEL_REST_VOID_OPERATION").isNotNull()).setBody().constant("").endChoice(); } } }
.validate(header(SERVICE_HEADER).isNotNull()) .validate(header(OPERATION_HEADER).isNotNull()) .errorHandler(noErrorHandler()) .validate(body().isInstanceOf(Message.class))
@Override public void configure() throws Exception { //NOSONAR super.configure(); // initial route RouteDefinition route = appendSplitterRoutes( appendFilterRoutes( from(endpoints.getInputUri()) ) ); // main processing route addInterimProc(route .setHeader(PLUGIN_ID, constant(pluginId)) .log(DEBUG, format("===> INPUT FOR %s ${exchangeId} ${in.header.bodyClass}, correlationKey: ${in.header.correlationKey}", pluginId)) .process(getProcessor())) .choice() .when(body().isNull()) .log(DEBUG, pluginId + " output is NULL, skipping next routes") .stop() .otherwise() .log(DEBUG, format("===> ROUTE %s ===> %s", endpoints.getInputUri(), endpoints.getProducerUri())) .to(endpoints.getProducerUri()) .routeId(endpoints.getInputRouteId()); }
@Override protected void doConfigure() throws Exception { from("servlet:///" + SERVLET_URL + "?servletName=" + CAMEL_SERVLET) .routeId(ROUTE_ID_CONTEXT_CALL) .validate(header(CALL_ID_HEADER).isNotNull()) .log(LoggingLevel.DEBUG, "Incoming context call with ID: ${headers." + CALL_ID_HEADER + "} ") .bean(this, "makeCall"); }
.when(body().isNull()) .log(DEBUG, pluginId + " output is NULL, skipping next routes") .stop()
@Override public void configure() throws Exception { LOG.debug("Started REST data stream source at port {}.", port); from("netty4-http:http://0.0.0.0:" + port + "/?matchOnUriPrefix=true&httpMethodRestrict=OPTIONS,GET,POST,PUT,DELETE"). choice(). when(header(HTTP_METHOD).isEqualTo("OPTIONS")).setBody().constant("").endChoice(). otherwise(). setHeader(CONTENT_TYPE).constant(contentType). process( exc -> { String requestUri = exc.getIn().getHeader(HTTP_URI, String.class); LOG.debug("Processing request URI: {}", requestUri); String trimmedUri = removeEnd(requestUri, "/"); LOG.debug("Trimmed request URI: {}", trimmedUri); String busChannel = trimmedUri.substring(1).replaceAll("\\/", "."); exc.setProperty("target", "amqp:" + busChannel); }).toD("${property.target}").endChoice(). end(). process(exc -> { exc.getIn().setHeader("Access-Control-Allow-Origin", "*"); exc.getIn().setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); }); }
@Override public void configure() { // load file orders from src/data into the JMS queue from("file:src/data?noop=true").to("jms:incomingOrders"); // content-based router from("jms:incomingOrders") .process(new Processor() { public void process(Exchange exchange) throws Exception { System.out.println("Received order: " + exchange.getIn().getBody(String.class)); } }) .choice() .when(header("CamelFileName").endsWith(".xml")) .to("jms:xmlOrders") .when(header("CamelFileName").regex("^.*(csv|csl)$")) .to("jms:csvOrders") .otherwise() .to("jms:badOrders"); } });
@Override public void configure() throws Exception { // this is the file route which is started 2nd last from("file://target/inventory/updates") .routeId("file").startupOrder(2) .split(body().tokenize("\n")) .convertBodyTo(UpdateInventoryInput.class) .to("direct:update"); // this is the shared route which then must be started first from("direct:update") .routeId("update").startupOrder(1) .to("bean:inventoryService?method=updateInventory"); } }
@Override protected void doConfigure() throws Exception { from("servlet:///" + SERVLET_URL + "?servletName=" + CAMEL_SERVLET) .routeId(ROUTE_ID_DIRECT_CALL) .validate(header(CALL_ID_HEADER).isNotNull()) .log(LoggingLevel.DEBUG, "Incoming direct WS call with ID: ${headers." + CALL_ID_HEADER + "} ") .bean(this, "setHeader") .bean(this, "getRequest") .convertBodyTo(String.class, "UTF-8") .routingSlip(method(this, "getWsUri")).id(ROUTING_SLIP_ID) .bean(this, "removeCallParams"); }
/** * * @throws Exception */ @Override public void configure() throws Exception { for (int i = 0; i<endpoints.size();i++){ from(endpoints.get(i)).routeId("Node2MatcherRoute"+brokerUri+i) .choice() .when(header("methodName").isEqualTo("needCreated")) .to("bean:matcherProtocolMatcherServiceJMSBased?method=needCreated") .when(header("methodName").isEqualTo("needActivated")) .to("bean:matcherProtocolMatcherServiceJMSBased?method=needActivated") .when(header("methodName").isEqualTo("needDeactivated")) .to("bean:matcherProtocolMatcherServiceJMSBased?method=needDeactivated") .otherwise() .to("log:Message Type Not Supported"); } }