Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:camel="http://camel.apache.org/schema/spring"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://camel.apache.org/schema/spring
- http://camel.apache.org/schema/spring/camel-spring.xsd">
- <!-- this is the JDBC data source which uses an in-memory only Apache Derby database -->
- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="url" value="jdbc:mysql://localhost:3306/practice"/>
- <property name="username" value="root"/>
- <property name="password" value="root"/>
- </bean>
- <!-- setup the Camel hibernate component -->
- <bean id="hibernate" class="org.apacheextras.camel.component.hibernate.HibernateComponent">
- <property name="sessionFactory" ref="sessionFactory1"/>
- <property name="transactionStrategy" ref="springTransactionStrategy"/>
- </bean>
- <!-- setup hibernate and spring to use transaction -->
- <bean id="springTransactionStrategy" class="org.apacheextras.camel.component.hibernate.SpringTransactionStrategy">
- <constructor-arg ref="sessionFactory1"/>
- <constructor-arg ref="transactionTemplate"/>
- </bean>
- <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
- <property name="sessionFactory" ref="sessionFactory1"/>
- </bean>
- <bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">
- <property name="transactionManager" ref="transactionManager"/>
- </bean>
- <!-- setup Hibernate session factory -->
- <bean id="sessionFactory1" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
- <property name="dataSource" ref="dataSource"/>
- <!-- here we define the hibernate mapping files we use -->
- <property name="mappingResources">
- <list>
- <value>Student.hbm.xml</value>
- </list>
- </property>
- <!-- and here we have additional hibernate options -->
- <property name="hibernateProperties">
- <value>
- hibernate.dialect=org.hibernate.dialect.MySQLDialect
- hibernate.hbm2ddl.auto=create
- hibernate.show_sql=true
- </value>
- </property>
- </bean>
- <!-- Student bean is our business logic bean that creates new orders -->
- <bean id="studentBean" class="nl.camel.hibernate.StudentBean"/>
- <camelContext xmlns="http://camel.apache.org/schema/spring">
- <!-- route that generate new orders and insert them in the database -->
- <route id="generateStudent-route" xmlns="http://camel.apache.org/schema/spring" autoStartup="false">
- <from uri="timer:foo?period=1s"/>
- <log message="To check whether route is invoked or not????"/>
- <transform>
- <method ref="studentBean" method="generatedOrder"/>
- </transform>
- <to uri="hibernate:nl.camel.hibernate.StudentEntity"/>
- <log message="Inserted new order ${body.id}"/>
- </route>
- <!-- route that process the orders by picking up new rows from the database
- and when done processing then update the row to mark it as processed -->
- <route id="processOrder-route">
- <from uri="hibernate:nl.camel.hibernate.StudentEntity?delay=1s;flushOnSend=true"/>
- <to uri="bean:studentBean?method=retrieveData"/>
- <log message="${body}"/>
- </route>
- </camelContext>
- </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement