RamblingCookieMonster / RabbitMQTools

PowerShell module containing cmdlets to manage RabbitMQ.
http://ramblingcookiemonster.github.io/RabbitMQ-Intro/
MIT License
31 stars 22 forks source link

Breaking change in RabbitMQ 3.7.0: Get-RabbitMQMessage missing parameter ackmode #33

Open Spamme1 opened 6 years ago

Spamme1 commented 6 years ago

The RabbitMQ 3.7.0 has introduced a breaking change in the parameters to get messages from the queue:

https://github.com/rabbitmq/rabbitmq-management/issues/68 https://github.com/rabbitmq/rabbitmq-management/issues/521 https://github.com/rabbitmq/rabbitmq-server/issues/1496

Invoke-RestMethod : {"error":"bad_request","reason":"[{key_missing,ackmode}]"}
At C:\Program Files\WindowsPowerShell\Modules\RabbitMQTools\1.2\Public\Get-RabbitMQMessage.ps1:131 char:13
+             $result = Invoke-RestMethod $url -Credential $Credentials ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Invoke-RestMethod : {"error":"bad_request","reason":"[{key_missing,ackmode}]"}
At C:\Program Files\WindowsPowerShell\Modules\RabbitMQTools\1.2\Public\Get-RabbitMQMessage.ps1:131 char:13
+             $result = Invoke-RestMethod $url -Credential $Credentials ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

This quick fix in the Get-RabbitMQMessage.ps1 is working

$body = @{
    "count" = $Count
    "requeue" = -not [bool]$Remove
    "encoding" = $Encoding
    "ackmode" = @("ack_requeue_true","ack_requeue_false")[[bool]$Remove]
}