Re: Accessing OSGI Services from Camel Routes
Hi Willem, Thanks so much for your response. Would you mind further explaining what you mean when you say "export your Services as a bean component". In Camel, if I access a bean and its not their in camel registry, can we make it search the OSGI registry? I am struggling to find any examples or documentation on it. Would appreciate it if someone can provide any pointers. Regards, Anurag On Wed, Nov 23, 2011 at 7:08 PM, Willem.Jiang [via Camel] < ml-node+s465427n5015841...@n5.nabble.com> wrote: > On Wed Nov 23 08:31:42 2011, Anurag Sharma wrote: > > > Hi All, > > > > We are in the process of porting from JBoss to Karaf. In Jboss we have > the > > concept of SARs (Service Archives). They are essentially services having > an > > MBean interface and they have their own lifecycle. > > We are planning to model these as OSGI services. Now we would like to > use > > these OSGI services from camel routes. For example > > Camel Route would be in Bundle A > > OurService would be in Bundle B (and registred with OSGI service > registry). > > > > Q1 - For a camel route to use OurService as an endpoint, do we have to > wrap > > it in a Camel Component interface? > Yes, if you want to access the Service as an camel endpoint, you need to > follow the way of component/endpoint/producer&consumer. > > > > > Q2 - Is NMR the preferred and only way to asynchrounously trigger > camel > > components residing in different bundles. > > NMR can be used across the camel context and bundle out of box. > There are some other camel components which supports to communicate > across the camel context,like camel-vm, camel-jms, camel-cxf etc. > > > > > Q3 - Another option we are considering is to have a wrapper camel > component > > in the same bundle as the route. In the implementation of our camel > > component we can then access the OSGI Service registry to get hold of > > OurService deployed in a seperate bundle. Is this the usual way of > > integrating camel routes with OSGI services? > > It depends on what's you need. if you export your Services as a bean > component, you can use it as the bean component and do lots customer > work yourself. > > > > > > > > > > > -- > > View this message in context: > http://camel.465427.n5.nabble.com/Accessing-OSGI-Services-from-Camel-Routes-tp5015186p5015186.html > > Sent from the Camel - Users mailing list archive at Nabble.com. > > > > > -- > Willem > -- > FuseSource > Web: http://www.fusesource.com > Blog:http://willemjiang.blogspot.com (English) > http://jnn.javaeye.com (Chinese) > Twitter: willemjiang > Weibo: willemjiang > > > -- > If you reply to this email, your message will be added to the discussion > below: > > http://camel.465427.n5.nabble.com/Accessing-OSGI-Services-from-Camel-Routes-tp5015186p5015841.html > To unsubscribe from Accessing OSGI Services from Camel Routes, click > here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5015186&code=YW51cmFnLmRhcy5zaGFybWFAZ21haWwuY29tfDUwMTUxODZ8MTUxNTMzMjQz> > . > NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- View this message in context: http://camel.465427.n5.nabble.com/Accessing-OSGI-Services-from-Camel-Routes-tp5015186p5015909.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Grouping lines while streaming
Thank you Willem. Kind Regards, Anurag On Monday, February 20, 2012, Willem.Jiang [via Camel] wrote: > You can also create a customer processor[1] to combine the list of > object into a String like this > > from("stream:file?fileName=src/data/webservices_20090723_001_trunc.log&groupLines=2") > > .processor(new Processor() { > void process(Exchange exchange) { > Message in = exchange.getIn(); > List lines = in.getBody(); > StringBuffer buffer = new StringBuffer(); > for(Object line:lines) { > buffer.append(line); > buffer.append("\n"); > } > exchange.getOut().setBody(buffer); > } > }). > > On Mon Feb 20 15:55:07 2012, Willem Jiang wrote: > > > It could more easy for user to group the lines if camel-stream > > component can expose the strategy processLine to the client. > > I just fill a JIRA[1] for it > > > > You may need to extends the StreamConsumer yourself to implement such > > of feature at this time. > > > > [1]https://issues.apache.org/jira/browse/CAMEL-5017 > > > > On Mon Feb 20 08:59:09 2012, Anurag Sharma wrote: > >> Hi All, > >> > >> I have a file with million plus records. Each record is of CSV > >> format. Now > >> instead of reading the whole file in memory I would like to stream it > >> record > >> by record , or prefereably bunch N nbr of records in a single message > >> exchange. > >> > >> Following is my route which works OK for streaming it line by line. > >> > >> > >> > from("file:src/data?fileName=webservices_20090723_001_trunc.log&noop=true").split(body().tokenize("\n")).streaming() > > >> > >> .to("seda:input?concurrentConsumers=1") > >> .log("Processing ${id}"); > >> from("seda:input?concurrentConsumers=1") > >> .convertBodyTo(String.class) > >> .unmarshal(csv) > >> .to("bean:LogService?method=doHandleCsvData"); > >> > >> Now if i want to bunch a group of lines together, it appears that > >> there is > >> no group option while streaming from file component. So I decided to > >> try the > >> streaming component as follows: > >> > >> > >> > from("stream:file?fileName=src/data/webservices_20090723_001_trunc.log&groupLines=2") > > >> > >> > >> Now this does group two lines together however it removes the new line > >> seperator. Consequently two records are concatenated in a single list > >> entry > >> when the message arrives at doHandleCsvData. > >> > >> I suppose I can write my own producer within the File component that > >> takes > >> the file handle and streams data out. However I am keen on exploring > the > >> capabilities of the existring components. > >> > >> Would appreciate any help. > >> > >> Thanks& Regards, > >> > >> Anurag > >> > >> > >> -- > >> View this message in context: > >> > http://camel.465427.n5.nabble.com/Grouping-lines-while-streaming-tp5497878p5497878.html > > >> > >> Sent from the Camel - Users mailing list archive at Nabble.com. > >> > > > > > > > > -- > Willem > -- > FuseSource > Web: http://www.fusesource.com > Blog:http://willemjiang.blogspot.com (English) > http://jnn.javaeye.com (Chinese) > Twitter: willemjiang > Weibo: willemjiang > > > > -- > If you reply to this email, your message will be added to the discussion > below: > > http://camel.465427.n5.nabble.com/Grouping-lines-while-streaming-tp5497878p5498832.html > To unsubscribe from Grouping lines while streaming, click > here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5497878&code=YW51cmFnLmRhcy5zaGFybWFAZ21haWwuY29tfDU0OTc4Nzh8MTUxNTMzMjQz> > . > NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- View this message in context: http://camel.465427.n5.nabble.com/Grouping-lines-while-streaming-tp5497878p5505013.html Sent from the Camel - Users mailing list archive at Nabble.com.