Refine search
@Override public void configure() throws Exception { final String kafkaUri = kafkaConnectionInformation.kafkaUri(); from("direct:start").process(new Processor() { @Override public void process(Exchange exchange) throws Exception { final INDArray arr = (INDArray) exchange.getIn().getBody(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); Nd4j.write(arr, dos); byte[] bytes = bos.toByteArray(); String base64 = Base64.encodeBase64String(bytes); exchange.getIn().setBody(base64, String.class); String id = UUID.randomUUID().toString(); exchange.getIn().setHeader(KafkaConstants.KEY, id); exchange.getIn().setHeader(KafkaConstants.PARTITION_KEY, id); } }).to(kafkaUri); from(kafkaUri).process(new Processor() { @Override public void process(Exchange exchange) throws Exception { byte[] body2 = (byte[]) exchange.getIn().getBody(); String body = new String(body2); INDArray arr = Nd4jBase64.fromBase64(body); exchange.getIn().setBody(arr); } }).to("direct:receive"); } }
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"); } };
routes.from("direct:getdata").bean(new Bean3()); context.addRoutes(routes); context.start(); final MockEndpoint result = context.getEndpoint("mock:expression", MockEndpoint.class); result.expectedBodiesReceived("Hello Hiram", "Hello World"); result.assertIsSatisfied();
@Override public void configure() throws Exception { // Verify that the module returns a valid number. If number of threads is < 0, // creating the routes below does not work final int numberConsumerThrads = getNumConsumerThreads(module); final JmsQueueNameFactory queueNameFactory = new JmsQueueNameFactory( CamelSinkConstants.JMS_QUEUE_PREFIX, module.getId()); from(String.format("queuingservice:%s?concurrentConsumers=%d", queueNameFactory.getName(), numberConsumerThrads)) .setExchangePattern(ExchangePattern.InOnly) .process(new CamelSinkServerProcessor(consumerManager, module)) .routeId(getRouteId()); } }
@Override public void configure() throws Exception { // HTTP service fromF("jetty:http://localhost:" + port) // increase the atomic clustered counter from the hazelcast cache .setHeader(HazelcastConstants.OBJECT_ID, constant("myCounter")) .to("hazelcast:atomicvalue:Cache?hazelcastInstance=#hz&defaultOperation=increment") // prepare http response .log(name + ": counter is now ${body}") .setHeader(Exchange.CONTENT_TYPE, constant("text/plain")) .transform().simple("Atomic Counter is now ${body}\n"); }
@Override public void configure() throws Exception { // this is the webservice route which is started last from("cxf:bean:inventoryEndpoint") .routeId("webservice").startupOrder(2) .to("direct:update") .transform().method("inventoryService", "replyOk"); // 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() { 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 { JacksonDataFormat jackson = new JacksonDataFormat(); String result_queue = "latexmlresults_"+UUID.randomUUID().toString(); from("activemq:queue:"+result_queue) .unmarshal(jackson) .bean(method(this, "compile_result")); from("direct:compileLaTeXML") .setHeader("uid", constant(uid)) .setHeader("JMSReplyTo", constant(result_queue)) .to("activemq:queue:latexml?preserveMessageQos=true"); }
@Override public void configure() throws Exception { JacksonDataFormat configFormat = new JacksonDataFormat(MHWWorkerConfig.class); from("file://"+lmhRoot+"?fileName=worker.cfg&delay=10000&noop=true") .unmarshal(configFormat) .bean(method(this, "setConfig")); from("direct:saveConfig") .marshal(configFormat) .to("file://"+lmhRoot+"?fileName=worker.cfg"); }
@Override public void configure() throws Exception { from("direct:input") .toF("mhd-iti65:localhost:%d", FhirTestContainer.DEMO_APP_PORT); from("mhd-iti65:stub?audit=true") .errorHandler(noErrorHandler()) .setHeader(VALIDATION_MODE, constant(SCHEMA | MODEL)) .process(itiRequestValidator()) .transform(new Responder()); }
@Override public void configure() throws Exception { // define a Camel REST service using the rest-dsl // where we define a GET /hello as a service that routes to the hello route // we will cover rest-dsl in chapter 10 rest("/").produces("text/plain") .get("hello") .to("direct:hello"); from("direct:hello") .to("geocoder:address:current") .transform().simple("Hello from Spring Boot and Camel. We are at: ${body}"); } }