Hi,
It stopped working with more recent rabbitmq-releases, so it blocked me from upgrading rabbitmq as well.
Now I have to upgrade rabbitmq from 3.5 to 3.7 for other reasons and therefore need a fix for my powershell-script. I chose RabbitMQ.Client 5.1.0, no reason not to go to the latest release.
The old code is using RabbitMQ.Client.QueueingBasicConsumer, which I need to change to RabbitMQ.Client.Events.EventingBasicConsumer.
This is what I try:
$consumer = New-Object RabbitMQ.Client.Events.EventingBasicConsumer($channel)
$a = function x( $c, $ea) {
$body = $ea.Body
$props = $ea.BasicProperties
$messageJson = $enc.GetString($body)
Write-Warning $messageJson
$channel.BasicNack($ea.DeliveryTag, $false, $true)
}
Register-ObjectEvent $consumer -EventName "Received" $a
$autoAck = $false
$consumerTag = $channel.BasicConsume($queue, $autoAck, $consumer, [type]::Missing,[type]::Missing,[type]::Missing,[type]::Missing)
I'd be extremely surprised if the event worked, but the call to $channel.BasicConsume fails, so that's to be solved later...
The current error is: Cannot find an overload for "BasicConsume" and the argument count: "7".
But as far as I can tell, 7 should be correct?
if I try $channel.BasicConsume($queue, $autoAck, $consumer, $null,$null,$null,$null)
instead, the powershell simply crashes. I'm not surprised, "Missing" seams much more reasonable.
Obviously, I started with $channel.BasicConsume($queue, $autoAck, $consumer), but it's wrong argument count again.
Passing named parameters to .net-code is not supported by powershell.
So, any ideas? Somebody got a solution?
Pull would work, but I'd like to avoid it.
Best regards
Patrick