newbie question, running camel-example-hibernate

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

newbie question, running camel-example-hibernate

pixelpshr
This is my first exposure to the camel-extras project, and I'm having trouble with my first test of the hibernate example. I cloned the project from GitHub received the 2.16.2 version. I was able to compile and install the camel-hibernate component. I could also compile the camel-example-hibernate example. But, when I try to "man camel:run", I get a failure. I think the relevant section of the error output is:

=================

[INFO] --- camel-maven-plugin:2.16.2:run (default-cli) @ camel-example-hibernate ---
[INFO] Using org.apache.camel.spring.Main to initiate a CamelContext
[INFO] Starting Camel ...
[pache.camel.spring.Main.main()] Version                        INFO  HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
[pache.camel.spring.Main.main()] Version                        INFO  HHH000412: Hibernate Core {4.2.20.Final}
[pache.camel.spring.Main.main()] Environment                    INFO  HHH000206: hibernate.properties not found
[pache.camel.spring.Main.main()] Environment                    INFO  HHH000021: Bytecode provider name : javassist
[pache.camel.spring.Main.main()] ClassPathXmlApplicationContext WARN  Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernate' defined in file [/Users/tdecarlo/NetBeansProjects/camel-extra/examples/camel-example-hibernate/target/classes/META-INF/spring/camel-context.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [/Users/tdecarlo/NetBeansProjects/camel-extra/examples/camel-example-hibernate/target/classes/META-INF/spring/camel-context.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Unable to read XML
[pache.camel.spring.Main.main()] SpringCamelContext             INFO  Apache Camel 2.16.2 (CamelContext: camel-1) is shutting down
[pache.camel.spring.Main.main()] SpringCamelContext             INFO  Apache Camel 2.16.2 (CamelContext: camel-1) uptime
[pache.camel.spring.Main.main()] SpringCamelContext             INFO  Apache Camel 2.16.2 (CamelContext: camel-1) is shutdown in 0.007 seconds

================

I was also able to compile and install the entire camel-extra tree, but it didn't change the result of trying to run the hibernate example.

Can anyone tell me what I'm doing wrong here?

Thanks,
Thom
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: newbie question, running camel-example-hibernate

pixelpshr
It turned out that many of my initial problems were solved when the update to Camel 2.17.2 was pushed up the the camel-extra github repo. I still needed to modify the installation a little bit, to update to Hibernate 5.2.1 and Spring 4.3.1. I also swapped the update rates of the two routes so the generateOrder-route runs every second and the processOrder-route runs every 5 seconds. That let me see what was actually happening to the database as the program was run.

I put my changes into my fork of the camel-extra project and submitted a pull-request.

There are still a couple problems with the camel-example-hibernate example, though.

1 - The comment in the camel-context.xml file says:
   

But, no... this is not really true. It actually pulls the rows from the database and deletes them. We definitely need something different to mark the row and leave it in the database. Adding the "consumeDelete=false" to the uri tells camel to leave the row in the database. Except that it only works for the first two passes through the processOrder-route. After it reads the database for the second time, all rows are deleted. So, the "consumeDelete" flag seems to be broken.

Also, it does not do anything to mark the database rows as having been processed. It looks like that will require changing the "processOrder()" java function to add an "@Consumed" annotation, plus code to change the database row.

2 - For some reason, two generateOrder-route threads are created when the program runs. My output looks like this:

[pache.camel.spring.Main.main()] SpringCamelContext             INFO  Route: generateOrder-route started and consuming from: Endpoint[timer://foo?period=1s]
[pache.camel.spring.Main.main()] SpringCamelContext             INFO  Route: processOrder-route started and consuming from: Endpoint[hibernate://org.apacheextras.camel.examples.hibernate.Order?consumeDelete=false&delay=5s&initialDelay=5s]
[pache.camel.spring.Main.main()] SpringCamelContext             INFO  Total 2 routes, of which 2 are started.
[pache.camel.spring.Main.main()] SpringCamelContext             INFO  Apache Camel 2.17.2 (CamelContext: camel-2) started in 0.039 seconds
[mel-1) thread #1 - timer://foo] generateOrder-route            INFO  Inserted new order 1
[mel-2) thread #3 - timer://foo] generateOrder-route            INFO  Inserted new order 2
[mel-1) thread #1 - timer://foo] generateOrder-route            INFO  Inserted new order 3
[mel-2) thread #3 - timer://foo] generateOrder-route            INFO  Inserted new order 4
[mel-1) thread #1 - timer://foo] generateOrder-route            INFO  Inserted new order 5
[mel-2) thread #3 - timer://foo] generateOrder-route            INFO  Inserted new order 6
[mel-1) thread #1 - timer://foo] generateOrder-route            INFO  Inserted new order 7
[mel-2) thread #3 - timer://foo] generateOrder-route            INFO  Inserted new order 8
[mel-1) thread #1 - timer://foo] generateOrder-route            INFO  Inserted new order 9
[camel.examples.hibernate.Order] ueryTranslatorFactoryInitiator INFO  HHH000397: Using ASTQueryTranslatorFactory
[mel-2) thread #3 - timer://foo] generateOrder-route            INFO  Inserted new order 10
[camel.examples.hibernate.Order] processOrder-route             INFO  Processed order id 1 item 222 of 10 copies of ActiveMQ in Action
[camel.examples.hibernate.Order] processOrder-route             INFO  Processed order id 2 item 111 of 10 copies of Camel in Action
[camel.examples.hibernate.Order] processOrder-route             INFO  Processed order id 3 item 222 of 1 copies of ActiveMQ in Action
[camel.examples.hibernate.Order] processOrder-route             INFO  Processed order id 4 item 111 of 6 copies of Camel in Action
[camel.examples.hibernate.Order] processOrder-route             INFO  Processed order id 5 item 222 of 5 copies of ActiveMQ in Action
[camel.examples.hibernate.Order] processOrder-route             INFO  Processed order id 6 item 111 of 9 copies of Camel in Action
[camel.examples.hibernate.Order] processOrder-route             INFO  Processed order id 7 item 222 of 4 copies of ActiveMQ in Action
[camel.examples.hibernate.Order] processOrder-route             INFO  Processed order id 8 item 111 of 3 copies of Camel in Action
[camel.examples.hibernate.Order] processOrder-route             INFO  Processed order id 9 item 222 of 10 copies of ActiveMQ in Action
[camel.examples.hibernate.Order] processOrder-route             INFO  Processed order id 10 item 111 of 2 copies of Camel in Action




Loading...