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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -