The approach you take depends on how sensitive the customer information is. The disadvantage of one topic with selectors is that anyone can subscribe to a topic without a selector and see all the information for everyone - usually this is not what you want to do.
The best scheme is to use a message distribution mechanism (a set of Camel routes) that act as an intermediary between the websocket clients and the system that creates the messages. This mechanism is responsible for distributing messages from one recipient to target clients. I worked on several banking web interfaces that used a similar scheme.
For this to work, you first generate a separate token / UUID for each user; this is presented to the user when the session is established (usually through some profile / profile message). It is very important that the UUID can be generated as a clientId hash, and not be stored in the database, because it will be used all the time, and you want to make sure that it is quickly developed.
The user then uses this information to connect to specific topics that use this UUID as a suffix. For example, two users who subscribe to the orderConfirmation topic will subscribe to their own version of this topic:
clientA -> orderConfirmation.71jqsd87162iuhw78162wd7168 clientB -> orderConfirmation.76232hdwe7r23j92irjh291e0d
To track "presence", your customers should periodically send a heartbeat message containing their clientId on a known topic that your distribution mechanism is listening to. Clients should not subscribe to this topic for reading (see ActiveMQ Security ). The message distribution mechanism must store in memory a data structure that contains the clientId, and the time during which a heartbeat was noticed.
When a message is received by the distribution mechanism, it checks whether the identifier of the client for which it received the message has a live / current session, determines the UUID for the client and broadcasts the message on the relevant topic.
Over time, this will create a large number of topics in your broker that you do not want to hang out when the user leaves. You can configure ActiveMQ to remove them if they have been inactive for some time .
source share