Subqueues

Updated: June 25, 2007

Applies To: Windows Server 2008

Subqueues are implicitly created local queues that are logical partitions of a physical queue. Applications can use subqueues to group messages in a queue. For example, purchase orders sent to a main queue could be moved to the appropriate "vendor" subqueue in an order processing scenario. Subqueues also accommodate poison message handling. For example, messages can be moved from a main queue to a "non-deliverable" subqueue if the message fails delivery from the main queue after a specified number of attempts.

Subqueues do not have any separate properties or state, but share those of the main queue. Moving messages between a main queue and/or its subqueues has no impact on the quota for the queue.

Messages cannot be sent directly to subqueues, messages can only be moved from a parent queue to a subqueue, between subqueues within a queue, or from a subqueue to its parent queue.

Subqueues are created and deleted implicitly. They are created when opened and deleted when empty and have no open handles. For example, the following script could be used to create the subqueue SubQ of a public queue named TESTQ on the computer named TESTMSMQ:

Dim objInfo
Dim objQ
Dim strFormatName
strFormatName = "DIRECT=OS:TESTMSMQ\TESTQ;SubQ"
Set objInfo = CreateObject("MSMQ.MSMQQueueInfo")
objInfo.FormatName = strFormatName
Set objQ = objInfo.Open(32,0) 'MQ_PEEK_ACCESS, MQ_DENY_NONE
'Close subqueue
'objQ.Close 'this will delete the subqueue if it is empty
Set objInfo = Nothing
Msgbox "Done…"

Subqueues cannot be created under journal queues, system queues, or other subqueues. Journaled messages for all subqueues go to the journal queue of the main queue.

Applications can open a subqueue with access modes MQ_PEEK_ACCESS, MQ_RECEIVE_ACCESS, and MQ_MOVE_ACCESS only. Subqueues cannot be opened with MQ_SEND_ACCESS access.

Only the following APIs can be used with subqueues:

  • MQOpenQueue

  • MQCloseQueue

  • MQCreateCursor

  • MQReceiveMessage

  • MQReceiveMessageByLookupId

  • MQHandleToFormatName

  • MQMoveMessage

  • MQPathNameToFormatName

Any other operations with subqueues will return an error.

Community Additions

ADD
Show: