Example #1
0
        private ProducterHeartbeatProtect(ProducterContext context)
        {
            try
            {
                DebugHelper.WriteLine(context.GetMQPathID(), context.GetMQPath(),"ProducterHeartbeatProtect", "生产者心跳守护开始注册");
                cancelSource = new CancellationTokenSource();

                System.Threading.Tasks.Task.Factory.StartNew(() =>
                {
                    HeatbeatRun();//注册心跳
                }, cancelSource.Token);
                DebugHelper.WriteLine(context.GetMQPathID(), context.GetMQPath(),"ProducterHeartbeatProtect", "生产者心跳守护心跳注册成功");

                redislistener = new RedisNetCommandListener(ConfigHelper.RedisServer); redislistener.Name = "生产者";
                redislistener.Register((channel, msg) =>
                {
                    RedisListenerCommand(channel, msg);
                }, cancelSource, context.ProducterProvider.MQPath, SystemParamConfig.Redis_Channel);
                DebugHelper.WriteLine(context.GetMQPathID(), context.GetMQPath(),"ProducterHeartbeatProtect", "生产者心跳redis监听注册成功");
                LogHelper.WriteLine(context.GetMQPathID(), context.GetMQPath(),"ProducterHeartbeatProtect", "生产者心跳守护注册成功");
            }
            catch (Exception exp)
            {
                ErrorLogHelper.WriteLine(context.GetMQPathID(), context.GetMQPath(),"ProducterHeartbeatProtect", "生产者心跳初始化错误", exp);
                throw exp;
            }
        }
Example #2
0
        private void Create()
        {
            try
            {
                DebugHelper.WriteLine(Context.GetMQPathID(), Context.GetMQPath(), "ReceiveMessageQuque-Create", "消费者开始创建内部消息队列");
                Init();
                cancelSource = new CancellationTokenSource();

                System.Threading.Tasks.Task.Factory.StartNew(() =>
                {
                    Run();
                }, cancelSource.Token);
                DebugHelper.WriteLine(Context.GetMQPathID(), Context.GetMQPath(), "ReceiveMessageQuque-Create", "消费者内部消息队列注册消息循环成功");

                redislistener = new RedisNetCommandListener(ConfigHelper.RedisServer); redislistener.Name = "消费者内部消息队列";
                redislistener.Register((channel, msg) =>
                {
                    RedisListenerCommand(channel, msg);
                }, cancelSource, Context.ConsumerProvider.MQPath, SystemParamConfig.Redis_Channel_Quque + "." + Context.ConsumerProvider.MQPath);
                DebugHelper.WriteLine(Context.GetMQPathID(), Context.GetMQPath(), "ReceiveMessageQuque-Create", "消费者内部消息队列注册redis消息监听成功");

                LogHelper.WriteLine(Context.GetMQPathID(), Context.GetMQPath(), "ReceiveMessageQuque-Create", "消费者内部队列注册成功");
            }
            catch (Exception exp)
            {
                ErrorLogHelper.WriteLine(Context.GetMQPathID(), Context.GetMQPath(), "ReceiveMessageQuque-Create", "消费者内部消息队列创建失败", exp);
                throw exp;
            }
        }