Solved

Detect deletion of a messagequeue?

Posted on 2004-08-31
2
288 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
object modeling - load and save functions 5 62
Unable to start eclipse ? 17 154
How to print into std::string like sprintf using C++11? 12 86
Finding Divisors 5 21
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

820 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