ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » MQRC_HANDLE_IN_USE_FOR_UOW

Post new topic  Reply to topic
 MQRC_HANDLE_IN_USE_FOR_UOW « View previous topic :: View next topic » 
Author Message
Amazone
PostPosted: Mon Oct 17, 2005 2:05 am    Post subject: MQRC_HANDLE_IN_USE_FOR_UOW Reply with quote

Novice

Joined: 17 Oct 2005
Posts: 14

Hi,

I developed a service of duplication of file WMQ, in C#.
This service use threads to manage duplication's queues.
I use server bindings connection. My service runs on the same machine than WMQ server.

Messages of a queue can be duplicate on a few others queues.
I want to use transaction.

This is my code :


Code:
      public void Start(string qmName, string inQueueName, ArrayList outQueueNames, ArrayList extQueues)
      {
         MQMessage retrievedMessage;
         MQQueueManager mqQMgr=null;
         ArrayList myOutQueues = new ArrayList();         
         MQQueue myInQueue = null;
         while (true)
         {
            try
            {
               #region Connexion WMQ
               // On essaie de se connecter
               // (ou se reconnecter si la connexion est perdue...)
               if (mqQMgr==null || !mqQMgr.IsConnected)
               {
                  // Connect server mode
                  MQEnvironment.Channel  = null;
                  MQEnvironment.Hostname = null;
                  mqQMgr = new MQQueueManager(qmName);

                  // Access input queues
                  myInQueue = mqQMgr.AccessQueue(inQueueName, openInOptions);
                  
                  // Access output queues
                  myOutQueues.Clear();         
                  foreach(string queue in outQueueNames)
                  {
                     myOutQueues.Add(mqQMgr.AccessQueue(queue, openOutOptions));
                  }
               }


               #endregion

               #region Dupliq
               bool hadMessage = false;

               MQPutMessageOptions pmo = new MQPutMessageOptions();
               MQGetMessageOptions gmo = new MQGetMessageOptions();
               gmo.Options = MQC.MQGMO_SYNCPOINT | MQC.MQGMO_WAIT;
               pmo.Options = MQC.MQPMO_SYNCPOINT;
               //gmo.Options = MQC.MQGMO_WAIT;
               gmo.WaitInterval = 1000; //MQC.MQWI_UNLIMITED for waiting unlimited times

               retrievedMessage = new MQMessage();

               myInQueue.Get(retrievedMessage, gmo);

               // On n'arrive jamais ici si il n'y a pas de message (Exception levée)
;
               foreach(MQQueue myOutQueue in myOutQueues)
               {
               myOutQueue.Put(retrievedMessage, pmo);
               }
               mqQMgr.Commit();
         
               #endregion

            }
            catch(System.Threading.ThreadAbortException the)
            {
               #region Abandon de Thread
               #region BackOut
               Log.Warning("Queue Name : " + inQueueName + "\nType Erreur : Abandon Thread\nMessage d'erreur : " + the.Message + "\nStackTrace : " + the.StackTrace );
               try
               {
                  mqQMgr.Backout();
               }
               catch (Exception e)
               {
                  Log.Warning("Queue Name : " + inQueueName + "\nType Erreur : Abandon Thread\nMessage d'erreur : " + e.Message + "\nStackTrace : " + e.StackTrace );
               }
               #endregion

               #region Clear & close MQ
               // Nettoyage et fermeture
               if ((myInQueue != null) && myInQueue.IsOpen)
               {
                  myInQueue.Close();
               }
               foreach(MQQueue myOutQueue in myOutQueues)
               {
                  if ((myOutQueue != null) && myOutQueue.IsOpen)
                  {
                     myOutQueue.Close();
                  }
               }
               if (mqQMgr != null)
               {
                  mqQMgr.Disconnect();
               }
               #endregion

               return;
               #endregion
            }
            catch(MQException mqe)
            {
               #region Erreur MQ
               if (mqe.ReasonCode == MQC.MQRC_NO_MSG_AVAILABLE)
               { // Pas de message dans l'intervalle
                  if ((myInQueue != null) && myInQueue.IsOpen)
                  {
                     myInQueue.Close();
                  }
                  foreach(MQQueue myOutQueue in myOutQueues)
                  {
                     if ((myOutQueue != null) && myOutQueue.IsOpen)
                     {
                        myOutQueue.Close();
                     }
                  }
                  if (mqQMgr != null)
                  {
                     mqQMgr.Disconnect();
                  }
                  System.Threading.Thread.Sleep(1000);
               }
               else
               {
                  Log.Error("Queue Name :" + inQueueName + "\nType Erreur : base\nMessage d'erreur : " + mqe.Message + "\nStackTrace : " + mqe.StackTrace );
                  mqQMgr.Backout();
                  throw;   // on relance l'exception pour stopper la transaction
               }
               #endregion
            }
            catch (Exception e)
            {
               #region Autre exception
               Log.Warning("Queue Name :" + inQueueName + "\nType Erreur : base\nMessage d'erreur : " + e.Message + "\nStackTrace : " + e.StackTrace );

               // Nettoyage et fermeture
               if ((myInQueue != null) && myInQueue.IsOpen)
               {
                  myInQueue.Close();
               }
               foreach(MQQueue myOutQueue in myOutQueues)
               {
                  if ((myOutQueue != null) && myOutQueue.IsOpen)
                  {
                     myOutQueue.Close();
                  }
               }
               if (mqQMgr != null)
               {
                  mqQMgr.Disconnect();
               }
               #endregion
            }
         }

      }


When i run the service, i've this error :
Quote:
Description :
Queue Name :TT.OUT.TO_EDI
Type Erreur : base
Message d'erreur : MQRC_HANDLE_IN_USE_FOR_UOW
StackTrace : at IBM.WMQ.MQQueue.Get(MQMessage message, MQGetMessageOptions gmo, Int32 maxMsgSize)
at IBM.WMQ.MQQueue.Get(MQMessage message, MQGetMessageOptions gmo)
at DuplicationWmq.WmqComponent.Start(String qmName, String inQueueName, ArrayList outQueueNames, ArrayList extQueues)

Pour plus d'informations, consultez le centre Aide et support à l'adresse http://go.microsoft.com/fwlink/events.asp.


I think it's because i can share a unit of work in my duplications' threads... but i'm not sure, and i don't know how to do.

Can somebody help me ?
Back to top
View user's profile Send private message Visit poster's website
wschutz
PostPosted: Mon Oct 17, 2005 2:20 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

I'm not an MTS expert, but did you see this in the Messages Manual:
Quote:

Programmer Response:

Check that the "MTS Transaction Support" attribute defined for the object's class is set correctly.
?
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
Amazone
PostPosted: Mon Oct 17, 2005 3:12 am    Post subject: Reply with quote

Novice

Joined: 17 Oct 2005
Posts: 14

Yeah, i've define a transaction attribute on my class :

Code:
   [Transaction(TransactionOption.RequiresNew)]
   public class WmqComponent : ServicedComponent
   {...}
Back to top
View user's profile Send private message Visit poster's website
Amazone
PostPosted: Tue Oct 18, 2005 12:15 am    Post subject: Reply with quote

Novice

Joined: 17 Oct 2005
Posts: 14

how can I ensure myself that my thread do not try to use the same connection handle ?
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » MQRC_HANDLE_IN_USE_FOR_UOW
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.