You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by sparky2708 <da...@columbia.edu> on 2006/08/08 02:24:13 UTC

Leaving Messages in a Topic. Any ideas?

Hi,
I was wondering if there was some way to store messages on the ActiveMQ
server. Let me clarify. Suppose you were keeping track of a sum of numbers
and each number arrived in a message. Here is how it would work:

1. Some producer would constantly publish the numbers throughout the day

2. A number of consumers that are listening to the producer in #1 keep
summing up the numbers. If some consumer goes down or one comes up it needs
to be able to get the current sum since the beginning of the day (let's say,
since 12:00:01am) so it needs to be able to replay all the messages since
the beginning of the day to catch-up.

Any ideas on how this could be accomplished using ActiveMQ?
-- 
View this message in context: http://www.nabble.com/Leaving-Messages-in-a-Topic.-Any-ideas--tf2069895.html#a5698477
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Leaving Messages in a Topic. Any ideas?

Posted by James Strachan <ja...@gmail.com>.
BTW the MessageQuery feature is also useful - its an easy way to allow
you to add a query to send messages to new consumers to get them 'up
to speed' with other consumers.

see QueryBasedSubscriptionRecoveryPolicy and MessageQuery

http://incubator.apache.org/activemq/maven/activemq-core/apidocs/org/apache/activemq/broker/region/policy/package-summary.html

then to implement MessageQuery you could either use a Broker
Interceptor or create a consumer in the broker to maintain the
counters etc.


On 8/8/06, Hiram Chirino <hi...@hiramchirino.com> wrote:
> Sure.  Look at
>
> On 8/8/06, sparky2708 <da...@columbia.edu> wrote:
> >
> > yes, calculation is very cheap. Just a sum.
> >
> >     What you describe is exactly what I would like to do (in an ideal case).
> > We were thinking of creating  a module that would attach to an ActiveMQ
> > broker so a crashed or recently started client would ask the module for the
> > sum and then start receiving messages from the JMS.
> >
> >     Although I think ultimately the above is doable but before we take the
> > hard road it would be interested to know how to track the sum at the broker?
>
> In activemq you add your own custom broker type interceptors.  Here's
> an example one:
> http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java?revision=426366&view=markup
> That example creates 'advisory' messages that get sent to a topic when
> connections/producers/consumers are created/destroyed.  The one bit
> that is similar to your case is that when a consumer for that advisory
> topic comes on, it sends that consumer all the events that it had
> missed so that it know about all the connected
> connection/consumers/producers.
>
> In your case I think you would just need to override the
> "send(ConnectionContext context, Message messageSend)" call to keep
> your counters.  Also override the " addConsumer(ConnectionContext
> context, ConsumerInfo info)" So that you can send a message to the
> consumer with the sum when he gets created.
>
> > I guess what I am trying to find out is where on the broker do you keep it
> > (that would be the ideal solution). Can you give me some examples or point
> > me to some documentation where I can read about this functionality?
> > --
> > View this message in context: http://www.nabble.com/Leaving-Messages-in-a-Topic.-Any-ideas--tf2069895.html#a5708608
> > Sent from the ActiveMQ - User forum at Nabble.com.
> >
> >
>
>
> --
> Regards,
> Hiram
>
> Blog: http://hiramchirino.com
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Leaving Messages in a Topic. Any ideas?

Posted by James Strachan <ja...@gmail.com>.
On 8/8/06, sparky2708 <da...@columbia.edu> wrote:
> This sounds like an idea I would like to try. So I looked at:
> http://www.activemq.org/site/logging-interceptor.html for an example on how
> to install an Interceptor but I can't figure out how it knows that
> "<loggingBrokerPlugin>" refers to the interceptor class, i.e. how does that
> resolve to a particular class name?

There's some docs here

http://activemq.org/site/developing-plugins.html

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Leaving Messages in a Topic. Any ideas?

