background preloader


Facebook Twitter

Subqueues. Mis à jour: juin 2007 S'applique à: 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. Subqueues do not have any separate properties or state, but share those of the main 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. Subqueues cannot be created under journal queues, system queues, or other subqueues. Applications can open a subqueue with access modes MQ_PEEK_ACCESS, MQ_RECEIVE_ACCESS, and MQ_MOVE_ACCESS only. Only the following APIs can be used with subqueues: Msmq/NativeMethods.cs at master from ayende/rhino-esb - GitHub. Unmanaged API “fun”, finding out MSMQ subqueues names in C# I needed to get a list of subqueues of a queue, and there is no way of actually doing that in managed code.

Unmanaged API “fun”, finding out MSMQ subqueues names in C#

I decided that I can still use P/Invoke and just make the appropriate unmanaged calls. In hindsight, it would have been significantly simpler to just build an unmanaged DLL in C++/CLR, but I was already too deep, and I can never remember how to properly compile a C++ app anymore. I finally had to slap myself a couple of times and remind me that I was a C++ developer for a long time, and I damn well should remember how to treat memory like it was something both sacred and abused. I had tested that on a Windows 2008 64 bits machine. During this project, I also found out that there is basically no information at all about this sort of thing, so I am putting the code here. public class MsmqUtil internal const int PROPID_MGMT_QUEUE_SUBQUEUE_NAMES = 27; internal const ushort VT_NULL = 1; public static unsafe string[] GetMsmqSubQueueNames(string queueFormatName) try if (result !

Return null; MQMgmtGetInfo. (Introduced in MSMQ 3.0.)


The MQMgmtGetInfo function retrieves information about a queue or the Message Queuing installation on a computer. HRESULT MQMgmtGetInfo( LPCWSTR pMachineName, LPCWSTR pObjectName, MQMGMTPROPS * pMgmtProps ); Parameters pMachineName [in] A pointer to a Unicode string that contains the name of a computer. pObjectName [in] A pointer to a Unicode string that describes the type of object: Required when retrieving information about the queue manager.

L"QUEUE=<formatname>" Required when retrieving information about a queue. pMgmtProps Return Values Indicates success. MQ_ERROR (0xC00E0001) A non-specific Message Queuing error was generated. MQ_ERROR_ACCESS_DENIED (0xC00E0025) The access rights for retrieving information about the applicable msmq (MSMQ-Configuration) or queue object are not allowed for the calling process. MQ_ERROR_ILLEGAL_FORMATNAME (0xC00E001E) The specified format name in pObjectName is illegal. MQMoveMessage. The MQMoveMessage function moves messages between a queue and its subqueue, or between two subqueues within the same main queue. HRESULT MQMoveMessage( QUEUEHANDLE sourceQueue, QUEUEHANDLE targetQueue, ULONGLONG lookupID, ITransaction* pTransaction); Parameters sourceQueue [in] A handle of the queue that the message has to be moved from.

The source queue must be opened with MQ_RECEIVE_ACCESS, and with either of the following share modes: targetQueue [in] A handle of the subqueue to which the message is to be moved. LookupID [in] The identity of the message that needs to be moved. pTransaction [in] A pointer to an ITransaction interface, a constant, or NULL. Ensures that the Message Queuing service (MSMQ) verifies that the application is running in the context of a COM+ transaction.

Specifies that the message is moved in a single-message transaction. Specifies that the call is part of an externally coordinated, XA-compliant transaction. Return Value The MQMoveMessage function returns an HRESULT.