cancel
Showing results for 
Search instead for 
Did you mean: 

Pub/sub in Kdb+

soum_guli
New Contributor
With Kdb+(not kdb+tick) is it possible to Pub/Sub?

Here is my what I am struggling to understand. If I do a normal upsert .Can I simple subscribe to it and receive the upserted data?Any piece of reference code?

2 REPLIES 2

soum_guli
New Contributor
Here is what I am doing 

Console subscriber:

q -p 5000
h:hopen 5001 
h(`.u.sub;`;`) //I expect this to subscribe to any table 


Console publisher:

q -p 5001
.u.pub[`sampletab; (09:30:01.000 09:30:02.000 09:30:03.000 09:30:04.000 09:30:05.000 ;89.9 89.8 80.3 85.2 81.4 ;1 1 0 0 1 ;1500 1500 1500 1500 1500 ;12 12 1 15 10 )]

But I donot see the subscriber being notified.

Assuming your publisher has all of the required tickerplant logic (http://code.kx.com/wsvn/code/kx/kdb%2Btick/tick.q) then your subscriber also needs to have the usual subscriber logic (http://code.kx.com/wsvn/code/kx/kdb%2Btick/tick/r.q)

At a bare minimum, your subscriber needs:

upd:insert;
{(.[;();:;].) each x}h(`.u.sub;`;`) 

Your subscriber should then start to receive and store the inserts

Terry