Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Oracle Advanced Queue and Java Messaging System(JMS)

Re: Oracle Advanced Queue and Java Messaging System(JMS)

From: Martic Zoran <>
Date: Thu, 14 Apr 2005 03:43:22 -0700 (PDT)
Message-ID: <>


Comments inline.

> How are the messages distributed between these
> consumers ?

For me nicely, because all processes (UNIX threads in my case) are spending similar amount of time on processing messages, have the similar behaviour of how they are reading the messages and so on.

Imagine all processes running that the same SQL that is doing locking for update skip locked.

If your processes are going to do different things dependant on the message, then who knows which kind of share can happen to you because some processes are doing slower business logic, some faster, so reading messages slower or faster.

> Does each consumer of this queue get to see each
> message ? I think not.

Yes, if the queue has multiple differently registered consumers, or to simple say the queue is mutli-consumer.

In my case NO, because I have multiple consumers but all registered with the same name, but this is the setup detail I cannot even remember now. Check Oracle AQ (or Stream AQ in 10g) guide for all possibilities.

>From the SQL I already sent (the second in enqueue, it
should be the first stated) it is clear that you will read and lock the first message that is not locked, but of course you will inspect all messages currently locked by other processes, because SELECT statement is the same for all consumers.

This line is telling you how you are skipping locked (in read mode already by somebody else): for update skip locked

Of course this is all done on the server side, not implicating so many network roundtrips for you. When you lock the message it will be sent to you.

So, very standard idea behind as I am sometimes using when having multiple simle table consumers. At the end the queue in Oracle is the table :)
Just they have the logic and interface tested for you for free (my developers wanted to invent AQ themselves, if I did not stop them they will spent crazy amount of time simulating the same).

> Therefore is it true that having more than one
> consumer on a queue makes sense
> only when you want to distribute the processing of
> the queue messages to
> multiple processes (=consumers), for reasons such as
> splitting the load etc ?

Of course. If you need to process all messages in some time you need more consumers.

> The JMS specification says:
> "Although it is possible to have two sessions with a
> QueueReceiver for the same
> queue, JMS does not define how messages are
> distributed between the
> QueueReceivers."

You can manage that if you need with making some Queuereceiver sleeping more in your business logic if needed :)

> Does Oracle AQ (whether using or not JMS) define
> this ? Do you even care about
> this, or it's of no relevance, since you simply want
> to distribute the work of
> processing messages between several consumers and
> care not what messages goes to
> where ?

I cannot remember any automatic load details for the moment, or at least I did not use them.
Messages may be ordered and things like that, but cannt remember any loading details, like preventing some process to not read the message because you already read 10 messages.
Cannot see any logic behind and not sure is it needed on the Oracle server side at the end, because the client process is the process reading this messages directly.


Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
Received on Thu Apr 14 2005 - 06:47:23 CDT

Original text of this message