Replies: 1 comment 1 reply
-
|
Some Rebus transports (like the ones for RabbitMQ and Azure Service Bus) use PREFETCH internally, causing there to be 0 waiting time and probably no actual I/O as part of the receive loop, which makes it pretty efficient. Rebus also natively supports backing off during idle times, so it will by default wait 100 ms between polls during the first 10 seconds of running idle, and then it will poll every 250 ms after that. On most normal machines, it will look as if the CPU .isn't actually doing anything. There hasn't really been any good reason yet, in my opinion, to change the polling nature of Rebus' receive loop. I may of course be wrong 🙂 but yeah, that's currently how things work. Since the The push callback in your app could then insert messages into that queue, and your Rebus transport would then just use the normal loop in the normal way to poll for messages.
TL;DR: yes 😆 (*) For example based on @StephenCleary's brilliant AsyncEx library where you can find the nifty |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Rebus is generally working with a polling receive loop:
ReceiveAsyncis called, if there is no message (call returnsnull) then there is a short wait time andReceiveAsyncis called again.I am considering optimizing the transport I use so that there is no wait time. This might be possible because a "push" side-channel exists so that the transport would know instantly when a message is available.
To integrate this in Rebus, what I have in mind is that
ReceiveAsyncmay never return null. The task would remain pending until either the bus shuts down (by means of its cancellation token), or a message was pushed and can be instantly received.Would this be a reasonable approach? Is there a downside or problem to having
ReceiveAsyncblock for very long periods of time?Beta Was this translation helpful? Give feedback.
All reactions