Example #1
0
        static void Main(string[] args)
        {
            Console.Title = "PushConsumer";

            Task.Run(() => {
                Console.WriteLine("start push consumer...");

                var consumerPtr = PushConsumerWrap.CreatePushConsumer("xxx");
                var p           = new Program();
                var consumer    = new HandleRef(p, consumerPtr);
                Console.WriteLine($"consumer: {consumer}");
                var r0 = PushConsumerWrap.SetPushConsumerLogLevel(consumer, CLogLevel.E_LOG_LEVEL_TRACE);

                var groupId = PushConsumerWrap.GetPushConsumerGroupID(consumer.Handle);
                Console.WriteLine($"groupId: {groupId}");

                var r1  = PushConsumerWrap.SetPushConsumerNameServerAddress(consumer, "47.101.55.250:9876");
                var r2  = PushConsumerWrap.Subscribe(consumer, "test", "*");
                var r3  = PushConsumerWrap.RegisterMessageCallback(consumer, _callback);
                var r10 = PushConsumerWrap.StartPushConsumer(consumer);
                Console.WriteLine($"start push consumer ptr: {r10}");

                while (true)
                {
                    Thread.Sleep(500);
                }
            });
            Console.ReadKey(true);

            //PushConsumerBinder.DestroyPushConsumer(consumer);
        }
        public IPushConsumerBuilder SetPushConsumerLogLevel(LogLevel logLevel)
        {
            if (logLevel == LogLevel.None)
            {
                throw new ArgumentException(nameof(logLevel));
            }

            var result = PushConsumerWrap.SetPushConsumerLogLevel(this._handleRef, (CLogLevel)logLevel);

            if (result != 0)
            {
                throw new RocketMQConsumerException($"set consumer logLevel error. cpp sdk return code {result}");
            }

            return(this);
        }