I used C# TDengine driver to subscribe data from taos database. My a sample code is like bellow:
public void RunSubscribeWithoutCallback(IntPtr conn, string table)
{
PrepareData(conn, table);
string topic = $"{table}_topic";
string sql = $"select * from {table}";
IntPtr subscribe = TDengine.Subscribe(conn, true, topic, sql, null, IntPtr.Zero, 1000);
Console.WriteLine("consume from begin");
IntPtr taosRes = TDengine.Consume(subscribe);
UtilsTools.DisplayRes(taosRes);
TDengine.FreeResult(taosRes);
for (int i = 0; i < 3; i++)
{
InsertData(conn, table);
}
Console.WriteLine("consume new data");
taosRes = TDengine.Consume(subscribe);
UtilsTools.DisplayRes(taosRes);
Console.WriteLine("Unsubscribe and keep progress");
TDengine.FreeResult(taosRes);
TDengine.Unsubscribe(subscribe, false);
}
While the output is like these
root@mybook:~/git_space/test/TDengine/src/connector/C#/examples# dotnet run drop database if exists csharp_example_db success create database if not exists csharp_example_db keep 3650 success use csharp_example_db success create table if not exists subscribe_without_callback (ts timestamp,i8 tinyint,i16 smallint,i32 int,i64 bigint); success insert into subscribe_without_callback values(1646150410000,1,2,3,4) success consume from begin 1646150410000 | 1 | 2 | 3 | 4 | insert into subscribe_without_callback values(1646150410100,1,2,3,4) success insert into subscribe_without_callback values(1646150410200,-1,-2,-3,-4) success insert into subscribe_without_callback values(1646150410300,1,2,3,4) success insert into subscribe_without_callback values(1646150410400,-1,-2,-3,-4) success insert into subscribe_without_callback values(1646150410500,1,2,3,4) success insert into subscribe_without_callback values(1646150410600,-1,-2,-3,-4) success consume new data
I can only get consume the first time. For the next time the application crashed. And there isn’t any error in taoslog file. Does any one know how to fix this?