blob: 6b2b5c8d42b52c7c006b18ebe69517c14bf6c364 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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">
<!-- START SNIPPET: e1 -->
<!-- this example uses JDBC so we define a data source -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
<property name="url" value="jdbc:hsqldb:mem:camel"/>
<property name="username" value="sa"/>
<property name="password" value=""/>
</bean>
<!-- spring transaction manager -->
<!-- this is the transaction manager Camel will use for transacted routes -->
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- bean for book business logic -->
<bean id="bookService" class="org.apache.camel.spring.interceptor.BookService">
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- END SNIPPET: e1 -->
<!-- START SNIPPET: e2 -->
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:okay"/>
<!-- we mark this route as transacted. Camel will lookup the spring transaction manager
and use it by default. We can optimally pass in arguments to specify a policy to use
that is configured with a spring transaction manager of choice. However Camel supports
convention over configuration as we can just use the defaults out of the box and Camel
that suites in most situations -->
<transacted/>
<setBody>
<constant>Tiger in Action</constant>
</setBody>
<bean ref="bookService"/>
<setBody>
<constant>Elephant in Action</constant>
</setBody>
<bean ref="bookService"/>
</route>
<route>
<from uri="direct:fail"/>
<!-- we mark this route as transacted. See comments above. -->
<transacted/>
<setBody>
<constant>Tiger in Action</constant>
</setBody>
<bean ref="bookService"/>
<setBody>
<constant>Donkey in Action</constant>
</setBody>
<bean ref="bookService"/>
</route>
</camelContext>
<!-- END SNIPPET: e2 -->
</beans>