i learn that LMAX disruptor is a High Performance Inter-Thread Messaging Library. But when i try to use it ,i found that the eventhandler use a callback method to process the data.
void onEvent(T event,
long sequence,
boolean endOfBatch)
throws java.lang.Exception
Called when a publisher has published an event to the RingBuffer
But if i don't use callback to get data, i write a while(true) to get data by my self, what should i do ?
thanks!
You should write your callback so it pushes the event into a queue. You can then iterate over the queue.
Queue<Event> queue = new ArrayBlockingQueue(10);
void onEvent(Event event,
long sequence,
boolean endOfBatch)
throws java.lang.Exception {
queue.add(event);
}
public void test() {
for ( Event event : queue ) {
// Your stuff here.
}
}