online-auction-java icon indicating copy to clipboard operation
online-auction-java copied to clipboard

Use a Cluster Singleton for the AuctionScheduler

Open TimMoore opened this issue 8 years ago • 3 comments

AuctionScheduler is not cluster aware: it will run its scheduled task on all nodes.

We should demonstrate use of a cluster singleton to ensure it only runs on one node.

(We should port this change to Scala as well.)

TimMoore avatar Feb 17 '17 05:02 TimMoore

Technically there's no problem with this, the worst that will happen is that duplicate commands get sent to end the auction, but the auction entity is tolerant to this.

jroper avatar Feb 20 '17 08:02 jroper

I agree that it isn't important in this specific case, but since this is the go-to example for scheduled tasks, and since many use cases will require a cluster singleton, I still think it's worth doing here as an example for others.

TimMoore avatar Feb 20 '17 08:02 TimMoore

For that we should probably provide an abstraction in Lagom, perhaps offering the ability to schedule something once on every node, to schedule something as a cluster singleton, and to distribute a list of scheduled tasks across all the nodes.

jroper avatar Feb 21 '17 00:02 jroper