Context: I have a client that can connect to 3 local-network nodes to distribute query-loads and be more resilient to network/software issues. I have managed to create a -simple- watch-dog with a background-thread monitoring nodes health-status and updating the list of nodes to send the next query to. Other modules can query the watch-dog and request a suitable web3j object for next requests. This is working properly, and when I switch-off a node, requests automatically skip the non-responding local node.
Problem: The "problem" comes when trying to use web3j-generated wrapper contract objects. Each self-generated contract, due to the API design is tied for its life-time to the life-time of a web3j instance when passing a web3j reference at deploy/load instantiation time. To be able to continue using the watch-dog functionality I'm forced to create N proxy-contracts instances for each of the N local-network nodes. It works, but code looks "patchy".
Question: Is there any cleaner method to solve the problem. For example, is there a way for a single web3j instance to change underlying JSON-RPC connections transparently at runtime or for a single contract proxy to switch the underlying web3j instance/connection?