Queued Components and TransactionScope

J

John

Hi,

I have an app that uses Queued Components. The queue is set as
transactional and the transaction is set to Supported (I've also tried
Required). Everything is running on the same box (tried XP and 2k3). In my
app I wrap the queued component call in a TransactionScope. I'm using
EnterpriseServicesInteropOption.Full in creating the scope. Right after
queuing the component I intentionally throw an exception and don't complete
the scope. The message stays on the queue and gets processed. This is a
simplified version of what my program really does, which is call a database
update within that same scope. When something fails I want the entire
transaction rolled back; DB and MSMQ. What actually happens though is that
the DB rolls back but MSMQ doesn't. I created the simplified version just
to see if I could get MSMQ to roll back, but I can't. So what am I missing?

John
 
K

Kevin Yu [MSFT]

Hi John,

Could you send the simplified version to me so that I can troubleshoot on
it? Remove 'online' from the nospam alias is my real email.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
J

John

Hi Kevin,

Thank you for the reply. The simplified version still uses a huge library
that does the queueing among other things. I can't send you that. I'll see
if I can work up a really simple stand-alone version that doesn't have any
of that. But in the mean time, is there anything special I need to do other
than what I've already described? This should work, right?

John
 
K

Kevin Yu [MSFT]

Hi John,

If the transaction is rolled back, please make sure that the
TransactionScope is disposed successfully. Putting the TransactionScope
object in a using block is a good idea.

http://msdn2.microsoft.com/en-us/library/system.transactions.transactionscop
e.aspx

Currently, I have no other ideas on this issue. If you have a repro sample,
please feel free to send it to me, I'll take a look. Thank you for your
understanding.

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
K

Kevin Yu [MSFT]

Hi John,

I did some research on this code and found that you're trying to use nested
transaction. Althrough you're using TransactionScopeOptions.Required, the
inner one is getting the outer transaction. So actually, there is only one
transaction here. When the inner one calls Complete, the Transaction is
committed.

So can you try to remove one TransactionScope? Or please try to use
TransactionScopeOption.RequiresNew in the inner transaction scope in the
Send method?

Please let me know if you have any problem.

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
J

John

Kevin,

From everything I've read it was my understanding that if transaction scopes
are nested and the inner scope joins the outer scope, committing the outer
scope--not the inner one--commits the whole thing. Is that not the case?

Either way, I removed the inner transaction scope, leaving only the one in
Main and I get the same behavior.

The other funny thing is that the message doesn't get queued until the
program ends--not at the point the scope.Complete() is called as I would
expect. Can that be explained?

John
 
K

Kevin Yu [MSFT]

Hi John,

Actually in this case, there is only one transaction here. Because
TransactionScopeOptions.Required will use the existing transaction. Would
you mind sending me an email so that we might discuss this issue? Remove
'online' from the nospam alias is my real email.

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
J

John

Kevin,
Per your email request I am indicating here that this issue has not been
resolved yet.
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top