qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rajith Attapattu <rajit...@gmail.com>
Subject Re: onMessage() always acknowledges msg even if Session is set to CLIENT_ACK
Date Thu, 10 Mar 2011 23:12:48 GMT
On Wed, Mar 9, 2011 at 4:03 PM, Chris Sears <csears@gmail.com> wrote:

> Hi Kim,
>
> Just to add to Rajith's comments, it sounds like you may be trying to use
> the ring queue, onMessage(), queue browsing and client acknowledgements in
> a
> way they were not designed to work.
>
> If you have multiple clients that all need to read the same message, the
> message producer should be sending the messages to a topic exchange and not
> a direct exchange. With a topic exchange, the producer sends messages to a
> named topic just like a named queue, but the broker will delivery a copy of
> each message to every client who is subscribed to that named topic. Using
> this model, you could safely auto-acknowledge messages using onMessage()
> since every client has it's own copy of the message. This also has the
> benefit of not relying on the queue being a ring queue to keep the number
> of
> messages in check.
>
>
Please note that topic exchange and direct exchange does not directly
correspond to Topics and Queues.
The exchanges are nothing but an implementation of a particular routing
algorithm.
In direct exchange the routing key is directly matched to the binding key
and in topic exchange a wild card match is done.

You can still do Topics with the direct exchange by binding several queues
with the same binding key.
So any message sent with a matching routing key will end up in all those
queues.

Ex. Using the new addressing syntax you can define a Topic as follows.
"amq.direct/hello"
       If you use that address and create several consumers, then all those
consumers will have a private temp queue bound to the amq.direct exchange
using "hello" as the binding key.
       If a producer is created using that address and sends messages, those
messages will end up in all those queues.



> There's a good overview of how direct and topic exchanges work here:
>
> http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_MRG/1.3/html/Messaging_User_Guide/chap-Messaging_User_Guide-Exchanges.html
>
> You mentioned that you can't change how the message producer is sending
> messages. You might confirm that the exchange type isn't configurable from
> a
> settings or properties file, perhaps as a connection/queue URL.
>
> I believe you meant to say that the exchange type *is* configurable ?
As an aside please don't use the old binding URL syntax.
Please use the new addressing scheme defined here.
http://qpid.apache.org/books/trunk/Programming-In-Apache-Qpid/html/index.html


> If you really are stuck with trying to read from a direct exchange, I don't
> think onMessage will work for you, at least not in the normal pattern of
> usage. Only a single subscriber will ever receive the onMessage() for a
> direct exchange message.


Sorry this is incorrect.
You can certainly have multiple consumers with the same binding key on a
direct exchange.
And all those consumers will get the same message.


> Even if you use onMessage() to be notified of a new
> message, never acknowledge the message, and then use the queue browser to
> read all the messages in the queue, you still have a number of problems...
> Under normal conditions, the broker expects someone (eventually) to
> acknowledge the message. There's no guarantee that the broker will attempt
> to redeliver the message to each client in succession, meaning that some
> clients might miss the message. The second problem is that if you use the
> queue browser to read messages you might have missed, your clients then
> need
> to keep track of which messages are new to them and which they've already
> seen before.
>
> I may have misunderstood your situation, but if not, I would strongly
> recommend you use the topic exchange -- it's really the correct tool for
> the
> job.
>
> Good luck,
>
>  - Chris
>
> On Wed, Mar 9, 2011 at 2:47 PM, Kim Garcia <jsmam97@hotmail.com> wrote:
>
> >
> > Hi Rajith,
> >
> > It doesn't matter if the apps are consumers or queue browsers as long as
> > they share the messages (or get their own copy).
> >
> > I'm looking into using the javax.jms Topic object as suggested, but do
> the
> > messages have to be sent to a topic instead of a queue? If so, then that
> > won't work for me. I have messages being sent to an AMQ queue, and at
> this
> > time, that cannot change.
> >
> > Thanks,
> > Kim
> >
> >
> >
> ----------------------------------------------------------------------------------------------------------------
> >
> > The answer below is assuming that all your apps are consumers and not
> queue
> > browsers.
> > If thats not the case then please let me know.
> >
> > Rajith
> >
> > On Wed, Mar 9, 2011 at 9:53 AM, Rajith Attapattu <rajith77@gmail.com>
> > wrote:
> >
> > > Kim,
> > >
> > > If you want all the apps (consumers) on the same queue to get all the
> > > messages in the queue, then using 'Queues (as in JMS terms)' is not
> going
> > > to do it.
> > > As in a shared queue situation the messages will be distributed among
> > them.
> > >
> > > Therefore you should use a Topic and all your consumers will get a copy
> > of
> > > every message sent to that topic.
> > >
> > > Regards,
> > >
> > > Rajith
> > >
> > >
> > > On Wed, Mar 9, 2011 at 12:05 AM, Kim Garcia <jsmam97@hotmail.com>
> wrote:
> > >
> > >>
> > >> Rajith,
> > >>
> > >> I have been trying to respond to your email all day but Hotmail keeps
> > >> saying the delivery has failed...
> > >>
> > >>
> > >>
> >
> ----------------------------------------------------------------------------------------------------------------------------
> > >>
> > >> Thank you for looking into this, Rajith.
> > >>
> > >> I'm not using any
> > >> tools to verify if the message has been acked. I am running 2 of the
> > >> same Java application. If I only run one, then it will get the
> messages
> > >> like normal. If I run 2, they do not both get the same messages. I see
> > >> that if app #1 gets message #1, then app #2 will not get message #1.
> The
> > >> same applies for messages app #2 gets -- app #1 will not get them. I
> > >> would like several apps to monitor the same queue with a listener and
> > >> for all apps to get all of the messages.
> > >>
> > >> Thanks.
> > >>
> > >> > Date: Mon, 7 Mar 2011 18:07:19 -0500
> > >> > Subject: Re: onMessage() always acknowledges msg even if Session is
> > set
> > >> to CLIENT_ACK
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message