Hi Stephen,

attached is a small junit test case that demonstrates a rollback on a JMS
session. Unfortunatly, I could send a zip file containing a running project
because it is rejected by the spam filter. So I attached the files
separately. The test case writes the redelivered message exchanges to
stdout.

Cheers,
Martin


> -----Ursprüngliche Nachricht-----
> Von: Stephen J [mailto:[EMAIL PROTECTED]
> Gesendet: Mittwoch, 30. Januar 2008 21:54
> An: [email protected]
> Betreff: Re: AW: AW: JMS Transactions - How To
> 
> 
> The configuration you suggested doesn't seem to work for me. I check it
> using
> both mqseries and activemq and in both cases the message was consumed even
> when an exception was thrown in the processing code.
> 
> Is there a specific way I need to configure my queues to handle
> transactions?
> 
> Thanks for your help.
> 
> --
> View this message in context: http://www.nabble.com/JMS-Transactions---
> How-To-tp15168958s22882p15191800.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

<?xml version="1.0" encoding="UTF-8"?>
<beans>
  <broker useJmx="false"  xmlns="http://activemq.org/config/1.0"; persistent="false" brokerName="localhost" />
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<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-2.0.xsd
http://activemq.apache.org/camel/schema/spring 
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd";>

  <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"; />

  <bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
      <property name="connectionFactory" ref="jmsConnectionFactory"/> 
      <property name="transactionManager" ref="jmsTransactionManager"/> 
      <property name="transacted" value="true"/> 
  </bean>

  <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent">
  	<property name="configuration" ref="jmsConfig" />
  </bean>

  <bean id="PROPAGATION_REQUIRED" class="org.springframework.transaction.support.TransactionTemplate">
    <property name="transactionManager" ref="jmsTransactionManager"/>
  </bean>
  
  <bean id="PROPAGATION_NOT_SUPPORTED" class="org.springframework.transaction.support.TransactionTemplate">
    <property name="transactionManager" ref="jmsTransactionManager"/>
    <property name="propagationBehaviorName" value="PROPAGATION_NOT_SUPPORTED"/>
  </bean>

  <bean id="PROPAGATION_REQUIRES_NEW" class="org.springframework.transaction.support.TransactionTemplate">
    <property name="transactionManager" ref="jmsTransactionManager"/>
    <property name="propagationBehaviorName" value="PROPAGATION_REQUIRES_NEW"/>
  </bean>

  <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
    <property name="connectionFactory" ref="jmsConnectionFactory" />
  </bean>
  
  <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="broker">
    <property name="brokerURL" value="vm://localhost"/>
  </bean>

  <bean id="broker" class="org.apache.activemq.xbean.BrokerFactoryBean">
    <property name="config" value="/activemq.xml"/>
  </bean>

</beans>
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns="http://maven.apache.org/POM/4.0.0";>

	<modelVersion>4.0.0</modelVersion>
	<groupId>dev.sandbox.camel</groupId>
	<artifactId>tx</artifactId>
	<version>1.0-SNAPSHOT</version>
	<name>tx</name>
	<build>
	    <plugins>
	       <plugin>
	           <groupId>org.apache.maven.plugins</groupId>
	           <artifactId>maven-compiler-plugin</artifactId>
	           <configuration>
	               <source>1.5</source>
	               <target>1.5</target>
	           </configuration>
	       </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.3</version>
				<configuration>
					<includes>
						<include>**/RollbackExample.java</include>
					</includes>
				</configuration>
            </plugin>
	    </plugins>
	</build>

	<dependencies>
		<dependency>
			<groupId>org.apache.camel</groupId>
			<artifactId>camel-core</artifactId>
			<version>1.2.0</version>
		</dependency>
		<dependency>
			<groupId>org.apache.camel</groupId>
			<artifactId>camel-spring</artifactId>
			<version>1.2.0</version>
		</dependency>
		<dependency>
			<groupId>org.apache.camel</groupId>
			<artifactId>camel-script</artifactId>
			<version>1.2.0</version>
		</dependency>
		<dependency>
			<groupId>org.apache.camel</groupId>
			<artifactId>camel-groovy</artifactId>
			<version>1.2.0</version>
		</dependency>
		<dependency>
			<groupId>org.apache.camel</groupId>
			<artifactId>camel-jms</artifactId>
			<version>1.2.0</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring</artifactId>
			<version>2.0.6</version>
		</dependency>
		<dependency>
			<groupId>org.apache.activemq</groupId>
			<artifactId>apache-activemq</artifactId>
			<version>4.1.1</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.4</version>
			<scope>test</scope>
		</dependency>
	</dependencies>
</project>

Reply via email to