Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8724145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:46:08+00:00 2026-06-13T07:46:08+00:00

I have a .NET TransactionScope that needs to contain both a MSSQL database and

  • 0

I have a .NET TransactionScope that needs to contain both a MSSQL database and a IBM MQ queue.

I’m using .NET 4.0 (VS2010), SQL 2008R2, MQ Server 6.0, MQ Client 7.0.1.9 in fully managed mode. All components are running on different machines.

From what I’ve found the following pattern should work:
http://publib.boulder.ibm.com/infocenter/wmqv7/v7r1/index.jsp?topic=%2Fcom.ibm.mq.doc%2Fun11400_.htm

Implicit Transaction
The following piece of code describes how a WebSphere MQ .NET application puts a message using .NET implicit transaction
programming.

Using (TransactionScope scope = new TransactionScope ()) { Q.Put
(putMsg,pmo); scope.Complete (); }

Q.close(); qMgr.Disconect();}

In my code this looks like:

  // mq properties
  properties = new Hashtable();
  properties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
  properties.Add(MQC.HOST_NAME_PROPERTY, HOSTNAME);
  properties.Add(MQC.PORT_PROPERTY, PORTNUMBER);
  properties.Add(MQC.CHANNEL_PROPERTY, CHANNELNAME);

  _queueManager = new MQQueueManager(queueManagerName, properties);
  _queue = _queueManager.AccessQueue(queueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
  _gmo = new MQGetMessageOptions();
  _gmo.Options |= MQC.MQGMO_WAIT;
  _gmo.Options |= MQC.MQGMO_SYNCPOINT;
  _gmo.WaitInterval = 1000;  // 1 seconds wait

  // in a loop
  using (TransactionScope t = new TransactionScope())
  {

  var message = new MQMessage();
  try
  {
     _queue.Get(message, _gmo);
  }
  catch (MQException mqe)
  { 
     message = null;
     if (mqe.ReasonCode == 2033)
     {
          Console.WriteLine("No message available");
     }
     else
     {
          throw;
      }
   }
   t.Complete();
 }

//Afterwards:

  if (_queue != null)
   {
  _queue.Close();
  _queue = null;
  }
  if (_queueManager != null)
  {
  _queueManager.Disconnect();
  _queueManager.Close();
  _queueManager = null;
  }

The problem with this is that all messages re-appear in the queue after the application is closed, while the work in the SQL database is committed.
If an exception happens inside the transactionscope, the SQL transaction rolls back while the messages in MQ appear to stay removed (until I restart the application).
Also, I don’t see any DTC activity between the .NET client and the MQ server (is that expected?)

I’m kind of lost here, any help is greatly appreciated.

  • Which MQ client should I use? Managed, Unmanaged, XA ?
  • Should I see DTC activity? How would I get the managed client to participate?
  • Which objects should be created inside the transactionscope?
  • Why do messages re-appear on the queue when the application ends even when I commit the transactionscope?

UPDATE

  • I’ve had this working with 7.1 on both client and server, but to get that (server) version deployed on our production environment would take too long.
  • So I need to work with version 7.0.x on the server side, clientside I can use whatever I need.
  • Connecting to a MQ6 server using the 7.1 client fails with errorcode 2354
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:46:09+00:00Added an answer on June 13, 2026 at 7:46 am

    Well, you need to have at least WebSphere MQ v7.1, both client and queue manager, installed to run global transactions in fully managed mode using the TransactionScope. MS DTC will be the transaction coordinator in this case. The InfoCenter link you posted about is actually pointing to WebSphere MQ v7.1.

    Update:
    Prior to MQ v7.1, XA transactions are supported only in Unmanaged mode with MTS as the transaction coordinator. Sample code for distributed transaction in unmanaged mode is here. You will require an additional component, Extended Transaction Client(XTC) to be installed. As per latest announcements the XTC is available for free. The installable can be found in your MQ Server installation image.

    When a MQ connection is disconnected (basically MQDISC is called), any uncommitted messages in a transaction will be rolled back. Because of this messages reappear on the queue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET MVC 3 Web Application using Linq-to-SQL for my data access
I have some VB.NET code that creates a TransactionScope instance: LoggingUtility.LogDebug(UpdateCallTable, SatComCallDataImporter, About to
I have an ASP.NET MVC 3 (using Entity Framework 4.2) application that uses transactions
Is the TransactionScope can be used only for Database/ADO.NET related methods? Say, I have
I have read (or perhaps heard from a colleague) that in .NET, TransactionScope can
Background: I have an ASP.NET MVC application that wraps controller actions in a TransactionScope
I have stored procedures in SQL Server T-SQL that are called from .NET within
I'm using SQL Server and ASP.NET. I have the following function: Using js =
I have .NET application that is hosted on IIS 6.1 It is impossible to
I have .Net service that listens on single port over TCP protocol. Clients connect

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.