Subqueues

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

Message queuing (MSMQ) applications often require messages to be grouped based on some criteria. Previously, the only way to do this was to create several queues and, when a message arrived in the main queue, move the message into a specific queue based on some selection criteria. Moving messages between physical queues is a resource-intensive process. The subqueues feature enables you to logically group messages in a queue without creating another physical queue.

What are Subqueues?

Subqueues are implicitly created local queues that are logical partitions of a physical queue. Applications can use subqueues to group messages. Subqueues are implicitly created when opened, are deleted when empty, and have no open handles. Messages cannot be sent to a subqueue. Messages can be received from subqueues, moved between the main queue and its subqueue, or moved between a pair of sibling subqueues.

Subqueues do not have their own properties or state, but share the properties and state of their parent queue. For example, a subqueue does not have its own quota, access control list (ACL), or transactional type.

Subqueues share the quota of the main queues. Messages in the subqueues consume the quota of the main queue.

Subqueues cannot be created under journal and other system queues, or other subqueues. If journaling is enabled, copies of messages that are removed from a subqueue are sent to the journal queue of the main queue.

Subqueues are created implicitly, so only the following APIs can be used with subqueues: MQOpenQueue, MQCloseQueue, MQCreateCursor, MQReceiveMessage, MQReceiveMessageByLookupId, MQHandleToFormatName, MQMoveMessage, and MQPathNameToFormatName. Calling any of the other Message Queuing APIs returns an error.

Security of a Subqueue

A subqueue inherits the security properties of its main queue. The security of the subqueue cannot be set directly. Calling the MQSetQueueSecurity or MQGetQueueSecurity function on a subqueue returns the MQ_ERROR_UNSUPPORTED_FORMATNAME_OPERATION error.

Why Use Subqueues?

Subqueues are useful in the following scenarios:

  • Work order processing. If an application processes messages that contain line items from different work orders, it can use subqueues to group the line items by order for more efficient processing.

  • Poison message handling. If an application receives a message that it cannot process, it can move the message to a "fault" subqueue to be processed separately.

See Also

Creating a Sub Queue
MQMoveMessage
Locating Queues
Queue Properties
MQCloseQueue
MQCreateCursor
MQHandleToFormatName
MQDeleteQueue
MQMgmtGetInfo
MQReceiveMessageByLookupId
MQReceiveMessage
MQPurgeQueue