Coder Social home page Coder Social logo

Comments (5)

ntucz avatar ntucz commented on May 20, 2024

官方这个问题么有答复?

from tdengine.

yu285 avatar yu285 commented on May 20, 2024

收到 我们看下

from tdengine.

sheyanjie-qq avatar sheyanjie-qq commented on May 20, 2024

消息订阅的应用场景一般是要一直订阅的,当订阅的 topic 对应的表如果有新插入数据,都会poll到消息。

你如果想订阅到一条消息就退出循环,可以这么改:
while (time > 0) 改成 while (true)

在if (!obj.isEmpty()){
....
//增加一行
break;
}

from tdengine.

ntucz avatar ntucz commented on May 20, 2024

消息订阅的应用场景一般是要一直订阅的,当订阅的 topic 对应的表如果有新插入数据,都会poll到消息。

你如果想订阅到一条消息就退出循环,可以这么改: while (time > 0) 改成 while (true)

在if (!obj.isEmpty()){ .... //增加一行 break; }

谢谢,consumer.poll(Duration.ofMillis(100)),这里的poll周期是毫秒级,而且非阻塞,即使没数据线程也继续跑,poll的结果是null,外面必须套个while(true)。
通常iot设备上报数据的周期很长,一直consumer.poll,太浪费cpu,所以我整了个定时器,周期到的时候再new 一个consumer去poll,但是不能确定第几次能得到数据。
https://www.taosdata.com/tdengine-engineering/1277.html
1710142556798
c++的这段代码,红框中是得不到就break,但是对照我最上面的问题,有可能第一次就是得不到,而是第5次才得到,这样第一次break就有问题了。

from tdengine.

sheyanjie-qq avatar sheyanjie-qq commented on May 20, 2024

你开始的例子是用的java连接器,因此我给你的答复也是基于java连接器
判断条件是if (!obj.isEmpty()) 就是拿到数据了,此时可以break的
播客的时间比较早了,你可以参考官网代码样例,比较新

from tdengine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.