如何用我的 hashmap lmax disruptor 中的数据填充环形缓冲区

how to fulfill the ringbuffer with data from my hashmap lmax disruptor

实际上,在阅读并使用了一个简单的破坏性示例之后,我找不到如何使用哈希图中的数据填充我的环形缓冲区,这些数据已经填充了来自 eventHandler 、翻译器或来自哪个组件的数据有任何帮助?

您应该在您的 bean 或包含您的业务流程的地方执行此操作,最简单的测试方法是在您的 main class

 public static void main () {

    // Executor that will be used to construct new threads for consumers
        Executor executor = Executors.newCachedThreadPool();

        // The factory for the event
        LogEventFactory factory = new LogEventFactory();

        // Specify the size of the ring buffer, must be power of 2.
        int bufferSize = 262144;

        // Construct the Disruptor
        Disruptor<LogEvent> disruptor = new Disruptor<LogEvent>(factory, bufferSize, executor);

        // Connect the handler
        disruptor.handleEventsWith(new LogEventHandler());

        // Start the Disruptor, starts all threads running
        disruptor.start();

        // Get the ring buffer from the Disruptor to be used for publishing.
        RingBuffer<LogEvent> ringBuffer = disruptor.getRingBuffer();

        LongEventProducerWithTranslator producer = new LongEventProducerWithTranslator(ringBuffer);

        **for (String name : cache.keySet()) {



            String key = name.toString();
            String value = cache.get(name).toString();

            producer.onData(cache.get(name));
            //Thread.sleep(2000);
            //System.out.println("key:" + key + " " + "//value:" + cache.get(name).getTags());

        }**

遍历它,您的翻译器 class 应该接受通过循环传递的对象