Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Detect deletion of a messagequeue?

Posted on 2004-08-31
2
Medium Priority
?
295 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 750 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

926 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