¿Cómo lograr una aplicación de múltiples consumidores para una base de datos compartida (multiusuario)?
Frecuentes
Visto 96 equipos
-2
A continuación Snapshot
es actual application flow
.
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.
Expectativa
How to achieve the same with all databases at application level and not at query level ?
1 Respuestas
0
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
UPDATE TABLE_NAME SET SERVER_INSTACE_ID=UNIQUE_VAL AND ROWNUM <= RECORD_RESERVATION_LIMIT
SELECT * FROM TABLE_NAME WHERE SERVER_INSTANCE_ID=UNIQUE_VAL
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 java database multithreading oracle11g multi-tenant or haz tu propia pregunta.
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
@coreJavare i think u havent read that helper updates user status in database. - Prateek
SMSHelper should check status of sent flag "JUST BEFORE" sending sms so it wont send other sms - coreJavare
@Mat Thanks, Is it fine now. - Prateek
@coreJavare Suppose both the helper checked status simultaneously, then in that case too, multiple sms will be sent. - Prateek