public void configure() throws Exception { errorHandler(deadLetterChannel("seda:errors")); // We pool the atom feeds from the source for further processing in the seda queue // we set the delay to 1 second for each pool. // Using splitEntries=true will during polling only fetch one RSS Entry at any given time. from("rss:" + VERTX_BLOG_ATOM + "?splitEntries=true&consumer.delay=100").to("seda:feeds"); from("seda:feeds") // Filter .filter().method("filterService", "isRelease") // Transform (extract) .transform(simple("${body.entries[0].title}")) // Output .to("seda:announce"); } };
@Override public void configure() throws Exception { from("jms:queue:factory." + factoryType + ".inbound").routeId(factoryType + "_factory") .setHeader("name", xpath("order/type/text()")) .setHeader("id", xpath("order/id/text()")) .setHeader("amount", xpath("order/amount/text()")) .delay(constant(factoryCosts)) .setHeader(Exchange.HTTP_METHOD, constant("PUT")) .setBody(constant("")) .to("http://" + reportServerHost + ":" + reportServerPort + "/report/services/reporting"); } }
.split(bodyAs(String.class).tokenize("${in.header.importConfigOneShot.getLineSeparator}")) .setHeader(RouterConstants.HEADER_CONFIG_TYPE, constant(configType)) .process(lineSplitProcessor) .to("log:org.apache.unomi.router?level=DEBUG") .marshal(jacksonDataFormat) .convertBodyTo(String.class); if (RouterConstants.CONFIG_TYPE_KAFKA.equals(configType)) { prDef.to((KafkaEndpoint) getEndpointURI(RouterConstants.DIRECTION_FROM, RouterConstants.DIRECT_IMPORT_DEPOSIT_BUFFER));
.bean(ROUTE_BEAN, "isAbleToHandleExistingMessage") .choice() .when().method(ROUTE_BEAN, "isMessageObsolete") .log(LoggingLevel.WARN, "Error occurred during route processing: ${property." + Exchange.EXCEPTION_CAUGHT + "}") .to("log:" + AsynchMessageRoute.class.getPackage().getName() + "?level=WARN&showCaughtException=true&showStackTrace=true&multiline=true") .choice() .validate(header(MSG_HEADER).isNotNull()) .to(AsynchConstants.URI_CONFIRM_MESSAGE) .bean(ROUTE_BEAN, "sendMailToAdmin").id("sendEmail"); .end();
.removeHeader(SpringWebserviceConstants.SPRING_WS_SOAP_HEADER) .bean(MessageTransformer.getInstance(), "createMessage") .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { }).id("throttleProcess") .bean(ROUTE_BEAN, "insertMessage") .to(URI_GUARANTEED_ORDER_ROUTE) .bean(ROUTE_BEAN, "createOkResponse") .endDoTry()
.setHeader(HTTP_METHOD).constant("PUT") .process(new RiakKeyBuilder()) .log("Updating cache entry for: ${headers[CamelFcrepoIdentifier]}") .to("http4://{{riak.host}}"); .filter(header(HTTP_RESPONSE_CODE).isEqualTo(200)) .log("Compacting resource ${headers[CamelFcrepoIdentifier]}") .to("direct:compact");
.removeHeaders("CamelHttp*") .setHeader(Exchange.HTTP_METHOD, constant("PATCH")) .setHeader(Exchange.CONTENT_TYPE, constant(MediaType.APPLICATION_FORM_URLENCODED_VALUE)) .setBody(simple("access_token=${headers.apiToken}&endpoint=https%3A%2F%2Flocation-${headers.userid}-api.amp.${headers.openshiftappurl}%3A443&api_backend=http%3A%2F%2Flocation-service.${headers.userid}.svc%3A8080&sandbox_endpoint=https%3A%2F%2Flocation-${headers.userid}-api-staging.amp.${headers.openshiftappurl}%3A443&oidc_issuer_endpoint=http%3A%2F%2F3scale-admin%3A${headers.secret}%40sso-sso.${headers.openshiftappurl}%2Fauth%2Frealms%2F${headers.userid}")) .toD("https4://${headers.userid}-admin.${headers.openshiftappurl}/admin/api/services/${headers.serviceid}/proxy.xml?sslContextParameters=#ssl&bridgeEndpoint=true") .removeHeaders("CamelHttp*") .log("Service : [${headers.serviceid}] and Plan [${headers.planid}] and Account [${headers.accountid}]") .setHeader(Exchange.HTTP_METHOD, constant("POST")) .setHeader(Exchange.CONTENT_TYPE, constant(MediaType.APPLICATION_FORM_URLENCODED_VALUE)) .setBody(simple("access_token=${headers.apiToken}&name=Secure&system_name=secure")) .toD("https4://${headers.userid}-admin.${headers.openshiftappurl}/admin/api/services/${headers.serviceid}/application_plans.xml?sslContextParameters=#ssl&bridgeEndpoint=true") .setHeader("planid").xpath("/plan/id", String.class) .setHeader(Exchange.HTTP_METHOD, constant("GET")) .setHeader(Exchange.HTTP_QUERY, simple("access_token=${headers.apiToken}")) .log("${headers}") .delay(1000) .toD("https4://${headers.userid}-admin.${headers.openshiftappurl}/admin/api/accounts.xml?sslContextParameters=#ssl&bridgeEndpoint=true") .setHeader("accountid").xpath("/accounts/account/id", String.class) .setHeader(Exchange.HTTP_METHOD, constant("POST")) .setHeader(Exchange.CONTENT_TYPE, constant(MediaType.APPLICATION_FORM_URLENCODED_VALUE)) .setBody(simple("access_token=${headers.apiToken}&plan_id=${header.planid}&name=Secured+App&description=SSO+Secured+App&redirect_url=http%3A%2F%2Fwww-${headers.userid}.apps.${headers.openshiftappurl}%2F*")) .toD("https4://${headers.userid}-admin.${headers.openshiftappurl}/admin/api/accounts/${header.accountid}/applications.xml?sslContextParameters=#ssl&bridgeEndpoint=true") .setHeader("applicationid").xpath("/application/id", String.class)
@Override public void configure() throws Exception { from("direct:start") .filter(header("userStatus").isEqualTo("valid")) .to("mock:valid") .end() .to("mock:all"); }
.split(bodyAs(String.class).tokenize(importConfiguration.getLineSeparator())) .log(LoggingLevel.DEBUG, "Splitted into ${exchangeProperty.CamelSplitSize} records") .setHeader(RouterConstants.HEADER_CONFIG_TYPE, constant(configType)) .process(lineSplitProcessor) .log(LoggingLevel.DEBUG, "Split IDX ${exchangeProperty.CamelSplitIndex} record") .marshal(jacksonDataFormat) .convertBodyTo(String.class);
.split(body()) .marshal(jacksonDataFormat) .convertBodyTo(String.class) .setHeader(RouterConstants.HEADER_EXPORT_CONFIG, constant(exportConfiguration)) .log(LoggingLevel.DEBUG, "BODY : ${body}"); if (RouterConstants.CONFIG_TYPE_KAFKA.equals(configType)) { prDef.to((KafkaEndpoint) getEndpointURI(RouterConstants.DIRECTION_FROM, RouterConstants.DIRECT_EXPORT_DEPOSIT_BUFFER));
@Override public void configure() { from("direct:primo.test") .to(ExchangePattern.InOut, "hazelcastmq:queue:primo.test"); from("hazelcastmq:queue:primo.test") .process(new StaticLogProcessor("Starting work in endpoint.")) .delay(2000) .process(new StaticLogProcessor("Finished work in endpoint.")) .setBody(constant("Goodbye World!")); } });
@Override public void configure() throws Exception { from("file:ordersin?noop=true").id("order") .setHeader("customer", xpath("/order/customer/text()").stringResult()) .split(xpath("/order/item")) .setHeader("count", xpath("/item/@count").stringResult()) .setHeader("name", xpath("/item/@name").stringResult()) .choice() .when(xpath("/item/@vendor != 'direct'")).to("direct:vendor") .otherwise().recipientList(simple("file:ordersout/${header.customer}")); from("direct:vendor").id("mailtovendor") .setHeader("to", method("vendorMailService")) .setHeader("subject", simple("Order from ${header.customer}")) .to("velocity:mailtemplate.txt") .to("stream:out") .to("smtp:{{mailserver}}"); } }
@Override public void configure() throws Exception { // this is the webservice route which is started last from("cxf:bean:inventoryEndpoint") .routeId("webservice").startupOrder(3) .to("direct:update") .transform().method("inventoryService", "replyOk"); // 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") .end(); // this is the shared route which then must be started first from("direct:update") .routeId("update").startupOrder(1) .to("bean:inventoryService?method=updateInventory"); } }
@Override public void configure() throws Exception { from("jms:queue:factory." + factoryType + ".inbound").routeId(factoryType + "_factory") .setHeader("name", xpath("order/type/text()")) .setHeader("id", xpath("order/id/text()")) .setHeader("amount", xpath("order/amount/text()")) .delay(constant(factoryCosts)) .setHeader(Exchange.HTTP_METHOD, constant("PUT")) .setBody(constant("")) .to("http://" + reportServerHost + ":" + reportServerPort + "/report/services/reporting"); } }
.end() // end delay -- see comment below delay(...).
@Override public void configure() throws Exception { // read files from the shared directory // url to consume files from String url = "file:target/inbox?delete=true"; // use the zookeeper master component in the clustered group named myGroup // to run a master/slave mode in the following Camel url from("zookeeper-master:myGroup:" + url) .log(name + " - Received file: ${file:name}") .delay(delay) .log(name + " - Done file: ${file:name}") .to("file:target/outbox"); }
@Override public void configure() throws Exception { // this is the webservice route which is started last from("cxf:bean:inventoryEndpoint") .routeId("webservice").startupOrder(3) .to("direct:update") .transform().method("inventoryService", "replyOk"); // 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") .end(); // this is the shared route which then must be started first from("direct:update") .routeId("update").startupOrder(1) .to("bean:inventoryService?method=updateInventory"); } }
private void addThrottling(TryDefinition route) { Throttling throttling = _reference.getServiceMetadata().getThrottling(); long timePeriodMS = throttling != null ? throttling.getTimePeriod() : Throttling.DEFAULT_TIME_PERIOD; route.filter(THROTTLE_CHECK) .throttle(header(Throttling.MAX_REQUESTS)).timePeriodMillis(timePeriodMS) // throttle needs a child process, so we'll just remove the header // using an empty process definition causes some of the interceptors // to blow chunks, specifically audit interceptors .removeHeader(Throttling.MAX_REQUESTS) .end().end(); } }