java - how handle requests consumed concurrently by different instances of my rest api -
i have rest api developed java. api running in 4 servers , consumes requests stored in database.
the executor class has run() method creates connections db , retrieves 1 request queue process.
the requests being retrieved inside synchronized block , works fine. problem synchronized block avoid concurrency problem inside instance of api. doesn't controls other instances. that's problem, different instances process same request:
synchronized (lock) { executionparameters = getexecutionparametersfromqueue(dbconnection); if (executionparameters == null) return; executionparameters.setstatus(executionstatus.processing); executionparameters.updateexecutionparameters(procedurehandler, dbconnection); }
could me problem? welcome. i'm thinking in way these 4 instances communicates each other, way instances know if request retrieved has been processed other instance. how that? better solution?
thanks in advance.
Comments
Post a Comment