Posted by sparky2708 <da...@columbia.edu>.
This sounds like an idea I would like to try. So I looked at:
http://www.activemq.org/site/logging-interceptor.html for an example on how
to install an Interceptor but I can't figure out how it knows that
"<loggingBrokerPlugin>" refers to the interceptor class, i.e. how does that
resolve to a particular class name?
-- 
View this message in context: http://www.nabble.com/Leaving-Messages-in-a-Topic.-Any-ideas--tf2069895.html#a5711459
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Leaving Messages in a Topic. Any ideas?

Posted by Hiram Chirino <hi...@hiramchirino.com>.
Sure.  Look at

On 8/8/06, sparky2708 <da...@columbia.edu> wrote:
>
> yes, calculation is very cheap. Just a sum.
>
>     What you describe is exactly what I would like to do (in an ideal case).
> We were thinking of creating  a module that would attach to an ActiveMQ
> broker so a crashed or recently started client would ask the module for the
> sum and then start receiving messages from the JMS.
>
>     Although I think ultimately the above is doable but before we take the
> hard road it would be interested to know how to track the sum at the broker?

In activemq you add your own custom broker type interceptors.  Here's
an example one:
http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/advisory/AdvisoryBroker.java?revision=426366&view=markup
That example creates 'advisory' messages that get sent to a topic when
connections/producers/consumers are created/destroyed.  The one bit
that is similar to your case is that when a consumer for that advisory
topic comes on, it sends that consumer all the events that it had
missed so that it know about all the connected
connection/consumers/producers.

In your case I think you would just need to override the
"send(ConnectionContext context, Message messageSend)" call to keep
your counters.  Also override the " addConsumer(ConnectionContext
context, ConsumerInfo info)" So that you can send a message to the
consumer with the sum when he gets created.

> I guess what I am trying to find out is where on the broker do you keep it
> (that would be the ideal solution). Can you give me some examples or point
> me to some documentation where I can read about this functionality?
> --
> View this message in context: http://www.nabble.com/Leaving-Messages-in-a-Topic.-Any-ideas--tf2069895.html#a5708608
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Re: Leaving Messages in a Topic. Any ideas?

Posted by sparky2708 <da...@columbia.edu>.
yes, calculation is very cheap. Just a sum. 
    
    What you describe is exactly what I would like to do (in an ideal case).
We were thinking of creating  a module that would attach to an ActiveMQ
broker so a crashed or recently started client would ask the module for the
sum and then start receiving messages from the JMS. 
    
    Although I think ultimately the above is doable but before we take the
hard road it would be interested to know how to track the sum at the broker?
I guess what I am trying to find out is where on the broker do you keep it
(that would be the ideal solution). Can you give me some examples or point
me to some documentation where I can read about this functionality?
-- 
View this message in context: http://www.nabble.com/Leaving-Messages-in-a-Topic.-Any-ideas--tf2069895.html#a5708608
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Leaving Messages in a Topic. Any ideas?

Posted by Hiram Chirino <hi...@hiramchirino.com>.
Hi sparky.. is the calculation cheap to do?

You might want to keep track of the sum at the broker.  and when a new
client connects the server can just send it the sum.  We do something
similar with advisory messages.

If not, they you can always use retroactive consumers and a properly
configured redelivery policy.  See:
http://activemq.com/site/subscription-recovery-policy.html
http://activemq.com/site/retroactive-consumer.html

Regards,
Hiram

On 8/7/06, sparky2708 <da...@columbia.edu> wrote:
>
> Hi,
> I was wondering if there was some way to store messages on the ActiveMQ
> server. Let me clarify. Suppose you were keeping track of a sum of numbers
> and each number arrived in a message. Here is how it would work:
>
> 1. Some producer would constantly publish the numbers throughout the day
>
> 2. A number of consumers that are listening to the producer in #1 keep
> summing up the numbers. If some consumer goes down or one comes up it needs
> to be able to get the current sum since the beginning of the day (let's say,
> since 12:00:01am) so it needs to be able to replay all the messages since
> the beginning of the day to catch-up.
>
> Any ideas on how this could be accomplished using ActiveMQ?
> --
> View this message in context: http://www.nabble.com/Leaving-Messages-in-a-Topic.-Any-ideas--tf2069895.html#a5698477
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 
Regards,
Hiram

Blog: http://hiramchirino.com