/// <summary> /// setup the client with standard values /// verbose == false /// timeout == 2500 /// reties == 3 /// </summary> private MDPClient() { m_ctx = NetMQContext.Create (); m_client = null; Timeout = TimeSpan.FromMilliseconds (2500); Retries = 3; m_connected = false; }
/// <summary> /// Initializes a new instance of the <see cref="XForwarder"/> class. /// </summary> /// <param name="context">The <see cref="NetMQContext"/> to use when creating the sockets.</param> /// <param name="poller">The <see cref="Poller"/> to use.</param> /// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param> /// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param> /// <param name="mode">The <see cref="DeviceMode"/> for the device.</param> public XForwarder(NetMQContext context, Poller poller, string frontendBindAddress, string backendBindAddress, DeviceMode mode = DeviceMode.Threaded) : base(poller, context.CreateXSubscriberSocket(), context.CreateXPublisherSocket(), mode) { this.FrontendSetup.Bind(frontendBindAddress); this.BackendSetup.Bind(backendBindAddress); }
public TcpGateway(NetMQContext ctx, string endpoint, MessageProcessor processor) { _ctx = ctx; _endpoint = endpoint; _processor = processor; _socket = connect(); }
public FeedZmQPublisher(string address, ILog log) { _log = log; _context = NetMQContext.Create(); _socket = _context.CreatePushSocket(); _socket.Bind(address); }
public void Dispose() { lock (this) { if (!m_isDisposed) { SharpDBConnection connection; while (m_connections.TryTake(out connection)) { connection.Dispose(); } if (m_contextOwned) { m_context.Dispose(); } m_connections = null; m_context = null; m_isDisposed = true; } } }
public SharpDBClient(string connectionString) { m_context = NetMQContext.Create(); m_contextOwned = true; ConnectionString = connectionString; SerializerFactory = () => new BsonSerializer(); }
public NetMQWorker(int id, string pushAddress, string pullAddress, NetMQContext context) : base(id) { _pullSocket = context.CreatePullSocket(); _pushSocket = context.CreatePushSocket(); _pushSocket.Connect(pushAddress); _pullSocket.Bind(pullAddress+id); }
public SharpDBClient(NetMQContext context, string connectionString) { m_context = context; m_contextOwned = false; ConnectionString = connectionString; SerializerFactory = () => new BsonSerializer(); }
private bool _disposedValue = false; // Для определения избыточных вызовов #endregion Fields #region Constructors public FanBrocker(NetMQContext context, string ventAddress, string sinkAddress, int workersCnt) { _logger.Trace("Brocker created"); _ventAddress = ventAddress; _sinkAddress = sinkAddress; _sinkSocket = context.CreatePullSocket(); _sinkSocket.Options.ReceiveBuffer = 1; _sinkSocket.Bind(sinkAddress); _ventSocket = context.CreatePushSocket(); _ventSocket.Options.SendBuffer = 1; _ventSocket.Bind(ventAddress); Task.Run(() => { try { while (true) { var ba = _sinkSocket.ReceiveFrameString(); _logger.Trace("Brocker received data {0}", ba); var data = JsonConvert.DeserializeObject<ProcessedEventArgs>(ba); OnFramesProcessed(data); } } catch (Exception) { _logger.Error("EXCEPTION"); } }); }
/// <summary> /// Initializes an instance of a NetMQSenderManager constructing a NetMQSender from the specified NetMQContext and /// connects it to the specified address /// </summary> /// <param name="context"></param> public NetMQSenderManager(NetMQContext context, String address) { var sender = new NetMQSender(context.CreateDealerSocket(), new BinarySerializer(), address); sender.Connect(); Route<object>(new NetMQSenderFactory(address, context)); }
/// <summary> /// Create reliable client /// </summary> /// <param name="context"></param> /// <param name="addresses">addresses of the reliable servers</param> public ReliableClient(NetMQContext context, params string[] addresses) { m_context = context; m_addresses = addresses; m_actor = NetMQActor.Create(context, Run); }
public Control(int port, NetMQContext context) { this.port = port; this.context = context; this.server = this.context.CreateRouterSocket(); }
public void Run(params string[] addresses) { using (m_context = NetMQContext.Create()) { var subscriber = Connect(addresses); if (subscriber == null) throw new Exception("cannot connect to eny of the endpoints"); // timeout timer, when heartbeat was not arrived for 5 seconds m_timeoutTimer = new NetMQTimer(TimeSpan.FromSeconds(5)); m_timeoutTimer.Elapsed += (sender, args) => { // timeout happend, first dispose existing subscriber subscriber.Dispose(); m_poller.RemoveSocket(subscriber); // connect again subscriber = Connect(addresses); if (subscriber == null) throw new Exception("cannot connect to eny of the endpoints"); m_poller.AddSocket(subscriber); }; m_poller = new Poller(subscriber); m_poller.AddTimer(m_timeoutTimer); m_poller.PollTillCancelled(); } }
internal NmqMessageSender(Uri serviceUri) { context = NetMQContext.Create(); socket = context.CreateRequestSocket(); var address = string.Format("tcp://{0}:{1}", serviceUri.Host, serviceUri.Port); socket.Connect(address); }
private Task RunSubscriber(NetMQContext context) { using (NetMQSocket syncClient = context.CreateRequestSocket()) { syncClient.Connect(Pipe.PubSubControlBackAddressClient); syncClient.Send(string.Empty); syncClient.Receive(); var actions = new Dictionary<string, Delegate>(); actions.Add("MethodInfo", TestActors); actions.Add("ShutDownAllActors", ShutDownAllActors); using (var actor = new Actor<Order>(context, new BinarySerializer())) { actor.RegisterActor( "Display", string.Empty, "outRoute", null, new BinarySerializer(), new DefaultSerializer(Exchange.ControlChannelEncoding), actions); actor.StartAllActors(); } } return null; }
public void Start(string serverIpAddress, int serverPort) { ctx = NetMQContext.Create(); pushSocket = ctx.CreatePushSocket(); string serverAddress = string.Format("tcp://{0}:{1}", serverIpAddress, serverPort); pushSocket.Connect(serverAddress); }
public ZmqClient() { context = NetMQContext.Create(); subSocket = context.CreateSubscriberSocket(); subSocket.Options.ReceiveHighWatermark = 1000; subSocket.Connect(MarketDataSettings.RealTimeUpdateServerAddress); }
public AsyncWorker(int id, NetMQContext context, string address) : base(id) { _responseSocket = context.CreateResponseSocket(); _responseSocket.Options.ReceiveHighWatermark = 2; _responseSocket.Options.SendHighWatermark = 2; _responseSocket.Options.Identity = BitConverter.GetBytes(id); _responseSocket.Connect(address); }
public ReliableServer(NetMQContext context, string address) { m_context = context; m_address = address; // actor is like thread with builtin pair sockets connect the user thread with the actor thread m_actor = NetMQActor.Create(context, Run); }
/// <summary> /// Initializes an instance of a NetMQReceiverManager, constructs a NetMQReceiver from the specified NetMQContext and binds /// it to the specified address /// </summary> /// <param name="context">NetMQContext</param> /// <param name="address">Address to connect the NetMQReceiver to</param> public NetMQReceiverManager(NetMQContext context, string address) { if (context == null) throw new ArgumentNullException("NetMQContext"); receiver = new NetMQReceiver(context.CreateRouterSocket(), new BinarySerializer()); receiver.Bind(address); }
public void Init(int port, MQServerType type) { _type = type; _port = port; _isStart = true; _context = NetMQContext.Create(); CreateServer(); }
public LeaderElection(IList<Peer> peers, object lockObject, NetMQContext context, ILogger logger) { this.peers = peers; this.lockObject = lockObject; this.context = context; this.logger = logger; localPeer = this.peers.First(c => c.IsLocal); }
public SingleThreadedZeroMqGateway(string endpoint, TimeSpan reaperInterval) { Log.DebugFormat("[STZMG] Starting. Thread Id: {0}", Thread.CurrentThread.ManagedThreadId); _ctx = NetMQContext.Create(); _endpoint = endpoint; _reaperInterval = reaperInterval; _socket = connect(); _reapTime = DateTime.Now.Add(reaperInterval); }
public ZmqService() { primitiveQuoteService = new YahooFinancialDataService(); subscribedTickerList = new List<string>(); subscribedTickerList.AddRange(MarketDataSettings.StartupTickers); refreshInterval = MarketDataSettings.ServerRefreshMillis; socketFactory = NetMQContext.Create(); }
/// <summary> /// create worker with standard parameter /// HeartbeatDelay == 2500 milliseconds /// ReconnectDelay == 2500 milliseconds /// ConnectionRetries == 3 /// Verbose == false /// </summary> private MDPWorker() { m_ctx = NetMQContext.Create(); HeartbeatDelay = TimeSpan.FromMilliseconds(2500); ReconnectDelay = TimeSpan.FromMilliseconds(2500); m_exit = false; m_connected = false; }
/// <summary> /// Initializes a new instance of the <see cref="NmqMessageServer"/> class. /// </summary> /// <param name="messageReceiver">The message receiver.</param> /// <param name="port">The port.</param> internal NmqMessageServer(IMessageReceiver messageReceiver, int port) { tokenSource = new CancellationTokenSource(); this.port = port; this.messageReceiver = messageReceiver; context = NetMQContext.Create(); responseQueue = new NmqResponseQueue(context, port); }
public void Start(int publishPort) { ctx = NetMQContext.Create(); publishSocket = ctx.CreatePublisherSocket(); publishSocket.Bind("tcp://*:" + publishPort); logger.Info("Message publisher started on port " + publishPort); }
public Heartbeat(ILog logger, string address, NetMQContext context) { this.logger = logger; this.address = address; this.context = context; this.server = context.CreateResponseSocket(); this.stopEvent = new ManualResetEventSlim(); }
private void InitZmq() { if (_ctx == null) { _ctx = NetMQContext.Create(); _socket = _ctx.CreatePublisherSocket(); var address = string.Format("{0}:{1}", _host, _port); _socket.Bind(address); } }
public ZrePeer(NetMQContext context, Guid identity) { _context = context; _identity = identity; _headers = new ConcurrentDictionary<string, string>(); _sentSequence = 0; _wantSequence = 0; _evasiveAt = 0; _expiredAt = 0; }
public NetMQScheduler([NotNull] NetMQContext context, [CanBeNull] Poller poller = null) { if (poller == null) { m_ownPoller = true; m_poller = new Poller(); } else { m_ownPoller = false; m_poller = poller; } m_tasksQueue = new ConcurrentQueue <Task>(); m_syncObject = new object(); var schedulerId = Interlocked.Increment(ref s_schedulerCounter); var address = string.Format("{0}://scheduler-{1}", Address.InProcProtocol, schedulerId); m_serverSocket = context.CreatePullSocket(); m_serverSocket.Options.Linger = TimeSpan.Zero; m_serverSocket.Bind(address); m_currentMessageHandler = OnMessageFirstTime; m_serverSocket.ReceiveReady += m_currentMessageHandler; m_poller.AddSocket(m_serverSocket); m_clientSocket = context.CreatePushSocket(); m_clientSocket.Connect(address); m_schedulerThread = new ThreadLocal <bool>(() => false); if (m_ownPoller) { m_poller.PollTillCancelledNonBlocking(); } }
public static NetMQActor Create <T>([NotNull] NetMQContext context, [NotNull] ShimAction <T> action, T state) { return(new NetMQActor(context, new ActionShimHandler <T>(action, state))); }
public static NetMQActor Create(NetMQContext context, IShimHandler shimHandler) { return(new NetMQActor(context, shimHandler)); }
public NetMQScheduler(NetMQContext context, Poller poller = null) : this(poller, context.CreatePushSocket(), context.CreatePullSocket()) { }
public static NetMQActor Create([NotNull] NetMQContext context, [NotNull] IShimHandler shimHandler) { return(new NetMQActor(context, shimHandler)); }
public static NetMQActor Create([NotNull] NetMQContext context, [NotNull] ShimAction action) { return(new NetMQActor(context, new ActionShimHandler(action))); }
public NetMQScheduler([NotNull] NetMQContext context, [CanBeNull] Poller poller = null) : this(poller, context.CreatePushSocket(), context.CreatePullSocket()) { }
public static NetMQActor Create(NetMQContext context, ShimAction action) { return(new NetMQActor(context.CreatePairSocket(), context.CreatePairSocket(), new ActionShimHandler(action))); }
public static NetMQActor Create <T>(NetMQContext context, ShimAction <T> action, T state) { return(new NetMQActor(context.CreatePairSocket(), context.CreatePairSocket(), new ActionShimHandler <T>(action, state))); }
public static NetMQActor Create(NetMQContext context, IShimHandler shimHandler) { return(new NetMQActor(context.CreatePairSocket(), context.CreatePairSocket(), shimHandler)); }