Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TransactionScope and MSMQ

Status
Not open for further replies.

Polu

Programmer
Sep 18, 2002
69
GB
Hello,

I am trying to use System.Transactions and MSMQ with no success. In it is said:

"The System.Transactions infrastructure makes transactional programming simple and efficient throughout the platform by supporting transactions initiated in SQL Server, ADO.NET, MSMQ, and the Microsoft Distributed Transaction Coordinator (MSDTC)."

However, when I try to run an implicit transaction using Transaction Scope it does dont work. Here is my code:

using (TransactionScope scope = new TransactionScope())
{
using (MessageQueue myQueue = new MessageQueue(QUEUE_NAME))
{
if (myQueue.Transactional)
{
myQueue.Send(TicketTextBox.Text, "Message");
}
}
scope.Complete();
}

It compiles and runs but no message is sent, just as if no transaction were opened. I cannot try to use explicit transactions because MessageQueue does not implement EnlistTransaction(CommittableTransaction tx) method.

Please, is MSMQ aware of System.Transaction? How can I use it?

Thank you.
 
Hello again. I found it. Rigth code is:

using (TransactionScope scope = new TransactionScope())
{
using (MessageQueue myQueue = new MessageQueue(QUEUE_NAME))
{
if (myQueue.Transactional)
{
myQueue.Send(TicketTextBox.Text, "Message",
MessageQueueTransactionType.Automatic);
}
}
scope.Complete();
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top