3 Replies Latest reply on May 21, 2007 7:16 AM by timfox

    receiveNoWait vs. receive(1L)

    sergeypk

      In the clustered ejb test I'm working on, using MessageConsumer.receiveNoWait from the clustered EJB returns null even if there are messages waiting in the queue. If I change that to receive(1L), the consumer receives all the messages successfully. Is this a bug?

        • 1. Re: receiveNoWait vs. receive(1L)
          timfox

          No, this is not a bug.

          receiveNoWait() only will return messages if they are "available" (see JMS spec). What available means is not defined.

          In our case "available" means in the client side buffer. So there is no guarantee that just because a message is in the queue it will be in the client side buffer. (This seems to be how most other providers implement it too).

          IMHO receiveNoWait is a pretty thing to do at the best of times and you should avoid it if possible.

          • 2. Re: receiveNoWait vs. receive(1L)
            sergeypk

            What word is missing in "a pretty thing"?

            Is it ok for me to change the stateless example to use receive(1L) in its EJB drain() method, then?

            • 3. Re: receiveNoWait vs. receive(1L)
              timfox

               

              "sergeypk" wrote:
              What word is missing in "a pretty thing"?


              Hmmmmm. I can't remember now, maybe "stupid", "pointless" ??


              Is it ok for me to change the stateless example to use receive(1L) in its EJB drain() method, then?


              Yes, please.