lagom / online-auction-java

Other
130 stars 109 forks source link

Use a Cluster Singleton for the AuctionScheduler #27

Open TimMoore opened 7 years ago

TimMoore commented 7 years ago

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

jroper commented 7 years ago

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.

TimMoore commented 7 years ago

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.

jroper commented 7 years ago

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.