0

Here is my use case: I am developing a trading application and i want to send incremental stock updates (bidQty etc) to active consumers instead of the whole quote and a snapshot update to a new consumer (to start with).

Now, is it possible to override any ActiveMQ's class (implementors of Topic) to achieve this behavior? Any clues on this would be helpful .

If the same is possible in any other openSource provider, please let me know.

Petter Nordlander
  • 22,053
  • 5
  • 50
  • 84
rajTho
  • 51
  • 1
  • 4

1 Answers1

0

This is NOT a case where you simply can change the implementation of topic. You should actually avoid changing the implementation of core ActiveMQ features to solve specific business requirements. Fixing bugs and adding core messaging features is another thing.

There are multiple ways to solve your use case with regular ActiveMQ features.

Separate Sync and Update channel

I would probably divide the "sync/snapshot" channel from the "incremental update" channel.

One way is to implement the "snapshot-sync" as JMS request/reply where the consumer asks the provider for a sync, then continues to rely on incremental updates pushed via the topic.

Advisory messages and Selectors

You can also implement it all using a single topic using a mix of AdvisoryMessages and JMS Selectors.

An idea (you can do this in many ways):

Introduce two message properties: MsgType and Receiver

  • Mark each incremental update with MsgType=inc
  • Mark each snapshot with some client id of the consumer, Receiver=.
  • Have the producer listen to advisory messages from ActiveMQ and and fire a snapshot/sync message marked with Receiver= and MsgType=snapshot when there is a new client subscribing the stock topic.
  • The client subscribes with a selector of something like

MsgType='inc' OR (MsgType='snapshot' AND Receiver=<me>)

This way you can trigger snapshot syncs with specific clients as well as incremental updates for all clients.

If you start think about the dynamics you already have, you can probably think of another ten or so solutions.

Retroactive Consumers

You might have some use of a Retroactive Consumer - the example actually shows a scenario similar to yours.

Petter Nordlander
  • 22,053
  • 5
  • 50
  • 84