This forum has been archived. Please start a new discussion on GitHub.

Idempotent and user exceptions


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?


  • 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.


  • Oh wow :eek: , I completely missed that chapter! Thank you for the hint I go read it right now