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

Queued messages aren't processed sometimes #82

Closed
ForNeVeR opened this issue Sep 29, 2019 · 0 comments · Fixed by #84
Closed

Queued messages aren't processed sometimes #82

ForNeVeR opened this issue Sep 29, 2019 · 0 comments · Fixed by #84
Assignees
Labels

Comments

@ForNeVeR
Copy link
Member

Right now I'm in the state when there's always one message in the queue:

[20:37:30 DBG] Current queue state: { Messages =
            seq
              [OutgoingMessage { author = "@fvnever"
                                 text = "???" };
               OutgoingMessage { author = "@fvnever"
                                 text = "????? ?????? ?? ????." }]

After that, one message gets sent, but the queue still contains one.

Probably this code is the culprit:

let! msg = inbox.Receive()
let newState =
match msg with
| QueueMessage m ->
let newMessages = Queue.conj m state.Messages
{ state with Messages = newMessages }
| SetReceiveStatus status ->
{ state with ReadyToAcceptMessages = status }
let! newState = processState ctx newState
return! loop newState

Here, we always await the incoming actor message first before doing anything else. But we should probably process the queue first, or maybe perform TryReceive to check if we have any messages. We should perform Receive() only on empty queue or if the queue is locked (by SetReceiveStatus false).

@ForNeVeR ForNeVeR self-assigned this Sep 29, 2019
ForNeVeR added a commit that referenced this issue Sep 29, 2019
Now the MessageSender code only blocks on incoming message when it is
absolutely necessary. In other cases, it will try to peek a new message,
and will flush the queue if there're no incoming messages.
This was referenced Sep 29, 2019
ForNeVeR added a commit that referenced this issue Oct 1, 2019
Now the MessageSender code only blocks on incoming message when it is
absolutely necessary. In other cases, it will try to peek a new message,
and will flush the queue if there're no incoming messages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant