blob: 898c799a241183c12bc4e4e1f3e3119c360d9fd6 [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:camel="http://camel.apache.org/schema/spring"
xmlns:broker="http://activemq.apache.org/schema/core"
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
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd">
<!-- jdbc idempotent repository -->
<bean id="messageIdRepository" class="org.apache.camel.processor.idempotent.jdbc.JdbcMessageIdRepository">
<constructor-arg index="0" ref="myNonXADataSource"/>
<constructor-arg index="1" value="myProcessor"/>
</bean>
<!-- use required TX -->
<bean id="requiredTemplate" class="org.springframework.transaction.support.TransactionTemplate">
<property name="transactionManager" ref="jmsTransactionManager"/>
</bean>
<bean id="required" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<property name="transactionTemplate" ref="requiredTemplate"/>
</bean>
<!-- this is the Spring JmsTransactionManager which under the hood uses Atomikos -->
<bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager" depends-on="my-broker">
<property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>
<!-- Is the ConnectionFactory to connect to the JMS broker -->
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="my-broker">
<property name="brokerURL" value="tcp://localhost:61616"/>
</bean>
<!-- define the activemq Camel component so we can integrate with the AMQ broker below -->
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" depends-on="my-broker">
<!-- must indicate that we use transacted acknowledge mode -->
<property name="transacted" value="true"/>
<!-- refer to the transaction manager -->
<property name="transactionManager" ref="jmsTransactionManager"/>
</bean>
<!-- setup a local JMS Broker for testing purpose -->
<broker:broker id="my-broker" useJmx="false" persistent="false" brokerName="localhost">
<broker:transportConnectors>
<broker:transportConnector uri="tcp://localhost:61616"/>
</broker:transportConnectors>
</broker:broker>
<!-- datasource used to create the database tables -->
<bean id="myNonXADataSource" class="org.springframework.jdbc.datasource.SingleConnectionDataSource" destroy-method="destroy">
<property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
<property name="url" value="jdbc:hsqldb:mem:mydatabase"/>
<property name="username" value="sa"/>
<property name="password" value=""/>
</bean>
</beans>