コード例 #1
0
ファイル: Program.cs プロジェクト: zzyks/rocketmq-externals
        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);
        }
コード例 #2
0
        public bool RegisterMessageCallback(PushConsumerWrap.MessageCallBack callBack)
        {
            if (callBack == null)
            {
                return(false);
            }

            var registerCallbackResult = PushConsumerWrap.RegisterMessageCallback(this._handleRef, callBack);

            return(registerCallbackResult == 0);
        }