Receive-MsmqQueue

Receive-MsmqQueue

Does a destructive read from a queue.

Syntax

Parameter Set: Peek
Receive-MsmqQueue -InputObject <MessageQueue> [-Count <Int32> ] [-Peek] [-RetrieveBody] [-Timeout <TimeSpan> ] [ <CommonParameters>]

Parameter Set: Transactional
Receive-MsmqQueue -InputObject <MessageQueue> [-Count <Int32> ] [-RetrieveBody] [-Timeout <TimeSpan> ] [-Transactional] [ <CommonParameters>]

Detailed Description

The Receive-MsmqQueue cmdlet does a destructive read from a queue. The Name parameter accepts path names, format names and direct format names, unlike other MSMQ cmdlets that accept only a friendly name for the queue. If –Peek is specified, the cmdlet peeks at the message instead of doing a destructive read. The cmdlet also writes the received System.Messaging.Message object to the pipeline. The cmdlet succeeds when at least one messages is returned. If the parameter -Peek is supplied, the number of messages returned by the cmdlet is the minimum of the number supplied by the parameter -Count and the number of messages in the queue.

Parameters

-Count<Int32>

Specifies the number of messages to be returned. Default is 1. Value must be greater than 0.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-InputObject<MessageQueue>

A MessageQueue object that represents the queue from which the message will be read from. Accepts pipelined input.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true(ByValue)

Accept Wildcard Characters?

false

-Peek

If specified, returns a copy of the first message in the queue without removing the message from the queue.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RetrieveBody

If specified, returns the body of the message.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Timeout<TimeSpan>

The time in milliseconds that specifies the maximum time to wait for the queue to contain a message. The default is 0.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Transactional

If specified, the cmdlet performs a transacted receive.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

Examples

Usage Example

PS C:\> Get-MsmqMessage –Name "a04bm10\private$\order_queue" | Receive-MsmqQueue –Transactional -Peek