We have a cluster of servers which run a service. This services are broadcasting transactions from one address to many different addresses. The problem now is, that they work in parallel. This means, that they always need to know the next valid nonce. Sometimes it happens that a service tries to broadcast a transaction with a nonce which is too high. For example lets say the last transaction of address "0xabc..." has the nonce 100. Now one service tries to broadcast a raw transaction with a nonce of 102 instead of the valid 101like this:
web3j.ethSendRawTransaction(rawMessageWithNonce102).send();
Is there any way of detecting the issue?
web3j of course does not through an error here, because initially the tx gets into the tx pool. But after some time its deleted from there.
How can I detect a "too high nonce issue" in my java application? Any ideas?