You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Bryan Murphy <bm...@gmail.com> on 2008/12/30 00:02:01 UTC

Transactional Send Messages (NMS)

Is there a way I can have the sending of messages to a message queue
participate inside a transaction while using C# and NMS?

Thanks,
Bryan

Re: Transactional Send Messages (NMS)

Posted by Bryan Murphy <bm...@gmail.com>.
Hmm.... I was not aware that it functioned like that.  Our current
code abstracts away and hides the AMQ interfaces so that they're
essentially fire and forget.  I'll play around with pulling the AMQ
session out to the level of our database transactions and see if that
solves our issues.  If that is the case, a simple unit of work pattern
should be all that we need!

Thanks,
Bryan

On Tue, Feb 3, 2009 at 11:47 AM, Jim Gomes <e....@gmail.com> wrote:
> That sounds like a bug.  My understanding of how sessions work is if you
> have set the AcknowledgementMode.Transactional, none of the messages that
> you send to producers created on that session will be visible to any
> consumers until the Commit() function is called.  At that point, all
> messages sent up to that point will now become visible -- an all or nothing
> proposition.  If this is not working correctly, can you provide some sample
> code showing the problem?
>
> Thanks,
> Jim
>
> On Tue, Feb 3, 2009 at 8:56 AM, Bryan Murphy <bm...@gmail.com> wrote:
>
>> Essentially two phase commit.  We keep running into the problem where
>> our message are handled before the producer can commit it's
>> transaction to the database, therefore the consumer does not see the
>> correct data.  We currently work around this by either putting a sleep
>> delay at the beginning of the consumer (bad), or by sending the
>> messages after the transaction commit (lots of extra buggy code),
>> neither of which am I particularly happy with as a long term solution.
>>
>> Bryan
>>
>> On Thu, Jan 29, 2009 at 11:00 AM, Jim Gomes <e....@gmail.com> wrote:
>> > Hi Bryan,
>> >
>> > I'm not sure what you mean by participating inside a transaction.  Are
>> you
>> > talking about implementing a two-phase commit extended transaction
>> > operation?  Or are you talking about using the transaction acknowledgment
>> > mode that is part of NMS?
>> >
>> > - Jim
>> >
>> > On Mon, Dec 29, 2008 at 3:02 PM, Bryan Murphy <bm...@gmail.com>
>> wrote:
>> >
>> >> Is there a way I can have the sending of messages to a message queue
>> >> participate inside a transaction while using C# and NMS?
>> >>
>> >> Thanks,
>> >> Bryan
>> >>
>> >
>>
>

Re: Transactional Send Messages (NMS)

Posted by Jim Gomes <e....@gmail.com>.
Hi Bryan,

Great!  I'm glad everything is working for you now.  I can see how it might
be a bit unclear, but I think it is there for historical reasons.

Best,
Jim

On Wed, Feb 4, 2009 at 4:01 PM, Bryan Murphy <bm...@gmail.com> wrote:

> On Tue, Feb 3, 2009 at 11:47 AM, Jim Gomes <e....@gmail.com> wrote:
> > That sounds like a bug.  My understanding of how sessions work is if you
> > have set the AcknowledgementMode.Transactional, none of the messages that
> > you send to producers created on that session will be visible to any
> > consumers until the Commit() function is called.  At that point, all
> > messages sent up to that point will now become visible -- an all or
> nothing
> > proposition.  If this is not working correctly, can you provide some
> sample
> > code showing the problem?
>
> I refactored our code and the commit/rollback is now working.  Thanks
> for pointing this out!  I had mistakenly assumed that
> AcknowledgementMode.Transactional only worked for consumers (and not
> producers).  It doesn't seem intuitive to me, that you would set
> something called "AcknowledgementMode" when producing messages.  It
> makes sense when consuming them, yes, I got it, and I'm letting you
> know.  But what do I acknowledge when sending a message?  The naming
> conventions are not as clear as they could be, but at least it's
> working now!
>
> Thanks,
> Bryan
>

Re: Transactional Send Messages (NMS)

Posted by Bryan Murphy <bm...@gmail.com>.
On Tue, Feb 3, 2009 at 11:47 AM, Jim Gomes <e....@gmail.com> wrote:
> That sounds like a bug.  My understanding of how sessions work is if you
> have set the AcknowledgementMode.Transactional, none of the messages that
> you send to producers created on that session will be visible to any
> consumers until the Commit() function is called.  At that point, all
> messages sent up to that point will now become visible -- an all or nothing
> proposition.  If this is not working correctly, can you provide some sample
> code showing the problem?

I refactored our code and the commit/rollback is now working.  Thanks
for pointing this out!  I had mistakenly assumed that
AcknowledgementMode.Transactional only worked for consumers (and not
producers).  It doesn't seem intuitive to me, that you would set
something called "AcknowledgementMode" when producing messages.  It
makes sense when consuming them, yes, I got it, and I'm letting you
know.  But what do I acknowledge when sending a message?  The naming
conventions are not as clear as they could be, but at least it's
working now!

Thanks,
Bryan

Re: Transactional Send Messages (NMS)

Posted by Jim Gomes <e....@gmail.com>.
That sounds like a bug.  My understanding of how sessions work is if you
have set the AcknowledgementMode.Transactional, none of the messages that
you send to producers created on that session will be visible to any
consumers until the Commit() function is called.  At that point, all
messages sent up to that point will now become visible -- an all or nothing
proposition.  If this is not working correctly, can you provide some sample
code showing the problem?

Thanks,
Jim

On Tue, Feb 3, 2009 at 8:56 AM, Bryan Murphy <bm...@gmail.com> wrote:

> Essentially two phase commit.  We keep running into the problem where
> our message are handled before the producer can commit it's
> transaction to the database, therefore the consumer does not see the
> correct data.  We currently work around this by either putting a sleep
> delay at the beginning of the consumer (bad), or by sending the
> messages after the transaction commit (lots of extra buggy code),
> neither of which am I particularly happy with as a long term solution.
>
> Bryan
>
> On Thu, Jan 29, 2009 at 11:00 AM, Jim Gomes <e....@gmail.com> wrote:
> > Hi Bryan,
> >
> > I'm not sure what you mean by participating inside a transaction.  Are
> you
> > talking about implementing a two-phase commit extended transaction
> > operation?  Or are you talking about using the transaction acknowledgment
> > mode that is part of NMS?
> >
> > - Jim
> >
> > On Mon, Dec 29, 2008 at 3:02 PM, Bryan Murphy <bm...@gmail.com>
> wrote:
> >
> >> Is there a way I can have the sending of messages to a message queue
> >> participate inside a transaction while using C# and NMS?
> >>
> >> Thanks,
> >> Bryan
> >>
> >
>

Re: Transactional Send Messages (NMS)

Posted by Bryan Murphy <bm...@gmail.com>.
Essentially two phase commit.  We keep running into the problem where
our message are handled before the producer can commit it's
transaction to the database, therefore the consumer does not see the
correct data.  We currently work around this by either putting a sleep
delay at the beginning of the consumer (bad), or by sending the
messages after the transaction commit (lots of extra buggy code),
neither of which am I particularly happy with as a long term solution.

Bryan

On Thu, Jan 29, 2009 at 11:00 AM, Jim Gomes <e....@gmail.com> wrote:
> Hi Bryan,
>
> I'm not sure what you mean by participating inside a transaction.  Are you
> talking about implementing a two-phase commit extended transaction
> operation?  Or are you talking about using the transaction acknowledgment
> mode that is part of NMS?
>
> - Jim
>
> On Mon, Dec 29, 2008 at 3:02 PM, Bryan Murphy <bm...@gmail.com> wrote:
>
>> Is there a way I can have the sending of messages to a message queue
>> participate inside a transaction while using C# and NMS?
>>
>> Thanks,
>> Bryan
>>
>

Re: Transactional Send Messages (NMS)

Posted by Jim Gomes <e....@gmail.com>.
Hi Bryan,

I'm not sure what you mean by participating inside a transaction.  Are you
talking about implementing a two-phase commit extended transaction
operation?  Or are you talking about using the transaction acknowledgment
mode that is part of NMS?

- Jim

On Mon, Dec 29, 2008 at 3:02 PM, Bryan Murphy <bm...@gmail.com> wrote:

> Is there a way I can have the sending of messages to a message queue
> participate inside a transaction while using C# and NMS?
>
> Thanks,
> Bryan
>