Oracle AQ same message is delivered twice
Asked Answered
R

1

7

I created a AQ in oracle and wrote 2 JMS consumers in Java to listen to the queue. I have observed sometimes that if I produce some message in to queue; the count of dequeued messages from queue is greater than what enqueued. It means that some messages are consumed twice.

I have created queue with property:- multiple_consumers => FALSE

And JMS consumers are working in CLIENT_ACKNOWLEDGE mode

Please help me learn the possible reasons for such behavior and it's solution. So, that I can replicate the problem and solve above issue and ensure that the number of message enqueued is equal to number of message dequeued in case of multiple JMS consumers listening to same AQ .

Renaldo answered 10/5, 2013 at 6:54 Comment(0)
D
3

Without having seen your code, CLIENT_ACKNOWLEDGE typically says you are sending acknowledgements manually. If you do not send an ack, the message won't get deleted and the broker will try to redeliver it at a later stage (like when you restart the connection or similar). This might be the cause of your concern.

Dote answered 11/5, 2013 at 7:46 Comment(4)
Actually the process is like Consumer consumes the message, logs it in Database table and send ACK. if there is some exception in processing then that message is moved to exception queue. I have created multiple JMS consumers because if one is off other can process consume the messages i.e; to ensure system is working efficiently and there is high availability. So, this ensures in such scenario where ACK is not done or exception is generated message is consumed once.Renaldo
Okay. But that is one of the most likely reason anyway (that an ack has not been sent). I am not familiar with the dequeue counter and how it calculates dequeues (i.e. is an unacked but sent message dequeued or not, what about a rolled back transaction etc.). Add code samples and more info in your Q for better answers.Dote
Actually, I ran such test scenarios in which i counted the number of message enqueued and number of message dequeued and the probability of getting such scenario is very rare. Actually it's like I enqueued 15K messages and dequeued it and I ran this test aroungd 20-30 times and only twice or thrice I observed that count of dequeued is greater than count of enqueued.Renaldo
So, I was looking for a reason So that I can exactly replicate the scenario in one shot and can add code to handle such intricaciesRenaldo

© 2022 - 2024 — McMap. All rights reserved.