Solved

reading the values of MSMQ properties?

Posted on 2004-03-24
7
955 Views
Last Modified: 2007-12-19

 Greetings,

    I've looked at the MSDN documentation and am getting somewhat confused on how to read the properities of an MSMQ message. Take lookupid for instance, If I have a message in a queue that was written as a 255 byte char message, and I then go to read the message out using MQReceiveMessageByLookupId which required the value of the LookupID to first get the message, how do I derive this ID?

 I saw an example where you start with the first message by setting lookupID to zero getting the first one and spinning through the rest, but what If I don't want to start with the first message in the queue? is there a way to read into a structure the 255 message that was written, AND the MQ properties of that message, like lookupId and other properties? would the structure def that reads the message in be defined in a generic sense something like:

 LookupID Char[18];
 OtherMQ_Properties Char[999];
 Msg_Body char[255];

 and once the message is read into a buffer mapped to the structure above I can simply get at the value of the message properties directly? or is there a much simpler wayt of doing this?

Thanks,

adgarcia13
0
Comment
Question by:adgarcia13
  • 5
7 Comments
 
LVL 5

Expert Comment

by:info_expert
ID: 10674583
Hi,
Well here is the proper link for your problem:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msmq/msmq_using_reading_msg_7ws2.asp

Any further help?

Regards.
0
 

Author Comment

by:adgarcia13
ID: 10678124

Actually, unless
0
 

Author Comment

by:adgarcia13
ID: 10678149

 Actually, unless I am missing something, the example you pointed me to assumes that the lookupid is being passed in to this function in this example so the lookupid was already acquired. My question was HOW do I get the lookupID to begin with?

adgarcia13
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:adgarcia13
ID: 10678485

This is the closest thing I found that speaks about how to get the lookupId of a specific message:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msmq/msmq_about_queues_19r9.asp

unfortunately, they never really explain How to retrieve the value of the property that identifies the message...
0
 

Author Comment

by:adgarcia13
ID: 10679209

 What might help here in trying to be a little more clear is why I am trying to derive lookupID. My thought is that I can read a message off a queue (lets call it QUE1), write it to another queue (which I will call QUE2), upon a successful write of the item in QUE2, delete the item off QUE1 using it's LookupId.

adgarcia13

0
 
LVL 5

Accepted Solution

by:
phyderous earned 500 total points
ID: 10683136
adgarcia,

First, I hope this clear to you reading a message from MSMQ using receive delete the message,

now for you question,

I would suggest the following senrio,

you will need a listener to peek QUE1

in the peek property you should add

ULONGLONG ullLookupId;
aPropID[i] = PROPID_Q_LOOKUPID;             // Property identifier
aVariant[i].vt = VT_UI8;                    // Type indicator
aVariant[i].uhVal.QuadPart = &ullLookupId;
i++;

then upon successfull peek

the lookupid will be in ullLookupId

then send a message to QUE2
with the relavent peeked PROPS(for example: PROPID_M_BODY_SIZE,PROPID_M_BODY_TYPE,PROPID_M_BODY)

Then use MQReceiveMessageByLookupId  with the ullLookupId of the original peeked message,

Hope it helps,









0
 

Author Comment

by:adgarcia13
ID: 10779322

phyderous,

  Finally got around to doing this and it works Great, Thank You for your help! Maybe someday the MSDN website will get better at providing a greater number of clear and concise examples on using their products. Documentation is great but a picture (or robust examples in this case) says a thousand words!

 Cheers,

 adgarcia13
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

777 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