【问题标题】:Can you get a list with all messages in a msmq?你能得到一个包含 msmq 中所有消息的列表吗?
【发布时间】:2016-11-16 10:46:47
【问题描述】:

我正在尝试通过脚本检查我所有 msmq 中的任何消息是否已存在超过 2 分钟。我尝试了powershell,但我得到的最接近的是获取私有队列中有多少消息,但似乎没有任何选项可以在变量中获取消息以查看它们的到达时间。这可能吗?

【问题讨论】:

    标签: powershell queue messages


    【解决方案1】:

    在另一个帖子中找到了这个答案,这正是我正在寻找的。​​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"
    }
    }
    

    【讨论】:

      【解决方案2】:

      这应该列出所有队列中的所有消息,并通过它们。

      以此为基础并展开。

      gwmi -class Win32_PerfRawData_msmq_msmqqueue -computerName $computerName |
          ft -prop Name, MessagesInQueue
      

      【讨论】:

      • 我已经使用此命令的变体到达了这一点,但这会返回所有队列的列表,我的问题是队列对象似乎没有返回列表的方法该队列中的消息。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-21
      • 2016-05-06
      • 2020-01-14
      • 2012-08-20
      • 1970-01-01
      相关资源
      最近更新 更多