【发布时间】:2016-11-16 10:46:47
【问题描述】:
我正在尝试通过脚本检查我所有 msmq 中的任何消息是否已存在超过 2 分钟。我尝试了powershell,但我得到的最接近的是获取私有队列中有多少消息,但似乎没有任何选项可以在变量中获取消息以查看它们的到达时间。这可能吗?
【问题讨论】:
标签: powershell queue messages
我正在尝试通过脚本检查我所有 msmq 中的任何消息是否已存在超过 2 分钟。我尝试了powershell,但我得到的最接近的是获取私有队列中有多少消息,但似乎没有任何选项可以在变量中获取消息以查看它们的到达时间。这可能吗?
【问题讨论】:
标签: powershell queue messages
在另一个帖子中找到了这个答案,这正是我正在寻找的。p>
[String]$cName = $Env:COMPUTERNAME
[Reflection.Assembly]::LoadWithPartialName("System.Messaging") | out-null
[System.Messaging.MessageQueue[]]$queues = [System.Messaging.MessageQueue]::GetPrivateQueuesByMachine($cName.ToLower())
Foreach ($queue in $queues) {
$queue.MessageReadPropertyFilter.SetAll()
try {
[System.Messaging.Message]$message = $queue.Peek(10)
Write-Host $queue.QueueName $message.ArrivedTime
}
catch {
#Write-Host "Timeout"
}
}
【讨论】:
这应该列出所有队列中的所有消息,并通过它们。
以此为基础并展开。
gwmi -class Win32_PerfRawData_msmq_msmqqueue -computerName $computerName |
ft -prop Name, MessagesInQueue
【讨论】: