Advertisement
Guest User

camelContext

a guest
Sep 20th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:camel="http://camel.apache.org/schema/spring"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans
  6. http://www.springframework.org/schema/beans/spring-beans.xsd
  7. http://camel.apache.org/schema/spring
  8. http://camel.apache.org/schema/spring/camel-spring.xsd">
  9.  
  10. <!-- this is the JDBC data source which uses an in-memory only Apache Derby database -->
  11. <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  12. <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
  13. <property name="url" value="jdbc:mysql://localhost:3306/practice"/>
  14. <property name="username" value="root"/>
  15. <property name="password" value="root"/>
  16. </bean>
  17.  
  18. <!-- setup the Camel hibernate component -->
  19. <bean id="hibernate" class="org.apacheextras.camel.component.hibernate.HibernateComponent">
  20. <property name="sessionFactory" ref="sessionFactory1"/>
  21. <property name="transactionStrategy" ref="springTransactionStrategy"/>
  22. </bean>
  23.  
  24. <!-- setup hibernate and spring to use transaction -->
  25. <bean id="springTransactionStrategy" class="org.apacheextras.camel.component.hibernate.SpringTransactionStrategy">
  26. <constructor-arg ref="sessionFactory1"/>
  27. <constructor-arg ref="transactionTemplate"/>
  28. </bean>
  29. <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
  30. <property name="sessionFactory" ref="sessionFactory1"/>
  31. </bean>
  32. <bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">
  33. <property name="transactionManager" ref="transactionManager"/>
  34. </bean>
  35.  
  36. <!-- setup Hibernate session factory -->
  37. <bean id="sessionFactory1" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  38. <property name="dataSource" ref="dataSource"/>
  39. <!-- here we define the hibernate mapping files we use -->
  40. <property name="mappingResources">
  41. <list>
  42. <value>Student.hbm.xml</value>
  43. </list>
  44. </property>
  45. <!-- and here we have additional hibernate options -->
  46. <property name="hibernateProperties">
  47. <value>
  48. hibernate.dialect=org.hibernate.dialect.MySQLDialect
  49. hibernate.hbm2ddl.auto=create
  50. hibernate.show_sql=true
  51. </value>
  52. </property>
  53. </bean>
  54. <!-- Student bean is our business logic bean that creates new orders -->
  55. <bean id="studentBean" class="nl.camel.hibernate.StudentBean"/>
  56.  
  57. <camelContext xmlns="http://camel.apache.org/schema/spring">
  58.  
  59. <!-- route that generate new orders and insert them in the database -->
  60. <route id="generateStudent-route" xmlns="http://camel.apache.org/schema/spring" autoStartup="false">
  61. <from uri="timer:foo?period=1s"/>
  62. <log message="To check whether route is invoked or not????"/>
  63. <transform>
  64. <method ref="studentBean" method="generatedOrder"/>
  65. </transform>
  66. <to uri="hibernate:nl.camel.hibernate.StudentEntity"/>
  67. <log message="Inserted new order ${body.id}"/>
  68. </route>
  69.  
  70.  
  71. <!-- route that process the orders by picking up new rows from the database
  72. and when done processing then update the row to mark it as processed -->
  73. <route id="processOrder-route">
  74. <from uri="hibernate:nl.camel.hibernate.StudentEntity?delay=1s;flushOnSend=true"/>
  75. <to uri="bean:studentBean?method=retrieveData"/>
  76. <log message="${body}"/>
  77. </route>
  78.  
  79. </camelContext>
  80. </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement