credo-ts icon indicating copy to clipboard operation
credo-ts copied to clipboard

Prevent double processing of messages

Open TimoGlastra opened this issue 3 years ago • 1 comments

When a message is received from the mediator, and we don't ack the message immediately (in pickup v2 protocol) and e.g. the app is closed, the mediator won't delete the message and will potentially redeliver the message. We should look at a way to keep track of processed messages and not process already processed messages.

Something like a log of processed messages could help here. This is only needed for messages received through pickup protocol

TimoGlastra avatar Sep 17 '22 09:09 TimoGlastra

Another approach could be

  • upon the recipient receiving delivery response from the mediator do not directly emit AgentMessageReceivedEvent here, instead store those messages in memory (as a list of messages to be received)
  • Recipients send messages-received to the mediator and the mediator should respond with an acknowledgment of messages being deleted.
  • Upon the recipient receiving the acknowledgment, the recipient should now emit AgentMessageReceivedEvent event with messages taken from the memory stored during the delivery response.

Zzocker avatar Sep 17 '22 14:09 Zzocker