internal ZmqMonitorFileDescriptorEventArgs(ZmqMonitor monitor, MonitorEventData data)
            : base(monitor, data.Address)
        {
#if UNIX
            this.FileDescriptor = data.Value;
#else
            this.FileDescriptor = new IntPtr(data.Value);
#endif
        }
示例#2
0
        public void Initialize()
        {
            ReqContext = ZmqContext.Create();
            RepContext = ZmqContext.Create();
            ReqMonitor = ReqContext.CreateMonitorSocket(ReqEndpoint);
            RepMonitor = RepContext.CreateMonitorSocket(RepEndpoint);
            Req = ReqContext.CreateSocket(SocketType.REQ);
            Rep = RepContext.CreateSocket(SocketType.REP);
            Req.Monitor(ReqEndpoint, ReqEvents);
            Rep.Monitor(RepEndpoint, RepEvents);
            EventRecorded = new ManualResetEvent(false);
            ReqThread = new Thread(ReqMonitor.Start);
            RepThread = new Thread(RepMonitor.Start);

            Fired = false;
            Address = null;

            ReqThread.Start();
            RepThread.Start();
        }
示例#3
0
        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;
            }
        }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZmqMonitorEventArgs"/> class.
 /// </summary>
 /// <param name="monitor">The <see cref="ZmqMonitor"/> that triggered the event.</param>
 /// <param name="address">The peer address.</param>
 public ZmqMonitorEventArgs(ZmqMonitor monitor, string address)
 {
     this.Monitor = monitor;
     this.Address = address;
 }
 internal ZmqMonitorErrorEventArgs(ZmqMonitor monitor, MonitorEventData data)
     : base(monitor, data.Address)
 {
     this.ErrorCode = data.Value;
 }
 internal ZmqMonitorIntervalEventArgs(ZmqMonitor monitor, MonitorEventData data)
     : base(monitor, data.Address)
 {
     this.Interval = data.Value;
 }