¿Cómo lograr una aplicación de múltiples consumidores para una base de datos compartida (multiusuario)?

A continuación Snapshot es actual application flow.enter image description here

Flujo de corriente

Cuándo user Logged in at these multiple deployments, then respective SMSAgent(java class) insert user info in database, SMSHelper es un java Scheduler which reads data from database in its local queue,send SMS y luego update user status in database.

Issue with this flow

Now,In above scenario, Multiple SMS is getting send to Single User because database is common and both the notification helper takes contact details from database(which may be common) and send SMS to that user.

Solución existente

Currently, solution to this problem is only available in oracle 11g where select query has for update skip locked support.


How to achieve the same with all databases at application level and not at query level ?

preguntado el 28 de mayo de 14 a las 14:05

you can add an additional column that indicates sms is sent so that if onc helper class send sms it will update that column then other helper class can check that column just before sending sms -

@coreJavare i think u havent read that helper updates user status in database. -

SMSHelper should check status of sent flag "JUST BEFORE" sending sms so it wont send other sms -

@Mat Thanks, Is it fine now. -

@coreJavare Suppose both the helper checked status simultaneously, then in that case too, multiple sms will be sent. -

1 Respuestas

First,you have to RESERVA the row by update and then do select.

Suppose u have 200 row,

so first you should do is RESERVA by some value which are unique by instance, also you could limit on no of rows updated in your query and then select the row which are reserved by your query



Through this approach, you don't need to obtain lock on row or table.

Respondido el 20 de junio de 20 a las 10:06

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.