Using StaX to parse xml document into database tables

2013-10-10 Thread richie.rivi...@gmail.com
Hi All, I've just spent a few hours trying to implement a solution and am a bit confused. My use case is that I have an XML document full of items. i.e. . There could be about 100 individual items in the document. I am currently using StAXXPathSplitChoicePerformanceTest.java and StAXJAX

Help to re-write route

2013-10-11 Thread richie.rivi...@gmail.com
Hi guys, I was wondering if someone could give me some help out how to re-write this camel test into a proper camel program. The issue is I know how to write a simple route and then execute it. But after the route is executed and I want to grab the parsed xml in a fashion similar to testStaxExpres

Re: Help to re-write route

2013-10-11 Thread richie.rivi...@gmail.com
No quite. I know that If I want to create a separate class for the route i can do this... public class MyRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { from("file:src/data?noop=true") .split(stax(Recor

Re: Help to re-write route

2013-10-11 Thread richie.rivi...@gmail.com
scrap this question. I'm following the camel-example-etl code from the camel examples instead. thanks -- View this message in context: http://camel.465427.n5.nabble.com/Help-to-re-write-route-tp5741339p5741389.html Sent from the Camel - Users mailing list archive at Nabble.com.

How to write a type converter?

2013-10-15 Thread richie.rivi...@gmail.com
Hi all (sorry in advance for the long post), I have been tweaking the camel-example-etl project to what I require for my project. My requirements are very similar. I need to parse an xml document and then insert the parsed entities as records into the database. The structure of my xml is differen

Re: How to write a type converter?

2013-10-15 Thread richie.rivi...@gmail.com
thanks. This is exactly the type of suggestion I was looking for. Since I'm new to Camel I'm still learning the concepts and different patterns. I'm going to try that right now. Will let you know how I go. -- View this message in context: http://camel.465427.n5.nabble.com/How-to-write-a-type-

Re: How to write a type converter?

2013-10-15 Thread richie.rivi...@gmail.com
I liked your original idea of doing a split so I had a look around and found that chapter 8 in the Camel in Action book had a good example. To split the ItemDocuments what I did was this public void configure() throws Exception { System.err.println("CONVERT STARTED");

Re: JPA type converter for multiple entities?

2013-10-16 Thread richie.rivi...@gmail.com
Just bumping this question as I'm struggling with a solution. If I am trying to persist to three separate entities should my routes specify all three entities? Or is it enough for only the first entity to be specified in the route and then to rely on the relationships defined to the other two bean

Re: JPA type converter for multiple entities?

2013-10-16 Thread richie.rivi...@gmail.com
okay thanks. My main concern is that I am defining my route properly. At the moment I am only defining my route to the item entity and I was thinking maybe because I had not specified the other entities it was using null or something like that. So it seems like from the response my problem is not

JPA component - Persist 1 record working but how to persist many records?

2013-10-26 Thread richie.rivi...@gmail.com
Hi guys, Fairly new to Apache Camel. I have a Camel program which parses some XML using Jaxb and then inserts the parsed objects into the database using open JPA. The example is very similar to the Camel ETL example. At the moment I have the application persisting records from the XML however it i

Re: JPA component - Persist 1 record working but how to persist many records?

2013-10-26 Thread richie.rivi...@gmail.com
Hi All, Well I spent a few hours on this today trying to understand how to do this. What I did was to change my splitter to do this... public List splitItemsRootDocuments(ItemRootDocument doc) { List itemDocuments = doc.getItemDocumentsList(); return itemD

Re: JPA component - Persist 1 record working but how to persist many records?

2013-10-27 Thread richie.rivi...@gmail.com
Thank you so much Taariq, Your advice was exactly what I needed to give me enough information to resolve my issue. public List splitItemsRootDocuments(ItemRootDocument doc) { List items = new ArrayList(); List itemDocumentsList = doc.getItemDocumentsList(

Springws component - beginner

2013-11-14 Thread richie.rivi...@gmail.com
Hi, I am about to embark on setting up my project to call soap web services (magento soap services) and process the responses using spring ws. I am thinking spring ws only because I am very comfortable with spring. I know that there is an example camel-example-spring-ws which says that it exposes

Ideas on how to structure JPA endpoint application

2013-11-16 Thread richie.rivi...@gmail.com
Hi guys, I am looking for some general guidance on how I should structure my JPA endpoint route. i.e. what would be a standard approach to my issue. My camel route parses an XML document containing many items then inserts the items into a db using a JPA enpoint. The way I did this was to structur

Re: Ideas on how to structure JPA endpoint application

2013-11-17 Thread richie.rivi...@gmail.com
Forget this question. I solved it myself. Instead of splitting the ItemDocument into individual items I chose not to split and then in the TypeConverter I just convert everything that I have parsed using JaxB. It seems to be pretty permanent. But I'm still not sure if it's a great idea to just lo

JPA enpoint to CSV enpoint working but only 1 row

2013-11-18 Thread richie.rivi...@gmail.com
Hi all, I have written a route that executes a JPA named query and then marshall's the object into csv... private void configureCsvExportRoute () throws Exception { from(END_POINT_JPA_ITEM_EXPORT) .marshal() .csv() .to(END_POINT_FILE_ITEM_EXPORT);

Execute a spedific route from unix cron

2013-11-28 Thread richie.rivi...@gmail.com
Hi All, I have written a camel application that I would like to execute from the crontab. My application has a main class which looks like ... public class Main extends org.apache.camel.spring.Main { public static void main(String... args) throws Exception { new Main().run(ar

Re: Execute a spedific route from unix cron

2013-11-28 Thread richie.rivi...@gmail.com
Yes your right letting cron right files out is not very nice. I'm not sure about quartz because we didn't really want the application to live. The original idea for us what to just startup our camel app when the routes needed to run. I would have been fine if I only had a single route in my applica

CamelLock file being created and not sure why

2013-11-30 Thread richie.rivi...@gmail.com
Hi, I have a route that grabs files from an input directory, does some operations and then moves files to another directory. The route works well and my file is moved post processing. My issue is that a camelLock file gets left in the source directory after processing. I read somewhere in the cam

Success but still confused about how to shut down my application

2013-11-30 Thread richie.rivi...@gmail.com
Hi All, I've been reading through Camel in action today but am a bit confused about how to shut down my application. I have it working but ultimately my understanding is lacking. My entry point into the application originally looked like below. It loads a spring application context. public class

Re: CamelLock file being created and not sure why

2013-11-30 Thread richie.rivi...@gmail.com
Well I don't know what I did but the problem seems to be gone now. I didn't do anything to fix it. Maybe it was a resource thing relating to me having it open somewhere else? -- View this message in context: http://camel.465427.n5.nabble.com/CamelLock-file-being-created-and-not-sure-why-tp57441

Re: CamelLock file being created and not sure why

2013-11-30 Thread richie.rivi...@gmail.com
actually scrap that. the problem is back...lol -- View this message in context: http://camel.465427.n5.nabble.com/CamelLock-file-being-created-and-not-sure-why-tp5744115p5744118.html Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CamelLock file being created and not sure why

2013-11-30 Thread richie.rivi...@gmail.com
I'm using 2.11. Its strange. Sometime it's happening and other times it doesn't. thanks -- View this message in context: http://camel.465427.n5.nabble.com/CamelLock-file-being-created-and-not-sure-why-tp5744115p5744121.html Sent from the Camel - Users mailing list archive at Nabble.com.

error handling design pattern advice

2013-12-05 Thread richie.rivi...@gmail.com
Hi All, I've got a question about error handling. Here is my scenario... I have a route which calls a bean.. from(...JPA...) .errorHandler(deadLetterChannel("log:dead") .maximumRedeliveries(5) .retryAttemptedLogLevel(LoggingLevel.ERROR)) .to("bean:serviceBean?method=login") .to("bean:serviceBean

Re: error handling design pattern advice

2013-12-10 Thread richie.rivi...@gmail.com
Thanks all for your replies. I have taken Kraythe's advice. Rather than just putting a try catch in createSimpleProduct, in my route I did some splitting so that the createSimpleProduct gets called for each item. I guess I could have just put a try catch in but this way seems to be more of a camel

Apache Camel File component preMove, move and moveFailed relative rather than absolute

2013-12-10 Thread richie.rivi...@gmail.com
Hi guys, I've got a question about preMove, move and moveFailed. PreMove seems to be relative to the input directory and move seems to be relative to the preMove directory. For example if I do a.. from("file:{{dir.item.inbox}}?" + "doneFileName={{filename.item.trig

Inject an endpoint into my route for testing purposes

2013-12-11 Thread richie.rivi...@gmail.com
Hi, Sorry to ask a few questions. I know i have asked a few recently. I have been looking up bean and endpoint injection today but can't find a blurb on my scenario. I have a route which uses a file component as the from endpoint... from("file:{{dir.item.inbox}}?"

Re: Apache Camel File component preMove, move and moveFailed relative rather than absolute

2013-12-11 Thread richie.rivi...@gmail.com
ok. As long as this is the way it is meant to work. thank you. yes making your change worked. -- View this message in context: http://camel.465427.n5.nabble.com/Apache-Camel-File-component-preMove-move-and-moveFailed-relative-rather-than-absolute-tp5744592p5744632.html Sent from the Camel - Use

JPA @Consumed

2013-12-11 Thread richie.rivi...@gmail.com
Hi guys, I have a route which selects from the database using a JPA entity bean. I then do some processing on the bean in the route and would like to mark the bean as processed when the route is complete. Seems like a pretty typical scenario for me to use @Consumed in my entity bean. The select w

Re: JPA @Consumed

2013-12-11 Thread richie.rivi...@gmail.com
I just had a thought whilst walking my dog. In the past when I have got JPA updating the database it has been in a TypeConverter class and what I had to do was . JpaTemplate template = exchange.getIn().getHeader(CamelConstants.HEADER_KEY_JPA_TEMPLATE, JpaTemplate.class); template.persist(item)

Re: JPA @Consumed

2013-12-11 Thread richie.rivi...@gmail.com
Thanks Williem, Changing my route to ... .pollEnrich("jpa://org.apache.camel.auski.etl.entity.ImportPayloadEntity?consumer.namedQuery=queryImportPayloads&consumeDelete=false&delay=3000&consumeLockEntity=false") worked!!! But still a bit of a problem.. The ImportPayloadEntity contains a list of

Re: JPA @Consumed

2013-12-11 Thread richie.rivi...@gmail.com
Maybe the pattern is to just have ImportPayloadEntity @Consumed loop through it's collection of ItemEntity classes and mark them all as processed. I just tried this and it worked (although I'm not sure it's the right pattern). thanks -- View this message in context: http://camel.465427.n5.nabb

Re: JPA @Consumed

2013-12-11 Thread richie.rivi...@gmail.com
Abother question about @Consumed. Using the strategy as described in my last post, what I am doing in selecting an ImportPayloadEntity, splitting this entity which has a list of ItemEntities into individual ItemEntity objects and processing each ItemEntity object. During the processing of each Ite

First CamelSpringTestSupport unit test - AdviceWith - No consumers available on endpoint

2013-12-12 Thread richie.rivi...@gmail.com
Hi guys, Thanks for the advice on a previous post asking about how to change the route of an application for the purposes of testing. Since that time I have gone and done some research into using adviceWith and given it a go. It seems to be working for me but I'm getting an error whilst executing

Re: First CamelSpringTestSupport unit test - AdviceWith - No consumers available on endpoint

2013-12-12 Thread richie.rivi...@gmail.com
Hi, Yes i think you may have missed the first part of the post where I describe the original route. It definitely has a from(“direct:itemExport”). So you think it can't find the route? -- View this message in context: http://camel.465427.n5.nabble.com/First-CamelSpringTestSupport-unit-test-Ad

Re: JPA when is @Consumed called - timing of it

2013-12-12 Thread richie.rivi...@gmail.com
Actually I think I know the issue here. I'm guessing is probably related to the timing that the @consume method is called. In my route I don't set the workingProcessedIndicator on the ItemEntity until the very end of the route using my Bean createSimpleItem method. Perhaps when the @consume method

Ideas on how to structure route (alternatives to direct:...)

2013-12-13 Thread richie.rivi...@gmail.com
Hi All, I've got two main routes in my application. An import route and an export route. At the end of my import route i say... .to("direct:import"); Then at the start of my export i say ... .from("direct:import") Pretty standard stuff. Yesterday I had to change my application to run about 5 p

Re: Ideas on how to structure route (alternatives to direct:...)

2013-12-13 Thread richie.rivi...@gmail.com
the mullticast example you posted looks good. I thought multi cast was just for parallel. Now that I know it's not i'll look into it. So with the multicast example you posted does it do them in order? I'll have a read of doco. Here are the post processing routes... public void configure()

SQL component issue - infinite loop

2013-09-16 Thread richie.rivi...@gmail.com
Hi All, I currently having issues with the SQL component in my camel project. I was using the stack overflow forum to try and get some help but haven't been able to get any yet and then I discovered these forums. My camel project uses Spring DSL. It has multiple routes specified in a route contex

Cam JDBC component help

2013-09-16 Thread richie.rivi...@gmail.com
Hi all, Apologies for the beginner question but I'm trying to get a new project going from the examples I have seen and read (Spring DSL). I'm trying to use the camel jdbc component to do a select from database 1 and insert into db2. I've got my select working as per below

Re: SQL component issue - infinite loop

2013-09-16 Thread richie.rivi...@gmail.com
woo hoo. Thanks for helping me with this... I'm so glad. Would it be better if I make my project available on github so you can grab it as a zip? regards -- View this message in context: http://camel.465427.n5.nabble.com/SQL-component-issue-infinite-loop-tp5739486p5739583.html Sent from the

Re: SQL component issue - infinite loop

2013-09-17 Thread richie.rivi...@gmail.com
Hi, I've posted the small project to github and you can grab a zip of it at... https://github.com/rriviere/camel-example-sql Really appreciate your help. regards -- View this message in context: http://camel.465427.n5.nabble.com/SQL-component-issue-infinite-loop-tp5739486p5739620.html Sent

Re: SQL component issue - infinite loop

2013-09-18 Thread richie.rivi...@gmail.com
Hi Costa, Yes you are correct, what you are looking at is what I have described in my post where I say "Tonight I also tried to separate the routes out into different route contexts but it didn't change anything". I've found the way I have structured it with multiple route contexts a bit more co