credo-ts
credo-ts copied to clipboard
Prevent double processing of messages
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
Another approach could be
- upon the recipient receiving
deliveryresponse from the mediator do not directly emitAgentMessageReceivedEventhere, instead store those messages in memory (as a list of messages to be received) - Recipients send
messages-receivedto 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
AgentMessageReceivedEventevent with messages taken from the memory stored during thedeliveryresponse.