After reading the BEA Understanding Object Clustering document (there is something I don't understand. The document says:
Stateless EJBs
But surely all stateless EJBS must be idempotent. How can you not be idempotent without state?
Not enough. You need stateless and side-effect free to imply idempotent. Actually, side-effect-free is enough - state is just one kind of side effect.
What about one that returns a truly-random number? (Perhaps by getting the number from some hardware device)
Maybe this is an example of what they are talking about - in general terms a stateless component that communicates with a stateful component. It is quite common to use stateless EJBs to encapsulate business logic, and for these to access entity beans to deal with persistent data. The thing is I can't see why this would be a problem - since the stateless bean has to access the stateful component for each invocation, surely it doesn't matter where or on which cluster member each invocation of the stateless component runs. I still don't really understand what they are saying!
Would a truly random number generator be idempotent? Could you use it as if it were? It's not, because each time you call it, it returns a different number. One could say that it is, by saying that it's a function of the current time, and therefore a second call would be made at a different time and get a different number. In a practical sense, as an EJB, you should call it idempotent, because you can safely call it any number of times and freely use the result of the last call. In other words, no "damage" is done by making a call and discarding the result.
"Transfer $200 from savings to checking" can easily be implemented as a stateless call. But it's not idempotent: If it worked, you don't want to do it again.
Perform transaction 2747262 transferring $200 could be idempotent.
Manipulating real-devices can be stateless but not idempotent. Ask a lever to move down 2 inches requires no state but does not give the same results.
OK - I understand now. What they are saying is that in the event of failover you have two options:
[See IdempotentDesign]
Summary
A middle tier component can be stateless in its relationship with the client, while participating in idempotent or non-idempotent operations on the persistent store side. The seeming paradox (stateless but not idempotent?) goes away when we bring back the context of the three tier architecture.