If you are using JBoss JCA then so long as you wire up the ActiveMQ RA
with JBoss you should just use the JBoss ConnectionFactory proxy that
its JCA provider creates with your JmsTemplate - then wire Spring's TM
with JBoss's.


On 8/21/06, PeterNilsson <[EMAIL PROTECTED]> wrote:

Hi,

The RA is deployed as follows:
- The activemq-ra-4.0.1.rar is copied unchanged from lib/optional in the
ActiveMQ distribution to the jboss-4.0.2\server\default\deploy directory in
JBoss.
- An activemq-ds.xml file is put in the same directory. The contents are at
the bottom of my original mail.
- The connection factory is registered with JBoss by the following
jboss-service.xml in the META-INF directory of the application:
  <?xml version="1.0" encoding="UTF-8"?>
  <server>
    <mbean code="com.omxgroup.esb.jmx.AppContextInitializer"
name="omx:service=AppContextInitializer">
      <attribute
name="AppContextFileName">applicationContext.xml</attribute>

<depends>jboss.jca:service=DataSourceBinding,name=MSSQL_XA_DS</depends>

<depends>jboss.jca:service=ConnectionFactoryBinding,name=kodo</depends>

<depends>jboss.jca:service=ConnectionFactoryBinding,name=activemq/QueueConnectionFactory</depends>
    </mbean>
  </server>
The AppContextInitializer class simply sets up a Spring application context
for our application while the depends tags are used for registering the
resources.

Do I need to wire the AMQ RA explicitly with the Spring TM? I was under the
impression that if a global transaction is active the session will join it:
"As defined by the J2EE specification, the transaction and acknowledgement
parameters are ignored when a JMS Session is created inside an active
transaction, no matter if a JTA transaction or a Spring-managed
transaction." from JmsTemplate API. If this isn't the case how do I connect
AMQ to Spring TM?

   Peter



