Message acknowledgements

This commit is contained in:
Neil Alexander 2021-11-03 15:45:51 +00:00
parent fb365a1bec
commit eb07c2d5d7
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
8 changed files with 52 additions and 0 deletions

View file

@ -74,10 +74,12 @@ func (s *OutputRoomEventConsumer) onMessage(msg *nats.Msg) {
if err := json.Unmarshal(msg.Data, &output); err != nil {
// If the message was invalid, log it and move on to the next message in the stream
log.WithError(err).Errorf("roomserver output log: message parse failure")
_ = msg.Nak()
return
}
if output.Type != api.OutputTypeNewRoomEvent {
_ = msg.Nak()
return
}
@ -87,7 +89,11 @@ func (s *OutputRoomEventConsumer) onMessage(msg *nats.Msg) {
// Send event to any relevant application services
if err := s.filterRoomserverEvents(context.TODO(), events); err != nil {
log.WithError(err).Errorf("roomserver output log: filter error")
_ = msg.Nak()
return
}
_ = msg.Ack()
}
// filterRoomserverEvents takes in events and decides whether any of them need