现在有这样一个场景。
有一个jar在多线程运行,每个线程里都有自己的局部变量累加器 long count;
现在我需要通过一个spring的web project获取每个线程的count值,并且通过highcharts绘制出图形
请问这个独立jar的各自线程中的count局部变量,如何能被spring拿到?
自己想到的几个方法:
1.NIO的管道通信,PipedInputStream、PipedOutputStream
2.Thrift RPC服务
3.netty的服务
有没有可行的解决方案?
黄舟2017-04-18 10:35:14
According to my understanding, you need inter-process communication, right?
Thrift and Netty you mentioned are both acceptable.
Or you can also use a message queue. Each jar package acts as a producer and submits count as a message to the queue, and then Your Spring Web project can retrieve the count value from the queue.
巴扎黑2017-04-18 10:35:14
No need.
Get data directly from count
使用map
结构存放在redis
中就ok了。hightcharts
渲染时直接从redis
.
The structure is as follows.
counter
|
| key1: v1`
| key2: v2