MessageEnumerator::RemoveCurrent Method (TimeSpan, MessageQueueTransactionType)
Removes the current message from a queue and returns the message to the calling application. If there is a message to remove, the method returns it immediately. Otherwise, the method waits the specified timeout for a new message to arrive.
Assembly: System.Messaging (in System.Messaging.dll)
public:
Message^ RemoveCurrent(
TimeSpan timeout,
MessageQueueTransactionType transactionType
)
Parameters
- timeout
-
Type:
System::TimeSpan
The interval of time to wait for the message to be removed.
- transactionType
-
Type:
System.Messaging::MessageQueueTransactionType
One of the MessageQueueTransactionType values, describing the type of transaction context to associate with the message.
Return Value
Type: System.Messaging::Message^A Message that references the first message available in the queue.
| Exception | Condition |
|---|---|
| ArgumentException | The value specified for the timeout parameter is invalid. |
| MessageQueueException | The timeout has expired. |
| InvalidEnumArgumentException | The transactionType parameter is not one of the MessageQueueTransactionType members. |
RemoveCurrent removes and returns the message at the cursor's current location, using a transaction context defined by the transactionType parameter. If the cursor is at the end of the queue, this overload of the method waits until a message is available or the interval specified by the timeout parameter has expired.
Specify Automatic for the transactionType parameter if there is already an external transaction context attached to the thread that you want to use to receive the message. Specify Single if you want to receive the message as a single internal transaction. You can specify None if you want to receive a message from a transactional queue outside of a transaction context.
If you are using queue journaling, removing the message causes a copy to be kept in the journal queue, just as the MessageQueue class's Receive method does.
When working with transactional queues, a rollback of a transaction causes any messages removed by a call to RemoveCurrent to be returned to the queue. The removal is not irreversible until the transaction is committed.
When you remove the current message, the cursor is moved to the next message. You do not have to call MoveNext after calling RemoveCurrent.
Available since 1.1