public void Declare() { if (!this.inited) { ZeroLog.LogInfo("producer inited...."); contexts = new Dictionary <string, ZmqContext>(); sockets = new Dictionary <string, ZmqSocket>(); monitors = new Dictionary <string, ZmqMonitor>(); List <ZeroRoute> rules = XMLExchange.GetInstance().Configs; routes = new Dictionary <string, ZeroRoute>(rules.Count); foreach (var config in rules) { ZmqContext context = ZmqContext.Create(); ZmqSocket socket = context.CreateSocket(PreSocketType()); ZmqMonitor monitor = context.CreateMonitor(); socket.SendTimeout = new TimeSpan(0, 0, config.SendTimeout); socket.MaxMessageSize = config.MaxMessageSize; contexts.Add(config.ExchangeName, context); sockets.Add(config.ExchangeName, socket); monitors.Add(config.ExchangeName, monitor); routes.Add(config.ExchangeName, config); Bind(socket, config); Connect(socket, config); ZeroLog.LogInfo("producer inited...." + config.ExchangeName); } processor = new Processor(contexts, sockets, monitors, routes); this.inited = true; } }
public void Declare() { if (!this.inited) { ZeroLog.LogInfo("consumer inited...."); List <ZeroRoute> rules = XMLExchange.GetInstance().Configs; foreach (var config in rules) { SubThread processor = new SubThread(); processor.Config = config; processor.ExchangeName = config.ExchangeName; pools.Add(config.ExchangeName, processor); ZeroLog.LogInfo("consumer inited...." + config.ExchangeName); } this.inited = true; } }