mqtt client libraries to perform load balanced work (when the workers are actually available to perform work), without needing a custom broker
{wid}
a unique identifier for a worker in a group.
{group}
name for a group of workers that have work distributed among them
{topic}
the original mqtt topic to subscribe to
{mtopic}
the original topic messages are published over
(message)
the original message published over {mtopic}
{uuid}
a uuid
can be done during load balancer startup
load balancer remembers group if not done so
load balancer subs to {topic}
if not done so
load balancer subs to lb/rsp/+/+/{topic}
if not done so
load balancer subs to lb/sub/+
workers pub to lb/sub/{group}
with {topic}
as payload, occasionally as a 'load balancer keepalive'
load balancer receives pub
load balancer subscribes to necessary topic paths
load balancer pubs to lb/suback/{group}
with {topic}
as payload
workers notice that load balancer is available
workers subscribe to paths based on their load balancing type
(message)
comes through {mtopic}
workers subscribe to lb/req/+/{topic}
workers subscribe to lb/work/{group}/{wid}/{topic}
workers subscribe to lb/dwork/+/{group}/+
load balancer pub lb/req/{uuid}/{mtopic}
workers respond to lb/rsp/{group}/{wid}/{uuid}/{mtopic}
if they can do the work, keep track that they're 'working' on {uuid}
the load balancer then pubs the (message)
to lb/work/{group}/{wid}/{mtopic}
to all first responding workers in each group.
load balancer pub lb/dwork/{uuid}/{group}/{wid}
to tell all the workers in the group who it chose
workers not chosen release their 'working' lock on {uuid}
if the client doesn't see suback, assume no load balancer and subscribe to {topic}
. if it does later, unsubscribe from {topic}