Home Help Center

Idempotent and user exceptions

Pompei2Pompei2 Member Lucas BeyerOrganization: none (student)Project: Arkana-FTS, an open-source Real Time Strategy game
Hello,

If I have a Slice interface like this:
interface ChatRoomMama {
    void destroy(string roomName) throws SomeUserException;
}

The semantics of destroy are: if the chat room named roomName exists, delete it and return. If it doesn't exist, do nothing and throw a SomeUserException.

Now I wonder if this method is idempotent? semantically, it is: calling it twice in a row is no problem for the server. But assume it gets called two times in a row, the first time it will delete the room, the second time it will throw the exception! So how does this go together with idempotent?

This is just an example case, I could easily return a bool instead of throwing an exception or completely ignore the case the room doesn't exist. I'm just interested on how idempotent may or may not go with such a case?

Comments

  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    Operations that cannot be executed twice with the same outcome are never idempotent. Object destruction falls into this category. For an explanation of how idempotent can trip up a client, see see Idempotency and Life Cycle Operations in the manual.

    BTW, it may be better to have your destroy operation on the chat room itself than to have it on the collection manager. That way, you do not need to track which factory created what objects, and you also don't need the SomeUserException, because you can use ObjectNotExistException instead. See Object Destruction in the manual for more detailed reasoning.

    Cheers,

    Michi.
  • Pompei2Pompei2 Member Lucas BeyerOrganization: none (student)Project: Arkana-FTS, an open-source Real Time Strategy game
    Oh wow :eek: , I completely missed that chapter! Thank you for the hint I go read it right now
Sign In or Register to comment.