The use case here goes like this:
- I have a data/value publisher
- I have multiple value consumer (or subscribers), that when they start needs to read/get the value, and then subscribe to subsequent updates
The goal is to have both publisher and subscribers only do "one" thing.
Example: A publisher publishes outside.temperature=28
and multiple subscribers would react on that new information, such as turning on heaters, sending a text message saying "bring long johns" and update some graphics on some monitor.
What I have today (working) is Apache ActiveMQ with queues where any subscriber can query outside.temperature
and have the publisher (re-)send it's latest value. Replies are sent to the consumer that sent the query (reply-to queue).
New values are published to a topic with the same name (outside.temperature
).
Every time a subscriber (re-)starts, this happens: query for the current state, subscribe to updates.
This all seems overly complex since the subscriber will have to know how to do two things:
- know how to ask for a value (queue and reply-to queue), ie poll
- know how to subscribe to future values (topic), ie subscribe to pushes
and the publisher has to know how to do two thinkgs:
- know how to reply to queries (queue), answer to poll requests
- know how to publish new values (topic), push new values
The goal here is to have some middleware software that will:
- keep (and persist) last known value for a key
- publish changes to all subscribers of that key, ie pubsub
- send latest known value (as a push) to a new subscriber
This would reduce the complexity in both publisher and subscriber.
I've been looking at Redis to solve this, but the PUBSUB feature only replaces the topic in the example above, not the polling of the current value on subscriber startup (and answering) ie, the query/queue part.
I've been looking a ZooKeeper and it's watches, and while it looks like it would meet my needs, it's overly complicated and requires quite a lot of code.
I've been looking at ØMQ (ZeroMQ) and saw the term Last Value Caching, LVC. The suggestion here is to create a proxy between the publisher and subscriber(s).
There are LVC extensions for RabbitMQ, like https://github.com/simonmacmullen/rabbitmq-lvc-plugin
My question is if there's some other FLOSS product that does pub-sub with built-in last value caching, not requiring a custom proxy or plugin to be added?