I am building a system that should consist of 3 servers, and the same Java service (Spring mvc) will work on all 3 of them. The service will be able to perform 3 categories of tasks, i.e. A, B, and C.
I want each service on the servers to perform only one category when communicating with another server. If one server dies, the remaining servers must negotiate, and only one of them must accept the category.
Example:
Server 1 - Service A
Server 2 - The service runs B
Server 3 - Service Runs C
Server 2 is dying
Server 1 and server 3 negotiate
Server 1 - Service Runs A and B
Server 3 - Service Runs C
If server 2 returns to normal, it should accept a category from server 1 (A or B)
Is there any pattern, architecture, technology, link that can help me solve this problem?