Hello,
Is there a way to edit .u.sub to return the current table data and then subscribe to a table without missing anything?
I’m currently sending a sync request for the current table data and then calling .u.sub but its possible to miss messages.
Thanks
If you follow the conventional subscription method as laid out in the official r.q (http://code.kx.com/wsvn/code/kx/kdb%2Btick/tick/r.q) then you will not lose data between the subscription initialisation and the replay of current data.
(I assume it’s OK to post this link on the public list now).
In particular, you start the sub and request the log details (or raw data if you’re storing it in memory) within the same sync call and then immediately pass the results into a replay function. All the while, the publisher will be queuing messages in its output queue until you’re ready
Hmm thanks Terry I must be missing something though. Or maybe I wasn’t clear enough. I am subscribing from a C# client. So for example I have a table of `orders.
When my client connects I’m calling .u.sub[orders;
]. In the kx back-end I am only publishing new orders using something like .u.pub[`orders;select from orders where newOrder].
In this scenario I don’t get the full table of orders when I first call .u.sub, and if I request the full table on startup then its possible to miss messages.
Does that make sense?
I see. Without knowing much about your setup I still think that the principle should be the same - you can send a single sync message to initialise the subscription and return the current data at the exact time the subscription started. i.e. something like
data=c.k(“(.u.sub[orders;
];select from orders where not newOrder)”);
Then process the data returned. Then start receiving new orders using
c.k()
In theory (depending on what your TP is doing) there would be a seamless transition from the snapshot you took when you initialised to the new messages coming in.
I don’t think you would have to edit .u.sub but again it all depends on your exact setup
Terry