If you are going to use a load-balancer for MQTT clients and your use-case includes using "dirty" sessions then I would strongly suggest using the connection router [1] functionality from ActiveMQ Artemis and routing based on client ID. This is because cluster nodes don't share MQTT session state so an MQTT client's state will exist only on one particular cluster node. Therefore, if your clients ever want to connect back to their session (e.g. to resume their previous subscriptions) they will need to connect back to node where they were previously connected and using a connection router is a great way to do that.
Justin [1] https://activemq.apache.org/components/artemis/documentation/latest/connection-routers.html On Wed, May 11, 2022 at 2:11 AM Prashanth Babu <[email protected]> wrote: > Hi all, > > I'd like to know if I could create a cluster of Artemis nodes via a > kubernetes deployment and use it as an MQTT broker for 2 way communication. > > The idea is to create a cluster of say 3 nodes and place it behind a load > balancer. Now clients can connect to any one of the 3 nodes ( N1,N2,N3 ) > based on load balancer distribution. > > Let's assume a client C1 has connected to node N1 and published to topic T1 > Also assume a client C2 has connected to node N2 and subscribed to topic T1 > > Would C2 get the message from C1 ? > > I wasn't able to find a suitable document on achieving this kind of > clustering for MQTT using kubernetes. > > Thanks, > Prashanth >
