[英]Siddhi I don't get any response from aggregate query
I have a simple query like this: 我有一个简单的查询,像这样:
define stream myEventStream (userId string, price int);
define stream outputStream (avgPrice double, userId string);
@info(name = 'aQuery')
from myEventStream#window.time(5000)
select avg(price) as avgPrice, userId group by userId
insert into outputStream;
When I add the query callback I don't get any response from it. 当我添加查询回调时,没有任何响应。
runtime.addCallback("aQuery", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
}
});
I'm producing messages in another thread: 我在另一个线程中生成消息:
final AtomicInteger counter = new AtomicInteger(0);
final Random rnd = new Random(System.currentTimeMillis());
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.submit(() -> {
while (counter.getAndIncrement() < 100) {
try {
handler.send(new Object[]{"user1", rnd.nextInt(100)});
handler.send(new Object[]{"user2", rnd.nextInt(100)});
handler.send(new Object[]{"user3", rnd.nextInt(100)});
System.out.println("Sent: " + counter.get());
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}
});
I'm expecting result each 5 seconds. 我希望每5秒就能得到结果。 What am I missing here?
我在这里想念什么? Please help.
请帮忙。 Thank you.
谢谢。
Well the problem was that I've shut down the runtime right after the code which produces the event stream. 问题是我在生成事件流的代码之后立即关闭了运行时。 Nevertheless I was able to send messages to runtime although it was shut down already.
尽管如此,尽管它已经关闭,但我仍能够向运行时发送消息。 No exception.
没有例外。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.