You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by Rajika Kumarasiri <ra...@wso2.com> on 2010/01/05 06:50:25 UTC
Question on distributed JMS transaction in JMS sender
hi,
I just went through the implementation of the distributed JMS transaction
implementation of JMS transport sender and came across the following
observations.
First JMS transport sender check for JTA JMS transaction using the message
context property "UserTransaction" ( JMSMessageSender.java:177) and this
property is set at the JMSMessageReceiver (JMSMessageReceiver.java:192),
which actually pass from the run method in ServiceTaskManager.
According to my understanding we are using the same transaction in JMSSender
(pass as a msg_ctx property) created in JMS listener. I think there is a
problem in this approach, because if we do not initialize the
userTransaction in the listener but if we plan to use a userTransaction in
the sender side we may not acquire a userTransaction. I think what sender
should do is to use an already available userTransaction or create a one and
participate in the distribute transaction if not.
Is my understanding is correct? WDYT ?
Rajika
Re: Question on distributed JMS transaction in JMS sender
Posted by Andreas Veithen <an...@gmail.com>.
Rajika,
Glad to hear that it worked.
Andreas
On Thu, Jan 7, 2010 at 11:58, Rajika Kumarasiri <ra...@wso2.com> wrote:
> Andreas,
> I just tried out this scenario and it works fine. I just use the transaction
> mediator to mark the start/end/rollback of the JTA transaction and JMS
> sender participated in that transaction, and I didn't configure anything
> related to JTA in JMS sender.
>
> Rajika
>
> On Tue, Jan 5, 2010 at 10:56 PM, Rajika Kumarasiri <ra...@wso2.com> wrote:
>
>> Andreas,
>> As I said I was just looking through the distributed transaction
>> implementation in JMS transport and observed the above. I am not sure why
>> there is a tight couple between the JTA transaction created in JMSListener
>> and the JMSSender is using it. Any way I'll try out my scenario and see how
>> it goes.
>>
>> Rajika
>>
>>
>> On Tue, Jan 5, 2010 at 5:07 PM, Andreas Veithen <andreas.veithen@gmail.com
>> > wrote:
>>
>>> If Synapse invokes the sender on the thread on which the transaction
>>> is running (and if the JMS connection factories are set up correctly),
>>> then it should automatically participate in this transaction. What
>>> kind of issue are you seeing with the current implementation of the
>>> JMS sender?
>>>
>>> Andreas
>>>
>>>
>>
>
Re: Question on distributed JMS transaction in JMS sender
Posted by Rajika Kumarasiri <ra...@wso2.com>.
Andreas,
I just tried out this scenario and it works fine. I just use the transaction
mediator to mark the start/end/rollback of the JTA transaction and JMS
sender participated in that transaction, and I didn't configure anything
related to JTA in JMS sender.
Rajika
On Tue, Jan 5, 2010 at 10:56 PM, Rajika Kumarasiri <ra...@wso2.com> wrote:
> Andreas,
> As I said I was just looking through the distributed transaction
> implementation in JMS transport and observed the above. I am not sure why
> there is a tight couple between the JTA transaction created in JMSListener
> and the JMSSender is using it. Any way I'll try out my scenario and see how
> it goes.
>
> Rajika
>
>
> On Tue, Jan 5, 2010 at 5:07 PM, Andreas Veithen <andreas.veithen@gmail.com
> > wrote:
>
>> If Synapse invokes the sender on the thread on which the transaction
>> is running (and if the JMS connection factories are set up correctly),
>> then it should automatically participate in this transaction. What
>> kind of issue are you seeing with the current implementation of the
>> JMS sender?
>>
>> Andreas
>>
>>
>
Re: Question on distributed JMS transaction in JMS sender
Posted by Rajika Kumarasiri <ra...@wso2.com>.
Andreas,
As I said I was just looking through the distributed transaction
implementation in JMS transport and observed the above. I am not sure why
there is a tight couple between the JTA transaction created in JMSListener
and the JMSSender is using it. Any way I'll try out my scenario and see how
it goes.
Rajika
On Tue, Jan 5, 2010 at 5:07 PM, Andreas Veithen
<an...@gmail.com>wrote:
> If Synapse invokes the sender on the thread on which the transaction
> is running (and if the JMS connection factories are set up correctly),
> then it should automatically participate in this transaction. What
> kind of issue are you seeing with the current implementation of the
> JMS sender?
>
> Andreas
>
>
Re: Question on distributed JMS transaction in JMS sender
Posted by Andreas Veithen <an...@gmail.com>.
If Synapse invokes the sender on the thread on which the transaction
is running (and if the JMS connection factories are set up correctly),
then it should automatically participate in this transaction. What
kind of issue are you seeing with the current implementation of the
JMS sender?
Andreas
On Tue, Jan 5, 2010 at 12:10, Rajika Kumarasiri <ra...@wso2.com> wrote:
> Yes,
> The transaction should be initialized by synapse ( and I fixed the
> transaction mediator to do that) and JMS transport(Sender) should
> participate in that distributed transaction.
>
> Rajika
>
> On Tue, Jan 5, 2010 at 4:34 PM, Andreas Veithen
> <an...@gmail.com>wrote:
>
>> Rajika,
>>
>> That is a valid requirement, but in that case, it is not the
>> responsibility of the JMS sender to create the transaction.
>>
>> Andreas
>>
>> On Tue, Jan 5, 2010 at 11:56, Rajika Kumarasiri <ra...@wso2.com> wrote:
>> > Andreas,
>> > I think I was not clear with my requirement. Consider a scenario like
>> this.
>> > Assume we use synapse and say we pick a message from a database and send
>> it
>> > to a JMS queue, using the JMS transport. Now I want this happen to be
>> > happened in a distributed transaction, i.e. if something went wrong
>> > (database crash or JMS queue crash) I want to rollback the transaction so
>> > that I don't loose any messages.
>> >
>> > Rajika
>> >
>> > On Tue, Jan 5, 2010 at 4:10 PM, Andreas Veithen
>> > <an...@gmail.com>wrote:
>> >
>> >> Rajika,
>> >>
>> >> In that case, why do you need a distributed transaction, considering
>> >> that the JMS sender uses a single resource (the JMS connection
>> >> factory) and executes a single operation (sending the JMS message)? It
>> >> seems to me that in that case, you don't need a transaction, and even
>> >> less a distributed transaction.
>> >>
>> >> Andreas
>> >>
>> >> On Tue, Jan 5, 2010 at 11:33, Rajika Kumarasiri <ra...@wso2.com>
>> wrote:
>> >> > On Tue, Jan 5, 2010 at 3:20 PM, Andreas Veithen
>> >> > <an...@gmail.com>wrote:
>> >> >
>> >> >> Rajika,
>> >> >>
>> >> >> Why would the JMS sender ever want to create a new transaction?
>> >> >>
>> >> >
>> >> > In case of only the JMS TransportSender needs to participate in a
>> >> > distributed transaction.
>> >> >
>> >> > Rajika
>> >> >
>> >> >
>> >> >>
>> >> >> Andreas
>> >> >>
>> >> >>
>> >> >
>> >>
>> >
>>
>
Re: Question on distributed JMS transaction in JMS sender
Posted by Rajika Kumarasiri <ra...@wso2.com>.
Yes,
The transaction should be initialized by synapse ( and I fixed the
transaction mediator to do that) and JMS transport(Sender) should
participate in that distributed transaction.
Rajika
On Tue, Jan 5, 2010 at 4:34 PM, Andreas Veithen
<an...@gmail.com>wrote:
> Rajika,
>
> That is a valid requirement, but in that case, it is not the
> responsibility of the JMS sender to create the transaction.
>
> Andreas
>
> On Tue, Jan 5, 2010 at 11:56, Rajika Kumarasiri <ra...@wso2.com> wrote:
> > Andreas,
> > I think I was not clear with my requirement. Consider a scenario like
> this.
> > Assume we use synapse and say we pick a message from a database and send
> it
> > to a JMS queue, using the JMS transport. Now I want this happen to be
> > happened in a distributed transaction, i.e. if something went wrong
> > (database crash or JMS queue crash) I want to rollback the transaction so
> > that I don't loose any messages.
> >
> > Rajika
> >
> > On Tue, Jan 5, 2010 at 4:10 PM, Andreas Veithen
> > <an...@gmail.com>wrote:
> >
> >> Rajika,
> >>
> >> In that case, why do you need a distributed transaction, considering
> >> that the JMS sender uses a single resource (the JMS connection
> >> factory) and executes a single operation (sending the JMS message)? It
> >> seems to me that in that case, you don't need a transaction, and even
> >> less a distributed transaction.
> >>
> >> Andreas
> >>
> >> On Tue, Jan 5, 2010 at 11:33, Rajika Kumarasiri <ra...@wso2.com>
> wrote:
> >> > On Tue, Jan 5, 2010 at 3:20 PM, Andreas Veithen
> >> > <an...@gmail.com>wrote:
> >> >
> >> >> Rajika,
> >> >>
> >> >> Why would the JMS sender ever want to create a new transaction?
> >> >>
> >> >
> >> > In case of only the JMS TransportSender needs to participate in a
> >> > distributed transaction.
> >> >
> >> > Rajika
> >> >
> >> >
> >> >>
> >> >> Andreas
> >> >>
> >> >>
> >> >
> >>
> >
>
Re: Question on distributed JMS transaction in JMS sender
Posted by Andreas Veithen <an...@gmail.com>.
Rajika,
That is a valid requirement, but in that case, it is not the
responsibility of the JMS sender to create the transaction.
Andreas
On Tue, Jan 5, 2010 at 11:56, Rajika Kumarasiri <ra...@wso2.com> wrote:
> Andreas,
> I think I was not clear with my requirement. Consider a scenario like this.
> Assume we use synapse and say we pick a message from a database and send it
> to a JMS queue, using the JMS transport. Now I want this happen to be
> happened in a distributed transaction, i.e. if something went wrong
> (database crash or JMS queue crash) I want to rollback the transaction so
> that I don't loose any messages.
>
> Rajika
>
> On Tue, Jan 5, 2010 at 4:10 PM, Andreas Veithen
> <an...@gmail.com>wrote:
>
>> Rajika,
>>
>> In that case, why do you need a distributed transaction, considering
>> that the JMS sender uses a single resource (the JMS connection
>> factory) and executes a single operation (sending the JMS message)? It
>> seems to me that in that case, you don't need a transaction, and even
>> less a distributed transaction.
>>
>> Andreas
>>
>> On Tue, Jan 5, 2010 at 11:33, Rajika Kumarasiri <ra...@wso2.com> wrote:
>> > On Tue, Jan 5, 2010 at 3:20 PM, Andreas Veithen
>> > <an...@gmail.com>wrote:
>> >
>> >> Rajika,
>> >>
>> >> Why would the JMS sender ever want to create a new transaction?
>> >>
>> >
>> > In case of only the JMS TransportSender needs to participate in a
>> > distributed transaction.
>> >
>> > Rajika
>> >
>> >
>> >>
>> >> Andreas
>> >>
>> >>
>> >
>>
>
Re: Question on distributed JMS transaction in JMS sender
Posted by Rajika Kumarasiri <ra...@wso2.com>.
Andreas,
I think I was not clear with my requirement. Consider a scenario like this.
Assume we use synapse and say we pick a message from a database and send it
to a JMS queue, using the JMS transport. Now I want this happen to be
happened in a distributed transaction, i.e. if something went wrong
(database crash or JMS queue crash) I want to rollback the transaction so
that I don't loose any messages.
Rajika
On Tue, Jan 5, 2010 at 4:10 PM, Andreas Veithen
<an...@gmail.com>wrote:
> Rajika,
>
> In that case, why do you need a distributed transaction, considering
> that the JMS sender uses a single resource (the JMS connection
> factory) and executes a single operation (sending the JMS message)? It
> seems to me that in that case, you don't need a transaction, and even
> less a distributed transaction.
>
> Andreas
>
> On Tue, Jan 5, 2010 at 11:33, Rajika Kumarasiri <ra...@wso2.com> wrote:
> > On Tue, Jan 5, 2010 at 3:20 PM, Andreas Veithen
> > <an...@gmail.com>wrote:
> >
> >> Rajika,
> >>
> >> Why would the JMS sender ever want to create a new transaction?
> >>
> >
> > In case of only the JMS TransportSender needs to participate in a
> > distributed transaction.
> >
> > Rajika
> >
> >
> >>
> >> Andreas
> >>
> >>
> >
>
Re: Question on distributed JMS transaction in JMS sender
Posted by Andreas Veithen <an...@gmail.com>.
Rajika,
In that case, why do you need a distributed transaction, considering
that the JMS sender uses a single resource (the JMS connection
factory) and executes a single operation (sending the JMS message)? It
seems to me that in that case, you don't need a transaction, and even
less a distributed transaction.
Andreas
On Tue, Jan 5, 2010 at 11:33, Rajika Kumarasiri <ra...@wso2.com> wrote:
> On Tue, Jan 5, 2010 at 3:20 PM, Andreas Veithen
> <an...@gmail.com>wrote:
>
>> Rajika,
>>
>> Why would the JMS sender ever want to create a new transaction?
>>
>
> In case of only the JMS TransportSender needs to participate in a
> distributed transaction.
>
> Rajika
>
>
>>
>> Andreas
>>
>>
>
Re: Question on distributed JMS transaction in JMS sender
Posted by Rajika Kumarasiri <ra...@wso2.com>.
On Tue, Jan 5, 2010 at 3:20 PM, Andreas Veithen
<an...@gmail.com>wrote:
> Rajika,
>
> Why would the JMS sender ever want to create a new transaction?
>
In case of only the JMS TransportSender needs to participate in a
distributed transaction.
Rajika
>
> Andreas
>
>
Re: Question on distributed JMS transaction in JMS sender
Posted by Andreas Veithen <an...@gmail.com>.
Rajika,
Why would the JMS sender ever want to create a new transaction?
Andreas
On Tue, Jan 5, 2010 at 06:50, Rajika Kumarasiri <ra...@wso2.com> wrote:
> hi,
> I just went through the implementation of the distributed JMS transaction
> implementation of JMS transport sender and came across the following
> observations.
> First JMS transport sender check for JTA JMS transaction using the message
> context property "UserTransaction" ( JMSMessageSender.java:177) and this
> property is set at the JMSMessageReceiver (JMSMessageReceiver.java:192),
> which actually pass from the run method in ServiceTaskManager.
> According to my understanding we are using the same transaction in JMSSender
> (pass as a msg_ctx property) created in JMS listener. I think there is a
> problem in this approach, because if we do not initialize the
> userTransaction in the listener but if we plan to use a userTransaction in
> the sender side we may not acquire a userTransaction. I think what sender
> should do is to use an already available userTransaction or create a one and
> participate in the distribute transaction if not.
> Is my understanding is correct? WDYT ?
>
> Rajika
>