Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prioritising Messages 2

Status
Not open for further replies.

ivpotter

Programmer
Jan 19, 2001
13
0
0
GB
I am trying to write an application that can write messages to a queue with different priorities such that it might write a message with a low priority then one with a high priority then another with a medium priority. I then want another application to have the option of reading these off in priority order such that it would receive the messages in the order 2, 3, 1. The messages have nothing to do with each other so they are not being written within a group. I also do not want to force the receiving application to receive them in priority order so simply setting the MSGDLVSQ value is not an option although if this is set to PRIORITY then I do get them in the desired order which suggests to me that my processing is correct when I am putting the messages to the queue.

On the receiving side I am specifying MQGMO_LOGICAL_ORDER for the MQGET call but this does not work - can anyone tell me what I am doing wrong please.

Many thanks

Ivor
 
Basically you can't do it, at least not easily.

When you do MQGET, MQ gives you the next available message. WHICH message is next can be affected by many things such as CORRELID, browse cursor position etc. But in all cases, if the queue is set to priority delivery, messages will be examined in priority order to determine which is the next available message for the specifications that you have given.

The only way I can think of is to use a FIFO queue and manually browse through the whole queue reading each message's priority, sorting them into priority sequence and then getting messages in that order, specifying the relevant CORRELID in each case. This is messy and can cause problems if other apps are reading from the queue.

Hope this helps,
Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top