You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by JohanB <jo...@gmail.com> on 2006/07/06 12:13:21 UTC
ActiveMQ 4 + Jencks + XA Transactions
Hi,
I'm trying to use Jencks JCA container with ActiveMQ-4.1-SNAPSHOT in order
to test XA transactions.
I'm using Spring 2.0RC1 + xbean-spring-2.4, Jencks-1.1.3 and using an
ActiveMQ Embedded Broker defined in Java code (no activemq.xml).
When I run my tests, the following exception occurs :
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'jmsConnectionFactory' defined in class path resource
[applicationContext-jca-activemq4.xml]: Instantiation of bean failed; nested
exception is java.lang.NoClassDefFoundError: org/activemq/pool/ConnectionKey
Caused by: java.lang.NoClassDefFoundError: org/activemq/pool/ConnectionKey
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethods(Unknown Source)
at java.beans.Introspector$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.beans.Introspector.getPublicDeclaredMethods(Unknown Source)
at java.beans.Introspector.getTargetMethodInfo(Unknown Source)
at java.beans.Introspector.getBeanInfo(Unknown Source)
....
at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)
at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)
...
Here is my jmsConnectionFactory bean, defined with Spring :
<bean id="jmsConnectionFactory"
class="org.jencks.pool.PooledSpringXAConnectionFactory">
<property name="connectionFactory" ref="activemqXAConnectionFactory" />
<property name="transactionManager" ref="transactionManager" />
</bean>
<!-- ActiveMQ XA-capable connection -->
<bean id="activemqXAConnectionFactory"
class="org.apache.activemq.ActiveMQXAConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
</bean>
<bean id="transactionManager"
class="org.jencks.factory.TransactionManagerFactoryBean">
...
</bean>
...
It makes me think that Jencks doesn't support well Active MQ 4, as it tries
to access a class in "org.activemq" instead of "org.apache.activemq".
Currently, is it possble to use Jencks with ActiveMQ4 ?
--
View this message in context: http://www.nabble.com/ActiveMQ-4-%2B-Jencks-%2B-XA-Transactions-tf1899733.html#a5196977
Sent from the ActiveMQ - User forum at Nabble.com.
Re: ActiveMQ 4 + Jencks + XA Transactions
Posted by "Christopher G. Stach II" <cg...@ldsys.net>.
Johan Brelet wrote:
> I misunderstand something (sorry but I'm an ActiveMQ / JCA newbie). When
> using inbound communications, I thought that transactions were managed
> transparently by the JCA Resource Adapter and that the only way to rollback
> a transaction was to throw an error... So how can I do to handle the current
> transaction in the onMessage() method ? In my Spring config file, the only
> class that is linked with JTA transactions is the Jencks JCA connector (via
> the transactionManager property) :
If you are using Spring's transaction support, something like:
TransactionInterceptor.currentTransactionStatus().setRollbackOnly();
--
Christopher G. Stach II
Re: ActiveMQ 4 + Jencks + XA Transactions
Posted by Johan Brelet <jo...@gmail.com>.
I misunderstand something (sorry but I'm an ActiveMQ / JCA newbie). When
using inbound communications, I thought that transactions were managed
transparently by the JCA Resource Adapter and that the only way to rollback
a transaction was to throw an error... So how can I do to handle the current
transaction in the onMessage() method ? In my Spring config file, the only
class that is linked with JTA transactions is the Jencks JCA connector (via
the transactionManager property) :
<bean id="queueListenerConnector" class="org.jencks.JCAConnector">
<property name="jcaContainer" ref="jencksJCAContainer" />
<property name="activationSpec" ref="queueActivationSpec" />
<property name="transactionManager" ref="transactionManager" />
<property name="ref" value="myListener" />
</bean>
<bean id="jencksJCAContainer" class="org.jencks.JCAContainer">
<property name="bootstrapContext" ref="bootstrapContext" />
<property name="resourceAdapter" ref="resourceAdapter" />
</bean>
<bean id="bootstrapContext"
class="org.jencks.factory.BootstrapContextFactoryBean">
<property name="threadPoolSize" value="25" />
</bean>
<bean id="resourceAdapter"
class="org.apache.activemq.ra.ActiveMQResourceAdapter">
<property name="serverUrl" value="tcp://localhost:61616" />
</bean>
<bean id="queueActivationSpec"
class="org.apache.activemq.ra.ActiveMQActivationSpec">
<property name="destination" value="test.queue" />
<property name="destinationType" value="javax.jms.Queue" />
</bean>
<bean id="transactionManager"
class="org.jencks.factory.TransactionManagerFactoryBean">
...
</bean>
...
--
View this message in context: http://www.nabble.com/ActiveMQ-4-%2B-Jencks-%2B-XA-Transactions-tf1899733.html#a5251236
Sent from the ActiveMQ - User forum at Nabble.com.
Re: ActiveMQ 4 + Jencks + XA Transactions
Posted by "Christopher G. Stach II" <cg...@ldsys.net>.
Johan Brelet wrote:
> Perhaps I said a bit too fast that it was working fine... :)
>
> Here is the problem I have now :
> In my tests I try to force the broker to rollback a global XA transaction
> when receiving a JMS Message. To do that, the onMessage() method throws a
> RuntimeException. So, I expect the broker to catch this exception, and then
> to rollback transaction, and later to try again delivering the message.
> But with ActiveMQ4.1 and latest Jencks from SVN HEAD, I don't understand the
> behaviour of the broker... The exception doesn't cause the transaction to
> rollback, so it stays active, and the broker do not redeliver the message.
> Here is a part of logs :
[...]
> I don't really understand what's going on...Am I doing something wrong ? Or
> is it a problem with ActiveMQ 4.1 ?
According to the spec, onMessage should not throw RuntimeException. Get
a handle on the current Transaction and setRollbackOnly().
--
Christopher G. Stach II
Re: ActiveMQ 4 + Jencks + XA Transactions
Posted by Johan Brelet <jo...@gmail.com>.
Perhaps I said a bit too fast that it was working fine... :)
Here is the problem I have now :
In my tests I try to force the broker to rollback a global XA transaction
when receiving a JMS Message. To do that, the onMessage() method throws a
RuntimeException. So, I expect the broker to catch this exception, and then
to rollback transaction, and later to try again delivering the message.
But with ActiveMQ4.1 and latest Jencks from SVN HEAD, I don't understand the
behaviour of the broker... The exception doesn't cause the transaction to
rollback, so it stays active, and the broker do not redeliver the message.
Here is a part of logs :
ERROR [org.apache.activemq.ActiveMQSession] - error dispatching message:
java.lang.RuntimeException: (Exception thrown to rollback global
transaction)
DEBUG [org.apache.activemq.ra.ServerSessionImpl:0] - run loop end
DEBUG [org.apache.activemq.ra.ServerSessionPoolImpl] - Session returned to
pool: ServerSessionImpl:0
DEBUG [org.apache.activemq.ra.ServerSessionImpl:0] - Run finished
DEBUG [org.apache.activemq.ra.ServerSessionImpl:0] - Work completed:
javax.resource.spi.work.WorkEvent[source=Work :ServerSessionImpl:0]
DEBUG [org.apache.activemq.ra.ActiveMQEndpointWorker] - Reconnect cause:
javax.jms.JMSException: (Exception thrown to rollback global transaction)
DEBUG [org.apache.activemq.broker.region.AbstractRegion] - Removing
consumer: ID:fr-44-01-03-003-3015-1152279054830-3:0:-1:2
DEBUG [org.apache.activemq.broker.region.AbstractRegion] - Removing
consumer: ID:fr-44-01-03-003-3015-1152279054830-3:0:-1:1
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]}
DEBUG [org.apache.activemq.transport.tcp.TcpTransport] - TCP consumer thread
starting
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]}
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]}
DEBUG [org.apache.activemq.transport.tcp.TcpTransport] - TCP consumer thread
starting
DEBUG [org.apache.activemq.transport.WireFormatNegotiator] -
tcp:///127.0.0.1:3025 before negotiation: OpenWireFormat{version=1,
cacheEnabled=false, stackTraceEnabled=false, tightEncodingEnabled=false,
sizePrefixDisabled=false}
DEBUG [org.apache.activemq.transport.WireFormatNegotiator] -
tcp:///127.0.0.1:3025 after negotiation: OpenWireFormat{version=1,
cacheEnabled=true, stackTraceEnabled=true, tightEncodingEnabled=true,
sizePrefixDisabled=false}
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]}
DEBUG [org.apache.activemq.transport.WireFormatNegotiator] -
tcp://localhost/127.0.0.1:61616 before negotiation:
OpenWireFormat{version=1, cacheEnabled=false, stackTraceEnabled=false,
tightEncodingEnabled=false, sizePrefixDisabled=false}
DEBUG [org.apache.activemq.transport.WireFormatNegotiator] -
tcp://localhost/127.0.0.1:61616 after negotiation: OpenWireFormat{version=1,
cacheEnabled=true, stackTraceEnabled=true, tightEncodingEnabled=true,
sizePrefixDisabled=false}
DEBUG [org.apache.activemq.broker.region.AbstractRegion] - Adding consumer:
ID:fr-44-01-03-003-3015-1152279054830-3:4:-1:1
DEBUG [org.apache.activemq.broker.region.AbstractRegion] - Adding consumer:
ID:fr-44-01-03-003-3015-1152279054830-3:4:-1:2
DEBUG [org.apache.activemq.transport.InactivityMonitor] - Message sent since
last write check, resetting flag
DEBUG [org.apache.activemq.transport.InactivityMonitor] - Message sent since
last write check, resetting flag
DEBUG [org.apache.activemq.transport.InactivityMonitor] - Message sent since
last write check, resetting flag
...
I don't really understand what's going on...Am I doing something wrong ? Or
is it a problem with ActiveMQ 4.1 ?
--
View this message in context: http://www.nabble.com/ActiveMQ-4-%2B-Jencks-%2B-XA-Transactions-tf1899733.html#a5217720
Sent from the ActiveMQ - User forum at Nabble.com.
Re: ActiveMQ 4 + Jencks + XA Transactions
Posted by "Christopher G. Stach II" <cg...@ldsys.net>.
James Strachan wrote:
> On 7/7/06, Johan Brelet <jo...@gmail.com> wrote:
>>
>> OK, it works fine with SVN Head of Jencks, thanks.
>
> Glad to hear it!
>
>> I was using the latest jar released on Jencks site. So, for the
>> moment, no
>> release of Jencks is ActiveMQ4.x compliant, isn't it ?
>
> Agreed. Will try get a release of Jencks out ASAP...
>
Looking back at the Jencks site, being that I think we're having this
same problem since we've upgraded to AMQ 4.0.1, I noticed that there's
no link to the 1.1.2 release. There also aren't any snapshot builds for
download. What is the ETA for the next release?
--
Christopher G. Stach II
Re: ActiveMQ 4 + Jencks + XA Transactions
Posted by James Strachan <ja...@gmail.com>.
On 7/7/06, Johan Brelet <jo...@gmail.com> wrote:
>
> OK, it works fine with SVN Head of Jencks, thanks.
Glad to hear it!
> I was using the latest jar released on Jencks site. So, for the moment, no
> release of Jencks is ActiveMQ4.x compliant, isn't it ?
Agreed. Will try get a release of Jencks out ASAP...
--
James
-------
http://radio.weblogs.com/0112098/
Re: ActiveMQ 4 + Jencks + XA Transactions
Posted by Johan Brelet <jo...@gmail.com>.
OK, it works fine with SVN Head of Jencks, thanks.
I was using the latest jar released on Jencks site. So, for the moment, no
release of Jencks is ActiveMQ4.x compliant, isn't it ?
--
View this message in context: http://www.nabble.com/ActiveMQ-4-%2B-Jencks-%2B-XA-Transactions-tf1899733.html#a5213459
Sent from the ActiveMQ - User forum at Nabble.com.
Re: ActiveMQ 4 + Jencks + XA Transactions
Posted by James Strachan <ja...@gmail.com>.
SVN HEAD of Jencks is working well with ActiveMQ 4.x. Are you sure you
are not using an old version of the resource adapter or something? I
don't see the use of the ActiveMQ resource adapter in your XML - could
that be the issue?
On 7/6/06, JohanB <jo...@gmail.com> wrote:
>
> Hi,
> I'm trying to use Jencks JCA container with ActiveMQ-4.1-SNAPSHOT in order
> to test XA transactions.
> I'm using Spring 2.0RC1 + xbean-spring-2.4, Jencks-1.1.3 and using an
> ActiveMQ Embedded Broker defined in Java code (no activemq.xml).
> When I run my tests, the following exception occurs :
>
> org.springframework.beans.factory.BeanCreationException: Error creating bean
> with name 'jmsConnectionFactory' defined in class path resource
> [applicationContext-jca-activemq4.xml]: Instantiation of bean failed; nested
> exception is java.lang.NoClassDefFoundError: org/activemq/pool/ConnectionKey
> Caused by: java.lang.NoClassDefFoundError: org/activemq/pool/ConnectionKey
> at java.lang.Class.getDeclaredMethods0(Native Method)
> at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
> at java.lang.Class.getDeclaredMethods(Unknown Source)
> at java.beans.Introspector$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.beans.Introspector.getPublicDeclaredMethods(Unknown Source)
> at java.beans.Introspector.getTargetMethodInfo(Unknown Source)
> at java.beans.Introspector.getBeanInfo(Unknown Source)
> ....
> at
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)
> at
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)
> ...
>
> Here is my jmsConnectionFactory bean, defined with Spring :
>
> <bean id="jmsConnectionFactory"
> class="org.jencks.pool.PooledSpringXAConnectionFactory">
> <property name="connectionFactory" ref="activemqXAConnectionFactory" />
> <property name="transactionManager" ref="transactionManager" />
> </bean>
>
> <!-- ActiveMQ XA-capable connection -->
> <bean id="activemqXAConnectionFactory"
> class="org.apache.activemq.ActiveMQXAConnectionFactory">
> <property name="brokerURL" value="tcp://localhost:61616" />
> </bean>
>
> <bean id="transactionManager"
> class="org.jencks.factory.TransactionManagerFactoryBean">
> ...
> </bean>
>
> ...
>
> It makes me think that Jencks doesn't support well Active MQ 4, as it tries
> to access a class in "org.activemq" instead of "org.apache.activemq".
> Currently, is it possble to use Jencks with ActiveMQ4 ?
> --
> View this message in context: http://www.nabble.com/ActiveMQ-4-%2B-Jencks-%2B-XA-Transactions-tf1899733.html#a5196977
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>
--
James
-------
http://radio.weblogs.com/0112098/