-
1. Re: discarding consumer messages.
timfox Jan 30, 2009 5:50 AM (in response to ataylor)It's easier and more efficient to reject messages at the server and not the client.
What need is a header in a message HDR_SOLO_MESSAGE (or whatever).
I sent a stock price to the queue and set the HDR_SOLO_MESSAGE to the stock ticker symbol e.g. RHT.
When the queue receives the message, it checks to see if HDR_SOLO_MESSAGE is present, if so, it looks in its local map to see if there is already a message in the queue with the same value of HDR_SOLO_MESSAGE.
If not, then it just adds the message as normal to the queue as normal. If so, then it removes the older reference with that header value before adding it.
In such a way there will only be the latest message for each stock ticker value in the queue at any time. I.e. only the latets price would be available.
This can be done by subclassing QueueIpl and adding the map and extra check on routing. -
2. Re: discarding consumer messages.
ataylor Jan 30, 2009 6:08 AM (in response to ataylor)Ok, that makes sense.
I guess the we just add a new queue setting and the queuefactory can make the correct kind of queue needed. -
3. Re: discarding consumer messages.
gozilla Feb 3, 2009 9:23 AM (in response to ataylor)Shouldn't we use the TTL for that ?
Say, put a TTL of the lentgh of validity period for the stock price.
That way, if the consumer is slow, old (outdated) messages are discarded, leaving only the fresh ones in the queue.
François -
4. Re: discarding consumer messages.
ataylor Feb 3, 2009 9:28 AM (in response to ataylor)that assumes that the rate these messages are sent are consistent and you know what the interval is. You wouldn't want to delete a message if a replacement hadn't arrived and vice versa you wouldn't want to keep a message even tho a newer one had arrived but the TTL hadn't. expired
-
5. Re: discarding consumer messages.
timfox Feb 3, 2009 9:31 AM (in response to ataylor)"gozilla" wrote:
Shouldn't we use the TTL for that ?
Say, put a TTL of the lentgh of validity period for the stock price.
That way, if the consumer is slow, old (outdated) messages are discarded, leaving only the fresh ones in the queue.
François
Sure, nothing is stopping you setting a TTL on the message, that will work too, if that's what you want.
However the semantics of this are slightly different as Andy mentioned.