Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait-RabbitMqMessage drains queue with one run #27

Open
kensel opened this issue Dec 10, 2018 · 3 comments
Open

Wait-RabbitMqMessage drains queue with one run #27

kensel opened this issue Dec 10, 2018 · 3 comments

Comments

@kensel
Copy link

kensel commented Dec 10, 2018

Hello,

I'm using the module and when I run Wait-RabbitMqMessage it removes all messages but only returns 1 output. Trying to understand if this is the expected behavior as I expected it to be more like the Get-RabbitMQMessage where it would return 1 object per run as Wait-RabbitMqMessage doesn't have the count parameter.

Get-NetIPAddress | Select-Object -ExpandProperty IPAddress | Send-RabbitMQMessage -Exchange TestFanExc -Key 'TestQueue'-Persistent @Params -SerializeAs "text/plain"

$Incoming = Wait-RabbitMQMessage -Exchange TestFanExc -Key 'TestQueue' -QueueName TestQueue2 -Timeout 120 @Params
$Incoming
# ::1

Thank you,
Kensel

@derekmwright
Copy link

Similar to #23

You should pipe this to a for-each loop and process messages and/or do assignment within that loop.

@kensel
Copy link
Author

kensel commented Dec 11, 2018

Hello derekmwright,
I tried changing to:

Wait-RabbitMQMessage -Exchange TestFanExc -Key 'TestQueue' -QueueName TestQueue -Timeout 120 @Params -LoopInterval 5 | ForEach-Object { Write-host $_}
#And
Start-RabbitMqListener -Exchange TestFanExc -Key 'TestQueue' -QueueName TestQueue @Params | ForEach-Object { Write-host $_}

But the first one still drains the queue while only outputting one item and the second outputs the number of messages but the same message (28 lines of '::1').

@yuvalmarciano
Copy link
Contributor

yuvalmarciano commented Oct 21, 2020

Try to turn on the -RequireAck flag (it's not optimal, but that's the current solution I have for you).
From the function's docstring:

.PARAMETER RequireAck
        If specified, require an ack for messages
        Note: Without this, dequeue seems to empty a whole queue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants