Closed Shazhko-Artem closed 1 year ago
Receive operation can optionally has a timeout, which is really the wait time the caller wants to wait if no message is available within the said time duration. This timer implements that behavior.
@xinchen10 Thank you very much for your reply. The fact that timeout is really the wait time the caller wants to wait if no message is available within the said time duration is understandable. But it's not entirely clear what this is for. I assume that this functionality is used to handle situations when, for some reason, there is a message in the queue, but the Signal
mechanism does not work and therefore there is a timer that will forcefully read messages from the queue - but is it possible that the Signal
mechanism would not work? If this is a very real situation, could you please tell me exactly how this can happen and if can I reproduce it?
Or is this timer not designed to process messages in the queue, which for some reason were not read by the Signal
mechanism?
I would be incredibly grateful if you could give an example of when this timer functionality is needed, it would help a lot.
This timer has two purposes:
requestedMessageCount
is greater than 1, wait a very short period of time (e.g. 20ms) when the first message is added by Signal
. This part is not very obvious.Amqp has no built-in message batching feature but there is a requirement of ReceiveBatch
API. The batching behavior is implemented in the library using the timer as mentioned above.
Thanks a lot, now it's a bit clear.
Could you please explain why you need a timer in class
ReceiveAsyncResult
? TheReceiveAsyncResult
class has aCompleteInternal
method that starts the message processing mechanism. This method is called by two methodsSignal
andOnTimer
. If everything is clear with theSignal
method - it is called when a message arrives in the queue, then with theOnTimer
method, everything is not so obvious.It can also be seen that in the
Initialize
method, we have the functionality to disable the timer when the value ofthis.timeout
isTimeSpan.MaxValue
. But for some reason, in the Azure.Messaging.ServiceBus package, a validation was added within which it is impossible to specify theTimeSpan.MaxValue
value to disable the timer, so I will also ask them a question.I would be very grateful if you could explain the main function of this timer. This will allow us to better understand how your package works and create better products based on this library.