Solved

reading the values of MSMQ properties?

Posted on 2004-03-24
7
961 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
[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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 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.

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