I'm writing service layer for DDD app.
Services are exposed through JSON-RPC over WSS.
I'm not sure how to respond to redundant calls to service.
Some facts about the system:
- All requests must be completed within specific time or timeout exception occurs.
- If system is under heavy load it may decide to discard request (visible as timeout).
- If system is under heavy load some messages may expire in the queue (visible as timeout).
- Even if request reaches it's destination ACK may not reach user in time (visible as timeout).
- End user has right to re-invoke method if ACK didn't arrive in time.
No guarantees on request completion are given. Thus the need for idempotency.
Problem arises if we consider [4]+[5] implications:
- User invokes method setFoo(Bar).
- Entity was created but ACK didn't make it on time.
- User receives timeout and assumes that he should try again, so he re-invokes setFoo(Bar).
- Entity already exists -> hmm...
Question is: Should user get ACK or Error(I've already done that mate...)?