Hey guys,
I’m coding a C# Kx subscriber that retrieves trading data once a second. I was looking at the Simple Subscriber example in the Cookbook (http://code.kx.com/wiki/Cookbook/InterfacingWithCSharp) but I have a couple of questions regarding best practices when subscribing for data:
- Should I be creating a kx.c object on every iteration of the my data retrieval or just one for the whole life of the subscriber? In other words, this question comes down to choosing between these options:
kx.c conn = new kx.c(…);
while(true)
{
object o = conn.k(query);
…
}
conn.Close();
OR
while(true){
kx.c conn = new kx.c(…);
object o = conn.k(query);
conn.Close();
…
}
Our instance of KDB is shared by many developers, so my concerns are that creating just one kx.c object could affect other users.
- At the moment I’m querying using ‘select’ every once a second, I haven’t tried using ‘sub’ yet. Is there any advantage in using one or the other? Any recommendation? What I want to do is just receive all trading updates for a product after I connect to KDB.
I’m still kind of new to Kx, so my apologies if these are rookie questions.
Thanks a lot for the help.
Best, Diego