/// <summary> RocketMQ管理器 </summary> public RocketMQManager(RocketMQItemConfig config) { DynamicGlobSetting.InitDynamicLib(); _factoryInfo = new ONSFactoryProperty(); if (config.AccessKey != null) { _factoryInfo.setFactoryProperty(ONSFactoryProperty.AccessKey, config.AccessKey); } if (config.SecretKey != null) { _factoryInfo.setFactoryProperty(ONSFactoryProperty.SecretKey, config.SecretKey); } if (config.ConsumerID != null) { _factoryInfo.setFactoryProperty(ONSFactoryProperty.ConsumerId, config.ConsumerID); } if (config.ProducerID != null) { _factoryInfo.setFactoryProperty(ONSFactoryProperty.ProducerId, config.ProducerID); } if (config.Topic != null) { _factoryInfo.setFactoryProperty(ONSFactoryProperty.PublishTopics, config.Topic); } if (config.Server != null) { _factoryInfo.setFactoryProperty(ONSFactoryProperty.NAMESRV_ADDR, config.Server); //_factoryInfo.setFactoryProperty(ONSFactoryProperty.ONSAddr, config.Server); } // 设置线程数 if (config.ConsumeThreadNums < 1) { config.ConsumeThreadNums = 1; } _factoryInfo.setFactoryProperty(ONSFactoryProperty.ConsumeThreadNums, config.ConsumeThreadNums.ToString()); // 默认值为ONSChannel.ALIYUN,聚石塔用户必须设置为CLOUD,阿里云用户不需要设置(如果设置,必须设置为ALIYUN) _factoryInfo.setOnsChannel(config.Channel); if (config.IsWriteLog) { _factoryInfo.setFactoryProperty(ONSFactoryProperty.LogPath, SysPath.LogPath); } _factoryInfo.setFactoryProperty(ONSFactoryProperty.SendMsgTimeoutMillis, "3000"); }
static RocketMQManager() { Console.WriteLine("静态初始化方法执行"); //这儿初始化动态库 DynamicGlobSetting.InitDynamicLib(); }