James.Strachan wrote:
>
> How are you registering the RA with JBoss and how are you wiring the
> RA with the Spring TM? A test case would be handy to see what you are
> doing.
>
> On 8/16/06, PeterNilsson <[EMAIL PROTECTED]> wrote:
>>
>> Hi,
>>
>> I can't manage to get my outbound Jms messages to be enlisted in the JTA
>> transaction. My testcase does some database access, sends a JMS message
>> and
>> the throws an exception which causes rollback. Despite the rollback the
>> message is sent and what I can see from the log the session is not
>> enlisted
>> in the JTA tx.
>> I am using Spring JtaTransactionManger with a JNDI ref to the JBoss
>> transaction manager. I am using the ActiveMQ ra which is deployed to
>> JBoss.
>> The relevant parts of configuration are after the log file below.
>>
>> Any hints on what need to be changed?
>>
>>    br,
>>
>>    Peter Nilsson
>>
>> Part of log file:
>> 2006-08-16 10:03:54,556 DEBUG
>> [org.apache.activemq.transport.WireFormatNegotiator] Sending:
>> WireFormatInfo
>> { version=1, properties={TightEncodingEnabled=true,
>> TcpNoDelayEnabled=true,
>> SizePrefixDisabled=false, StackTraceEnabled=true,
>> MaxInactivityDuration=30000, CacheEnabled=true}, magic=[A,c,t,i,v,e,M,Q]}
>> 2006-08-16 10:03:54,556 DEBUG
>> [org.apache.activemq.transport.tcp.TcpTransport] TCP consumer thread
>> starting
>> 2006-08-16 10:03:54,556 DEBUG
>> [org.apache.activemq.transport.WireFormatNegotiator] Received WireFormat:
>> WireFormatInfo { version=1, properties={StackTraceEnabled=true,
>> TightEncodingEnabled=true, TcpNoDelayEnabled=true,
>> SizePrefixDisabled=false,
>> MaxInactivityDuration=30000, CacheEnabled=true}, magic=[A,c,t,i,v,e,M,Q]}
>> 2006-08-16 10:03:54,556 DEBUG
>> [org.apache.activemq.transport.WireFormatNegotiator]
>> tcp:///127.0.0.1:2181
>> before negotiation: OpenWireFormat{version=1, cacheEnabled=false,
>> stackTraceEnabled=false, tightEncodingEnabled=false,
>> sizePrefixDisabled=false}
>> 2006-08-16 10:03:54,556 DEBUG
>> [org.apache.activemq.transport.WireFormatNegotiator]
>> tcp:///127.0.0.1:2181
>> after negotiation: OpenWireFormat{version=1, cacheEnabled=true,
>> stackTraceEnabled=true, tightEncodingEnabled=true,
>> sizePrefixDisabled=false}
>> # Starting jta transaction
>> 2006-08-16 10:03:54,967 DEBUG
>> [org.springframework.transaction.interceptor.TransactionInterceptor]
>> Getting
>> transaction for
>> com.omxgroup.bb.bong.ws.xatester.XATester.createPartyAndSendAndRollback
>> 2006-08-16 10:03:54,967 DEBUG
>> [org.springframework.transaction.jta.JtaTransactionManager] Using
>> transaction object
>> [EMAIL PROTECTED]
>> 2006-08-16 10:03:54,967 DEBUG
>> [org.springframework.transaction.jta.JtaTransactionManager] Creating new
>> transaction with name
>> [com.omxgroup.bb.bong.ws.xatester.XATester.createPartyAndSendAndRollback]
>> 2006-08-16 10:03:54,967 DEBUG
>> [org.springframework.transaction.jta.JtaTransactionManager] Beginning JTA
>> transaction
>> 2006-08-16 10:03:54,967 DEBUG
>> [org.springframework.transaction.support.TransactionSynchronizationManager]
>> Initializing transaction synchronization
>> # Do business logic including database access
>> 2006-08-16 10:03:54,967 DEBUG
>> [org.springframework.transaction.support.TransactionSynchronizationManager]
>> Bound value [EMAIL PROTECTED] for key [class
>> com.omxgroup.bb.bong.framework.persistence.JdoPmFactorySingleton] to
>> thread
>> [Thread-108]
>> 2006-08-16 10:03:54,967 DEBUG
>> [org.springframework.transaction.support.TransactionSynchronizationManager]
>> Retrieved value [EMAIL PROTECTED] for key
>> [class
>> com.omxgroup.bb.bong.framework.persistence.JdoPmFactorySingleton] bound
>> to
>> thread [Thread-108]
>> 2006-08-16 10:03:54,967 DEBUG
>> [org.springframework.orm.jdo.PersistenceManagerFactoryUtils] Opening JDO
>> PersistenceManager
>> 2006-08-16 10:03:54,967 DEBUG
>> [org.springframework.orm.jdo.PersistenceManagerFactoryUtils] Registering
>> transaction synchronization for JDO PersistenceManager
>> 2006-08-16 10:03:54,967 DEBUG
>> [org.springframework.transaction.support.TransactionSynchronizationManager]
>> Bound value [EMAIL PROTECTED]
>> for key [EMAIL PROTECTED] to thread
>> [Thread-108]
>> 2006-08-16 10:03:54,967 DEBUG
>> [org.springframework.transaction.support.TransactionSynchronizationManager]
>> Retrieved value [EMAIL PROTECTED] for key
>> [class
>> com.omxgroup.bb.bong.framework.persistence.JdoPmFactorySingleton] bound
>> to
>> thread [Thread-108]
>> 2006-08-16 10:03:54,967 DEBUG
>> [org.springframework.transaction.support.TransactionSynchronizationManager]
>> Retrieved value
>> [EMAIL PROTECTED] for key
>> [EMAIL PROTECTED] bound to thread
>> [Thread-108]
>> # Send jms message
>> 2006-08-16 10:03:54,987 DEBUG [org.springframework.jms.core.JmsTemplate]
>> Executing callback on JMS Session [ManagedSessionProxy { ActiveMQSession
>> {id=ID:SE10LT1240-2147-1155715337754-12:22:2,started=false} }] from
>> connection [EMAIL PROTECTED]
>> 2006-08-16 10:03:54,987 DEBUG [org.springframework.jms.core.JmsTemplate]
>> Sending created message [ActiveMQTextMessage {commandId = 0,
>> responseRequired = false, messageId = null, originalDestination = null,
>> originalTransactionId = null, producerId = null, destination = null,
>> transactionId = null, expiration = 0, timestamp = 0, arrival = 0,
>> correlationId = null, replyTo = null, persistent = false, type = null,
>> priority = 0, groupID = null, groupSequence = 0, targetConsumerId = null,
>> compressed = false, userID = null, content = null, marshalledProperties =
>> null, dataStructure = null, redeliveryCounter = 0, size = 0, properties =
>> {JMS_DESTINATION=XA_ROUTED}, readOnlyProperties = false, readOnlyBody =
>> false, text = <?xml version="1.0"
>> encoding="UTF-8"?><ns4:PartyAndPartyRolesNDO
>> xmlns:ns4="http://www.omxgroup.com/bb/bong/ndo/party";
>> xmlns:ns2="http://www.omxgroup.com/bb/bong/ws/xatester";
>> 
xmlns:ns3="http://www.omxgroup.com/bb/bong/ndo/sapbp";><Individual><Id><IdentifierType>SPS</IdentifierType><ObjectType>PARTY</ObjectType><Value>802</Value></Id><Name>Boris
>> Becker</Name><Address><Type>OFFICIAL_ADDRESS</Type><Line1>Upplandsgatan
>> 56</Line1><Line2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> xsi:nil="true"/><Line3
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> xsi:nil="true"/><PostalCode>113
>> 
28</PostalCode><City>Stockholm</City><Country>SE</Country></Address><Status>NORMAL</Status><OwnedBy
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> 
xsi:nil="true"/><TaxStatus>NORMAL</TaxStatus><TaxPercentage>0.45</TaxPercentage><LegalEntity
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> 
xsi:nil="true"/><ManagedBy><IdentifierType>SPS</IdentifierType><ObjectType>PARTY_ROLE</ObjectType><Value>0</Value></ManagedBy><ReportLanguage>EN</ReportLanguage><Template>false</Template><MemberOf><Id><IdentifierType>SPS</IdentifierType><ObjectType>CATEGORY</ObjectType><Value>0</Value></Id></MemberOf><ExtraIdentifiers><IdentifierType>SE_PIN</IdentifierType><ObjectType>PARTY</ObjectType><Value>681201-5555</Value></ExtraIdentifiers><Firstname>Boris</Firstname><Lastname>Becker</Lastname><Title
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> 
xsi:nil="true"/><TaxDomicile>SE</TaxDomicile><Nationality>SE</Nationality><PlaceOfBirth>Düsseldorf</PlaceOfBirth><DateOfBirth>1974-01-03</DateOfBirth></Individual><CustomerRole><Id><IdentifierType>SPS</IdentifierType><ObjectType>PARTY_ROLE</ObjectType><Value>803</Value></Id><Status>ACTIVE</Status><Comment
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> xsi:nil="true"/><Verified>false</Verified><ContactInfo
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> 
xsi:nil="true"/><AcceptsMarketInfo>false</AcceptsMarketInfo></CustomerRole></ns4:PartyAndPartyRolesNDO>}]
>> 2006-08-16 10:03:54,987 DEBUG [org.apache.activemq.ActiveMQSession]
>> Sending
>> message: ActiveMQTextMessage {commandId = 0, responseRequired = false,
>> messageId = ID:SE10LT1240-2147-1155715337754-12:22:2:1:1,
>> originalDestination = null, originalTransactionId = null, producerId =
>> ID:SE10LT1240-2147-1155715337754-12:22:2:1, destination =
>> queue://XA_ROUTED,
>> transactionId = null, expiration = 0, timestamp = 1155715434987, arrival
>> =
>> 0, correlationId = null, replyTo = null, persistent = true, type = null,
>> priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,
>> compressed = false, userID = null, content = null, marshalledProperties =
>> null, dataStructure = null, redeliveryCounter = 0, size = 0, properties =
>> {JMS_DESTINATION=XA_ROUTED}, readOnlyProperties = true, readOnlyBody =
>> true,
>> text = <?xml version="1.0" encoding="UTF-8"?><ns4:PartyAndPartyRolesNDO
>> xmlns:ns4="http://www.omxgroup.com/bb/bong/ndo/party";
>> xmlns:ns2="http://www.omxgroup.com/bb/bong/ws/xatester";
>> 
xmlns:ns3="http://www.omxgroup.com/bb/bong/ndo/sapbp";><Individual><Id><IdentifierType>SPS</IdentifierType><ObjectType>PARTY</ObjectType><Value>802</Value></Id><Name>Boris
>> Becker</Name><Address><Type>OFFICIAL_ADDRESS</Type><Line1>Upplandsgatan
>> 56</Line1><Line2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> xsi:nil="true"/><Line3
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> xsi:nil="true"/><PostalCode>113
>> 
28</PostalCode><City>Stockholm</City><Country>SE</Country></Address><Status>NORMAL</Status><OwnedBy
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> 
xsi:nil="true"/><TaxStatus>NORMAL</TaxStatus><TaxPercentage>0.45</TaxPercentage><LegalEntity
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> 
xsi:nil="true"/><ManagedBy><IdentifierType>SPS</IdentifierType><ObjectType>PARTY_ROLE</ObjectType><Value>0</Value></ManagedBy><ReportLanguage>EN</ReportLanguage><Template>false</Template><MemberOf><Id><IdentifierType>SPS</IdentifierType><ObjectType>CATEGORY</ObjectType><Value>0</Value></Id></MemberOf><ExtraIdentifiers><IdentifierType>SE_PIN</IdentifierType><ObjectType>PARTY</ObjectType><Value>681201-5555</Value></ExtraIdentifiers><Firstname>Boris</Firstname><Lastname>Becker</Lastname><Title
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> 
xsi:nil="true"/><TaxDomicile>SE</TaxDomicile><Nationality>SE</Nationality><PlaceOfBirth>Düsseldorf</PlaceOfBirth><DateOfBirth>1974-01-03</DateOfBirth></Individual><CustomerRole><Id><IdentifierType>SPS</IdentifierType><ObjectType>PARTY_ROLE</ObjectType><Value>803</Value></Id><Status>ACTIVE</Status><Comment
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> xsi:nil="true"/><Verified>false</Verified><ContactInfo
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>> 
xsi:nil="true"/><AcceptsMarketInfo>false</AcceptsMarketInfo></CustomerRole></ns4:PartyAndPartyRolesNDO>}
>> 2006-08-16 10:03:55,027 DEBUG
>> [org.apache.activemq.store.journal.JournalMessageStore] Journalled
>> message
>> add for: ID:SE10LT1240-2147-1155715337754-12:22:2:1:1, at: 0:52247
>> 2006-08-16 10:03:55,047 DEBUG
>> [org.springframework.transaction.support.TransactionSynchronizationManager]
>> Removed value [EMAIL PROTECTED] for key
>> [class
>> com.omxgroup.bb.bong.framework.persistence.JdoPmFactorySingleton] from
>> thread [Thread-108]
>> # Throw an exception to force rollback
>> 2006-08-16 10:03:55,047 ERROR [service] Exit
>> XATesterImpl.createPartyAndSendAndRollback() exception:
>> java.lang.RuntimeException: Explicitly thrown exception.
>> 2006-08-16 10:03:55,047 DEBUG
>> [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute]
>> Applying rules to determine whether transaction should rollback on
>> com.omxgroup.bb.bong.framework.errorhandling.SystemException
>> 2006-08-16 10:03:55,047 DEBUG
>> [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute]
>> Winning rollback rule is: null
>> 2006-08-16 10:03:55,047 DEBUG
>> [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute]
>> No relevant rollback rule found: applying superclass default
>> 2006-08-16 10:03:55,047 DEBUG
>> [org.springframework.transaction.interceptor.TransactionInterceptor]
>> Invoking rollback for transaction on
>> com.omxgroup.bb.bong.ws.xatester.XATester.createPartyAndSendAndRollback
>> due
>> to throwable
>> [com.omxgroup.bb.bong.framework.errorhandling.SystemException]
>> 2006-08-16 10:03:55,047 DEBUG
>> [org.springframework.transaction.jta.JtaTransactionManager] Triggering
>> beforeCompletion synchronization
>> 2006-08-16 10:03:55,047 DEBUG
>> [org.springframework.transaction.support.TransactionSynchronizationManager]
>> Removed value
>> [EMAIL PROTECTED]
>> for key [EMAIL PROTECTED] from thread
>> [Thread-108]
>> 2006-08-16 10:03:55,047 DEBUG
>> [org.springframework.orm.jdo.PersistenceManagerFactoryUtils] Closing JDO
>> PersistenceManager
>> 2006-08-16 10:03:55,047 DEBUG
>> [org.springframework.transaction.jta.JtaTransactionManager] Initiating
>> transaction rollback
>> 2006-08-16 10:03:55,047 DEBUG
>> [org.springframework.transaction.jta.JtaTransactionManager] Rolling back
>> JTA
>> transaction
>> 2006-08-16 10:03:55,047 DEBUG
>> [org.springframework.transaction.jta.JtaTransactionManager] Triggering
>> afterCompletion synchronization
>> 2006-08-16 10:03:55,047 DEBUG
>> [org.springframework.transaction.support.TransactionSynchronizationManager]
>> Clearing transaction synchronization
>>
>> Relevant Spring configuration:
>> <bean id="baseJdoTransactionInterceptor" abstract="true"
>>
>> class="org.springframework.transaction.interceptor.TransactionInterceptor">
>>   <property name="transactionManager">
>>     <bean
>> class="org.springframework.transaction.jta.JtaTransactionManager">
>>       <property name="userTransactionName">
>>         <null/>
>>       </property>
>>       <property name="transactionManager" ref="txManager"/>
>>     </bean>
>>   </property>
>> </bean>
>> <bean id="txManager"
>> class="org.springframework.jndi.JndiObjectFactoryBean">
>>   <property name="jndiName">
>>     <value>java:/TransactionManager</value>
>>   </property>
>> </bean>
>> <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"
>> abstract="true">
>>   <property name="connectionFactory">
>>     <ref local="jmsConnectionFactory"/>
>>   </property>
>>   <property name="pubSubDomain" value="false"/>
>> </bean>
>> <bean id="broker" class="org.apache.activemq.xbean.BrokerFactoryBean">
>>   <property name="config" value="classpath:activemq.xml"/>
>>   <property name="start" value="true"/>
>> </bean>
>> <bean id="jmsConnectionFactory"
>> class="org.springframework.jndi.JndiObjectFactoryBean">
>>   <property name="jndiName">
>>     <value>java:/activemq/QueueConnectionFactory</value>
>>   </property>
>> </bean>
>>
>> activemq-ds.xml deployed to JBoss contains:
>> <connection-factories>
>>   <tx-connection-factory>
>>     <jndi-name>activemq/QueueConnectionFactory</jndi-name>
>>     <xa-transaction/>
>>     <track-connection-by-tx/>
>>     <rar-name>activemq-ra-4.0.1.rar</rar-name>
>>
>> 
<connection-definition>javax.jms.QueueConnectionFactory</connection-definition>
>>   </tx-connection-factory>
>> </connection-factories>
>>
>>
>> --
>> View this message in context:
>> 
http://www.nabble.com/XA-with-ActiveMQ-4.0.1-on-JBoss-4.0.2-tf2113894.html#a5828407
>> Sent from the ActiveMQ - User forum at Nabble.com.
>>
>>
>
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
>
>

--
View this message in context: 
http://www.nabble.com/XA-with-ActiveMQ-4.0.1-on-JBoss-4.0.2-tf2113894.html#a5903827
Sent from the ActiveMQ - User forum at Nabble.com.




--

James
-------
http://radio.weblogs.com/0112098/

Reply via email to