Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you ensure there is only one client connected to Oracle AQ at any one time?

We have an Oracle AQ queue raising events.

We have Java Oracle AQ client processing those events.

For DR purposes we have another client which is always shutdown. But we had cases when the DR exercise left the second client on and this has cost us loss of events.

Is there any way programmatically or using configuration to ensure there is only only subscriber to the queue.

like image 636
chinto Avatar asked Feb 02 '26 12:02

chinto


1 Answers

There are multi-consumer queues, and single-consumer queues. Single consumer queues do not have subscribers. Any client can consume if has the access to. However, addressing your issue, you have few options, here are they in the order of ease of implementation:

Option 1: Access Control:

Oracle supports access control to dequeue at the queue level . So you can give this access to a single user, if the users are different

-> Application_A uses USER_A and only USER_A is given access to consume from QUEUE_A

Option 2: Use multi-consumer queues:

If you configured your queue as multi-consumer, and have consumer subscribing (multi-subscribers for whatever applications you use the queue for). The message will not be consumed from the queue until all subscribers have dequeued it. Hence, there can be no loss of messages for a given consumer. There are variation of this publish-subscribe model you can validate which is more suitable, but in general, a message would still be in the queue untill all subscribers consumes it or it timesout (which you can also control)

-> DR and Application_A both subscribe to multi-consumer queue QUEUE_MULTI. Each consumer (DR, Application_A) can consume (each only once) the message - as the message is not expired. The message is dequeued once all consumer have consumed it

Option 3: Use queue propagation:

Define a multi-consumer queue to propagate to another queue for which only one can dequeue from. Hence, a message received is propagated to other queues (can be remote for use of DR or other use of other applications). The message is propagated to the queue and marked as consumed by that queue once it reached. The message is not completely consumed until all consumers (incuding other queues) consumes it

-> DR and Application_A both has their own Queue for consuming these message. (QUEUE_DR, QUEUE_A). Define a multi-consumer queue QUEUE_MULTI. QUEUE_MULTI propagates to QUEUE_DR and QUEUE_A, etc. Once the message is propagated to all queues, the message is consumed from QUEUE_MULTI regardless of what happened in the respective queues QUEUE_A, QUEUE_DR

like image 172
BA. Avatar answered Feb 04 '26 02:02

BA.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!