Hello How can Guivanni's code be simplified further?
-christian- Am Wed, 8 Feb 2017 12:56:51 +0100 schrieb Zoran Regvart <[email protected]>: > Hi Christian, > something like that, but I would tie start/stop of Camel context with > the lifecycle of the application and use somewhat simpler code that > Giovanni suggested, > > zoran > > On Wed, Feb 8, 2017 at 11:57 AM, Christian Brunotte <[email protected]> > wrote: > > Hello Zoran > > > > So what you propose is (in pseudocode): > > > > RouteBuilder builder = new RouteBuilder() { > > from("direct:start") > > .enrich("file://src/main/resources/inputs/test.txt") > > ... > > .to("direct:result"); > > } > > > > CamelContext camel = new DefaultCamelContext(); > > camel.addRoutes(simpleRoute); > > camel.start(); > > camel.createProducer().send("direct:start"); > > String result = camel.createConsumer().receiveBody("direct:result", > > String.class); camel.stop(); > > > > That would start the Camel Engine but it would wait for a command > > ("direct:start") before it does anything and then would have to be > > manually be polled, correct? > > > > Best Regards, > > > > -christian- > > > > Am Wed, 8 Feb 2017 09:41:24 +0100 > > schrieb Zoran Regvart <[email protected]>: > > > >> Hi Christian, > >> bare in mind that you can have control if you use direct > >> component, so having Camel context/routes started, doesn't mean > >> that it needs to poll in the background, you can do that on demand, > >> > >> HTH, > >> > >> zoran > >> > >> On Tue, Feb 7, 2017 at 10:56 PM, Christian Brunotte > >> <[email protected]> wrote: > >> > Hello > >> > > >> > I'd like to integrate Apache Camel into an existing project and > >> > just use some of it's endpoint capabilities (ftp, file, sftp > >> > etc.) to fetch some files and maybe validate them a bit. > >> > > >> > I don't want Camel to act as the main controller that dispatches > >> > everything in the background. > >> > > >> > Is it possible to use Camel in a very simplistic and lean way > >> > like e.g.: > >> > > >> > RouteBuilder simpleRoute = new RouteBuilder() { > >> > @Override > >> > public void configure() { > >> > > >> > from("file://src/main/resources/inputs/?include=input.*\\.txt&noop=true") > >> > .convertBodyTo(String.class) > >> > .validate(body().regex("...")); > >> > } > >> > }; > >> > > >> > String result = > >> > CamelContext.createSimpleConsumerTemplate(simpleRoute).receiveBody(String.class); > >> > > >> > Currently it seems that I still have to add the route to the > >> > CamelContext, start it, then call my ConsumerTemplate and after > >> > that stop the context. > >> > > >> > Best Regards > >> > > >> > -christian- > >> > >> > >> > > >
