Solved

Detect deletion of a messagequeue?

Posted on 2004-08-31
2
281 Views
Last Modified: 2011-04-14
Hi everyone!

I have a problem...how can I detect a deleted queue? I tried using the
IMSMQQueueInfo::Refresh() just before sending a message to an queue. If you
do the refresh before sending you´ll get a MQ_ERROR_QUEUE_NOT_FOUND and
you´ll understand that the queue is deleted...the only problem with that is
that the Refresh decreases performance, a lot!

How can I detect a deleted queue, any ideas anyone?


This is my code ( ignore the neverending loop if the queue isn´t found, the
sample is just done to show my thinking ) :

CMessageQueue::PostMessage(IMSMQQueue3Ptr q, CMessage MsgToSend)
{
    // Here I don´t know if the q is deleted or not so I try sending a
message to it
    // and if I get a MQ_ERROR_QUEUE_NOT_FOUND I try to locate it and
    // then try resending the message
    try
    {
         IMSMQQueueInfo3Ptr qi = q->GetQueueInfo();
         // Try to refresh the queueinfo
         qi->Refresh();
         q->Send(MsgToSend);
    }
    catch( _com_error comerr )
    {
        HRESULT hr = comerr.Error();
        if( hr = MQ_ERROR_QUEUE_NOT_FOUND )
        {
            // Try locate the queue and then try this postmessage-function
again
        }
    }
}
0
Comment
Question by:TYB
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 11942466
Actually

         IMSMQQueueInfo3Ptr qi = q->GetQueueInfo();

         if ( !qi) {

             // no IMSMQQueueInfo3Ptr means that queue does not exist
         }

IMHO should do it, no need to refresh...
0
 

Author Comment

by:TYB
ID: 12074093
Tnx for your answer jkr...it helped me out..
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now