如https://martinfowler.com/articles/lmax.html中所述,我需要先使用 Unmarchaler 处理我的 RingBuffer 事件,然后再使用业务逻辑处理器。假设它的配置如下(https://lmax-exchange.github.io/disruptor/docs/com/lmax/disruptor/dsl/Disruptor.html)
Disruptor<MyEvent> disruptor = new Disruptor<MyEvent>(MyEvent.FACTORY, 32, Executors.newCachedThreadPool());
EventHandler<MyEvent> handler1 = new EventHandler<MyEvent>() { ... };
EventHandler<MyEvent> handler2 = new EventHandler<MyEvent>() { ... };
disruptor.handleEventsWith(handler1);
disruptor.after(handler1).handleEventsWith(handler2);
想法是handler1是unmarchaler,handler2消耗handler1处理的东西。
问题:我如何才能准确地编码“unmarchaling 并放回破坏者”部分?我找到了这个https://groups.google.com/forum/#!topic/lmax-disruptor/q6h5HBEBRUk解释,但我不太明白。假设事件到达handler1的回调
void onEvent(T event, long sequence, boolean endOfBatch)
(javadoc:https ://lmax-exchange.github.io/disruptor/docs/com/lmax/disruptor/EventHandler.html )
从事件中取消编组一些数据。现在我需要将未编组的数据附加到将处理未编组对象的handler2的事件中。
“更新”事件需要做什么?修改“事件”对象是否足够?