Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Detect deletion of a messagequeue?

Posted on 2004-08-31
2
Medium Priority
?
292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  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 video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

705 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