Open Jivko1212 opened 7 years ago
We encountered the same Problem in our code. We polled an inbox, because the receive method does not take a cancellation token as a parameter. If the receive encountered the timeout, then the message was not received with the next call. We now implemented our own inbox that also supports cancellation. This was the unit test that reproduced the Problem for us (pretty much the same like in the original post):
[Fact]
public async Task NotReceiveMessageAfterFirstTimeoutReachedWhilePolling()
{
// Arrange
var inbox = Inbox.Create(Sys);
// Act
try
{
await inbox.ReceiveAsync(TimeSpan.FromMilliseconds(500));
}
catch (Exception)
{
// Timeout
}
var secondReceive = inbox.ReceiveAsync(TimeSpan.FromMilliseconds(500));
inbox.Receiver.Tell(123);
// Assert
var result = await secondReceive;
result.Should().Be(123);
}
If there is no message in the inbox and receive is called and timeouts the next message is lost. The following code demonstrates the issue:
The last receive timeouts. If we comment the line in the try statement it receives an ActorIdentity from the Guardian.