@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"); }); }
/** * * @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"); } }
@Override public void configure() throws Exception { from("direct:start") .filter(header("userStatus").isEqualTo("valid")) .to("mock:valid") .end() .to("mock:all"); }
protected void assertSendBodyReceivesCorrectPayload(Object inputBody, String expectedBody) throws InterruptedException { resultEndpoint.expectedBodiesReceived(expectedBody); resultEndpoint.allMessages().header(Exchange.CONTENT_TYPE).isEqualTo(JsonEndpoint.JSON_CONTENT_TYPE); template.sendBody(inputBody); resultEndpoint.assertIsSatisfied(); }
@Override public void configure() throws Exception { logger.info("Configure Recurrent Route 'Export :: Data Producer'"); RouteDefinition rtDef; if (RouterConstants.CONFIG_TYPE_KAFKA.equals(configType)) { rtDef = from((KafkaEndpoint) getEndpointURI(RouterConstants.DIRECTION_TO, RouterConstants.DIRECT_EXPORT_DEPOSIT_BUFFER)); } else { rtDef = from((String) getEndpointURI(RouterConstants.DIRECTION_TO, RouterConstants.DIRECT_EXPORT_DEPOSIT_BUFFER)); } LineBuildProcessor processor = new LineBuildProcessor(profileExportService); rtDef.unmarshal(jacksonDataFormat) .process(processor) .aggregate(constant(true), new StringLinesAggregationStrategy()) .completionPredicate(exchangeProperty("CamelSplitSize").isEqualTo(exchangeProperty("CamelAggregatedSize"))) .eagerCheckCompletion() .process(exportRouteCompletionProcessor) .toD("${in.header.exportConfig.getProperty('destination')}"); }
@Test public void testSendXMLWhichShouldPassThroughUnchanged() throws Exception { String xmlContentType = "text/xml"; String expectedBody = "<foo>bar</foo>"; resultEndpoint.expectedBodiesReceived(expectedBody); resultEndpoint.allMessages().header(Exchange.CONTENT_TYPE).isEqualTo(xmlContentType); template.sendBodyAndHeader(expectedBody, Exchange.CONTENT_TYPE, xmlContentType); resultEndpoint.assertIsSatisfied(); }
@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"); }
@Override public void configure() throws Exception { // use vertx instance on the Camel vertx component getContext().getComponent("vertx", VertxComponent.class).setVertx(vertx); // initialize the list of games which is called when a new client connects to Vert.X backend from("direct:init-games").routeId("init-games") .log("Init games event") .to("goal:games.csv") // the frontend expect one message per game so split .split(body()) .to("vertx:games"); // the route for handling live score updates from the goal // component which is published to vertx addresses from("goal:goals.csv").routeId("livescore").autoStartup(false) .log("Goal event: ${header.action} -> ${body}") .choice() .when(header("action").isEqualTo("clock")) .to("vertx:clock") .when(header("action").isEqualTo("goal")) .to("vertx:goals"); // consume from vertx control address when the user clicks the control buttons // then we want to start/suspend the livescore route accordingly from("vertx:control").routeId("control") .log("Control event: ${body}") .toD("controlbus:route?routeId=livescore&async=true&action=${body}"); }
.setHeader(FCREPO_IDENTIFIER).simple("${headers[" + IDENTIFIER + "]}") .choice() .when(header(EVENT_TYPE).isEqualTo(REPOSITORY + "NODE_REMOVED")) .to("direct:delete") .otherwise() .setHeader(FCREPO_IDENTIFIER).simple("${headers[" + HTTP_PATH + "]}") .choice() .when(header(HTTP_METHOD).isEqualTo("GET")).to("direct:get") .when(header(HTTP_METHOD).isEqualTo("PUT")).to("direct:update") .when(header(HTTP_METHOD).isEqualTo("DELETE")).to("direct:delete"); .filter(header(HTTP_RESPONSE_CODE).isEqualTo(200)) .setHeader(HTTP_METHOD).constant("PUT") .process(new RiakKeyBuilder()) .routeId("JsonLdGet") .to("direct:getResource") .filter(header(HTTP_RESPONSE_CODE).isEqualTo(200)) .log("Compacting resource ${headers[CamelFcrepoIdentifier]}") .to("direct:compact");
header(WonCamelConstants.DIRECTION_HEADER).isEqualTo(URI.create(WONMSG.TYPE_FROM_OWNER_STRING)), PredicateBuilder.and( header(WonCamelConstants.MESSAGE_HEADER).isNotNull(), .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())))
.split(body()) .choice() .when(body().method("shouldBeKept").isEqualTo(false)).to(direct("removeMetadata")) .otherwise().to(direct("getMetadataArtifacts")) .endChoice();
.when(header(NO_EFFECT_PROCESS_HEADER).isEqualTo(Boolean.TRUE))