activemq - Camel route "to" specific websocket endpoint -
i have camel routes mina sockets , jetty websockets. able broadcast message clients connected websocket how send message specific endpoint. how maintain list of connected clients client id reference can route specific client. possible? able mention dynamic client in uri?
or maybe thinking wrong , need create topics on active mq , have clients subscribe it. mean create topic every websocket client? , route message right topic.
am atleast on right track here, examples can point out? google not helpful.
the approach take depends on how sensitive client information is. downside of single topic selectors can subscribe topic without selector , see information - not want do.
a better scheme use message distribution mechanism (set of camel routes) act intermediary between websocket clients , system producing messages. mechanism responsible distributing messages single destination client-specitic destinations. have worked on couple of banking web front-ends used similar scheme.
in order work first generate each user distinct token/uuid; presented user when session established (usually through sort of profile query/message). it's essential uuid can worked out hash of clientid rather being stored in db, used time , want make sure worked out quickly.
the user uses information connect specific topics use uuid suffix. example 2 users subscribing orderconfirmation
topic each subscribe own version of topic:
clienta -> orderconfirmation.71jqsd87162iuhw78162wd7168 clientb -> orderconfirmation.76232hdwe7r23j92irjh291e0d
to keep track of "presence", clients need periodically send heartbeat message containing clientid well-known topic distribution mechanism listens on. clients should not able subscribe topic reads (see activemq security). message distribution mechanism needs keep in memory data structure contains clientid , time heartbeat last seen.
when message received distribution mechanism, checks whether clientid received message has "live/present" session, determines uuid client, , broadcasts message on appropriate topic.
over time create large number of topics on broker don't want hanging around when user has gone away. can configure activemq delete these if have been inactive time.
Comments
Post a Comment