You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by "Martin C." <ma...@gmx.at> on 2010/04/25 13:50:56 UTC

XA and setMessageListener()?

Hi,

I am trying to use Atomikos-based JTA together with Spring to use
distributed transactions.

Sending messages in an atomic way works fine, as the transaction is started
before sending a message via the message producer.

Unfortunately, I'm unable to get asynchronous message listeners (i.e. using
setMessageListener()) to work, as this will fail with "Session's XAResource
has not been enlisted in a distributed transaction." in
ActiveMQXASession#doStartTransaction().

Is it possible to have ActiveMQ automatically start a distributed
transaction when a new message arrives or is using setMessageListener() a
no-go when using JTA?

Thanks in advance!

Best regards,
Martin
-- 
View this message in context: http://old.nabble.com/XA-and-setMessageListener%28%29--tp28355420p28355420.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: XA and setMessageListener()?

Posted by "Martin C." <ma...@gmx.at>.
Hi,


Martin C. wrote:
> 
> At the moment, I am using a Spring JmsTemplate approach. The Spring
> JmsTemplates work with polling (i.e. blocking call on receive()) and sets
> up the transaction before. This works fine.
> 

I've now put together a very minimal example of what I'm originally trying
to do (without Spring and JmsTemplate) at
http://github.com/capi/eval-activemq-atomikos available for download. I
think, I am somehow missing how I could add a TransactionManger or similar
to the ActiveMQXAFactory or the session.



> Again, one important information (I missed to mention, sorry), is that I
> am still on 5.3.0.
> 

My example is using the newest libraries, still I get the same problem. My
main question is: is it even possible to use setMessageListener() in an XA
environment?

Thanks in advance for any help.

Best regards,
Martin
-- 
View this message in context: http://old.nabble.com/XA-and-setMessageListener%28%29--tp28355420p28382748.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: XA and setMessageListener()?

Posted by "Martin C." <ma...@gmx.at>.
Hi,

thanks for your reply.


Gary Tully wrote:
> 
> There needs to be some JTA wrapper on the activemq session that will start
> a
> transaction and enlist the activemq XAResource for you. For Atomikos I
> think
> it is something like:
> 
>     <bean id="atomikosConnectionFactory"
> class="com.atomikos.jms.AtomikosConnectionFactoryBean"
>         init-method="init" destroy-method="close">
>         <property name="uniqueResourceName" value="activemq" />
>         <property name="xaConnectionFactory" ref="xaFactory" />
>     </bean>
> 
> 
> Can you post a simple test case or your config if that is not the problem?
> 

Basically, this is my setup. The problem seems to be that no transaction is
started in the ActiveMQ message dispatcher. I will try to provide a minimal
example in the evening, as I cannot hand out the code I am using here (quite
strict policy at my company).

At the moment, I am using a Spring JmsTemplate approach. The Spring
JmsTemplates work with polling (i.e. blocking call on receive()) and sets up
the transaction before. This works fine.

Again, one important information (I missed to mention, sorry), is that I am
still on 5.3.0.

Best regards,
Martin
-- 
View this message in context: http://old.nabble.com/XA-and-setMessageListener%28%29--tp28355420p28373226.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: XA and setMessageListener()?

Posted by Gary Tully <ga...@gmail.com>.
There needs to be some JTA wrapper on the activemq session that will start a
transaction and enlist the activemq XAResource for you. For Atomikos I think
it is something like:

    <bean id="atomikosConnectionFactory"
class="com.atomikos.jms.AtomikosConnectionFactoryBean"
        init-method="init" destroy-method="close">
        <property name="uniqueResourceName" value="activemq" />
        <property name="xaConnectionFactory" ref="xaFactory" />
    </bean>


Can you post a simple test case or your config if that is not the problem?

On 25 April 2010 12:50, Martin C. <ma...@gmx.at> wrote:

>
> Hi,
>
> I am trying to use Atomikos-based JTA together with Spring to use
> distributed transactions.
>
> Sending messages in an atomic way works fine, as the transaction is started
> before sending a message via the message producer.
>
> Unfortunately, I'm unable to get asynchronous message listeners (i.e. using
> setMessageListener()) to work, as this will fail with "Session's XAResource
> has not been enlisted in a distributed transaction." in
> ActiveMQXASession#doStartTransaction().
>
> Is it possible to have ActiveMQ automatically start a distributed
> transaction when a new message arrives or is using setMessageListener() a
> no-go when using JTA?
>
> Thanks in advance!
>
> Best regards,
> Martin
> --
> View this message in context:
> http://old.nabble.com/XA-and-setMessageListener%28%29--tp28355420p28355420.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
http://blog.garytully.com

Open Source Integration
http://fusesource.com