Example #1
0
        //#region Option 1, single ThreadBlock
        private static void DumpMessageAsConsumerGroupSigleThreadBlock(ConsumeGroupHelperOptions cgOptions)
        {
            initialOffset = null;
            newOffset     = null;
            AutoResetEvent[] autos = new AutoResetEvent[cgOptions.ZookeeperConnectorCount];

            for (int i = 0; i < cgOptions.ZookeeperConnectorCount; i++)
            {
                AutoResetEvent          resetEvent = new AutoResetEvent(false);
                ConsumerGroupHelperUnit unit       = new ConsumerGroupHelperUnit(DateTime.UtcNow.Second, cgOptions, resetEvent, cgOptions.ZookeeperConnectorConsumeMessageCount[i]);
                Thread t = new Thread(unit.Consume);
                t.Start();
                Logger.InfoFormat("Start thread {0} of ZookeeperConsumerConnector", i);
                autos[i] = resetEvent;
            }
            WaitHandle.WaitAll(autos);
        }
        //#region Option 1, single ThreadBlock
        private static void DumpMessageAsConsumerGroupSigleThreadBlock(ConsumeGroupHelperOptions cgOptions)
        {
            initialOffset = null;
            newOffset = null;
            AutoResetEvent[] autos = new AutoResetEvent[cgOptions.ZookeeperConnectorCount];

            for (int i = 0; i < cgOptions.ZookeeperConnectorCount; i++)
            {
                AutoResetEvent resetEvent = new AutoResetEvent(false);
                ConsumerGroupHelperUnit unit = new ConsumerGroupHelperUnit(i, cgOptions, resetEvent, cgOptions.ZookeeperConnectorConsumeMessageCount[i]);
                Thread t = new Thread(unit.Consume);
                t.Start();
                Logger.InfoFormat("Start thread {0} of ZookeeperConsumerConnector", i);
                autos[i] = resetEvent;
            }
            WaitHandle.WaitAll(autos);
        }