Leaving Messages in a Topic. Any ideas?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Leaving Messages in a Topic. Any ideas?

sparky2708
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?
Reply | Threaded
Open this post in threaded view
|

Re: Leaving Messages in a Topic. Any ideas?

chirino
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 <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Leaving Messages in a Topic. Any ideas?

sparky2708
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?
Reply | Threaded
Open this post in threaded view
|

Re: Leaving Messages in a Topic. Any ideas?

chirino
Sure.  Look at

On 8/8/06, sparky2708 <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Leaving Messages in a Topic. Any ideas?

James Strachan-2
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 <[hidden email]> wrote:

> Sure.  Look at
>
> On 8/8/06, sparky2708 <[hidden email]> 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/
Reply | Threaded
Open this post in threaded view
|

Re: Leaving Messages in a Topic. Any ideas?

sparky2708
In reply to this post by chirino
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?
Reply | Threaded
Open this post in threaded view
|

Re: Leaving Messages in a Topic. Any ideas?

James Strachan-2
On 8/8/06, sparky2708 <[hidden email]> 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/