Fork me on GitHub

I consider doing the following: 1. Each container maintains a list of users connected to it (this is already there with Sente) 2. Whenever a user connects, a common list is maintained in Datomic 3. Whenever a user disconnects, the user is removed from the common list 4. Whenever an update from a user needs to be sent to other users, it starts by sending out the messages directly to the users connected to the same container. Then the container reads the common list of connected users from Datomic. If some connected users are connected to other containers, the messages for those users are stored in a common messages list (queue) in Datomic. 5. Workers on all containers regularly (say, every 15 seconds?) check this common message queue. If a message exist for a connected user, the message is sent to the user, and removed from the queue. 6. When a user disconnects/logs off, the list of waiting messages for that user is (permanently) removed from the message queue.


@luposlip what is the purpose of #4? also instead of polling datomic, you may consume the transaction report queue and look for the messages


@alandipert: the purpose is for example: "I've changed this value that you are subscribing to". The server (containers) need to notify all subscribers (via push). Both the users connected to the same container that receives the event that changes the value (sent immediately), and the users connected to other containers.


so it's for reducing latency when users are adjacent?


What's the benefit of looking through the TX report queue? Can this be read directly from storage instead of waiting for the peer library to catch up?


well if you route everything through datomic instead of short circuting, than datomic is the data of record


and datomic already has a way to listen for changes, the tx queue


latency is potentially higher but it's simpler imo


also if you add logic to happen to the message, it goes in one place


So he TX queue is still relying on the peer library?


it's a feature of the peer library, yeah


Gotta look into that.


in practice one consumes it in a thread, filtering out messages not interested in


in a system i work on today we've built a really crappy datomic over a 10 yr period


various databases and queues spread around, piles of hacks


if you buy totally into datomic features from the beginning though i think you can make some pretty clean stuff


i should mention i am not a paid spokesperson lol


just a big fan ™️


Agreed. Do you use some scheduling library, or just plain Java threads? I've been using at-at and and some other earlier (just forgot which) based on Quartz.


you mean for the thread to consume the tx queue?


i have used plain threads, since it's a blocking queue, the thread just blocks on the get call


Yes, that's what I meant.