ChannelPausable not working with @RunOnVirtualThread #45795
Labels
area/virtual-threads
Issue related to Java's Virtual Threads
env/windows
Impacts Windows machines
kind/bug
Something isn't working
Describe the bug
Hello,
I'm using Smallrye Messaging RabbitMQ to consume the RabbitMQ messages to do an external Http request which have a Rate Limit (error 429) or sometimes can be temporary unavailable(error 503)
To be able to process more messages in parallel, I tried to set up the following parameter :
However, I have seen that this parameter creates as many connections as there are consumers for the queue.
I therefore tried to use the @RunOnVirtualThread annotation which works very well with a single connection, which can process 1024 messages in parallel.
However, I encounter a problem when I try to use the 'io.smallrye.reactive.messaging.PausableChannel' class to implement a pause mechanism. In order to be able to stop consuming messages when the external Http service returns us a rate limit error (429) or unavailability error (503)
Because when I use the @RunOnVirtualThread annotation, the messages are always consumed which does not happen when I do not use this annotation
However, if we initiate the service in pause mode - with the following parameter - the pause is taken into account:
Another case observed is when the RabbitMQ connection is automatically reset and the paused() method was previously called, the threads no longer consume the messages
I therefore see that the problem only occurs when I call the pause() method while the threads are consuming the messages.
Expected behavior
The messages consumption should stop when the ChannelPausable.pause() is called
Actual behavior
When using the @RunOnVirtualThread annotation and call ChannelPausable.pause(), the messages are always consumed
How to Reproduce?
To reproduce :
See below a code sample to reproduce:
Output of
uname -a
orver
135-Ubuntu SMP Fri Sep 27 13:53:58 UTC 2024 / Microsoft Windows [version 10.0.19045.5371]
Output of
java -version
21.0.2
Quarkus version or git rev
3.17.7
Build tool (ie. output of
mvnw --version
orgradlew --version
)3.9.9
Additional information
My goal is to be able to stop or resume consuming messages as I wish.
The ChannelPausable is the best solution I have found at the moment!
If there are other ways to achieve this, I'm interested.
The text was updated successfully, but these errors were encountered: