代码拉取完成,页面将自动刷新
package examples;
import com.xxdb.DBConnection;
import com.xxdb.streaming.client.ThreadPooledClient;
import com.xxdb.streaming.client.ThreadedClient;
import java.io.IOException;
/**
* when single thread client can not effectively process streaming data, you can use it.
* ThreadPooledClient has a fixed thread pool.
*
*/
public class ThreadPooledClientDemo {
private static DBConnection conn = new DBConnection();
public static String host = "localhost";
public static Integer port = 8848;
public static Integer subscribePort = 8892;
public static void main(String[] args) throws IOException, InterruptedException {
createStreamTable();
ThreadPooledClient client = new ThreadPooledClient(subscribePort,10);
client.subscribe(host, port, "Trades", new MyHandler(), 0);
}
public static void createStreamTable() throws IOException {
conn.connect(host, port);
conn.login("admin", "123456", false);
try{
conn.run("dropStreamTable(\"Trades\")");
}catch (Exception e){
System.out.println(e.getMessage());
}
conn.run("share streamTable(30000:0,`id`time`sym`qty`price,[INT,TIMESTAMP,SYMBOL,INT,DOUBLE]) as Trades\n");
conn.run("data=table(1..1000 as id, now()+1..1000 as time, take(`aaa,1000) as sym," +
"rand(100..1000, 1000) as qty,rand(100.0, 1000) as price)");
conn.run("Trades.tableInsert(data)");
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。