public override void Start(Options options) { Logger.LogInformation($"Starting [{options.Id}]"); using (var socket = Context.CreatePullSocket()) { socket.Bind(options.Address()); while (true) { // read a message var message = socket.ReceiveFrameString(); Logger.LogDebug($"[{options.Id}] Received - {message}"); } } }
public override void Start(Options options) { Logger.LogInformation($"Starting [{options.Id}]"); using (var socket = Context.CreateSubscriberSocket()) { socket.Connect(options.Address()); socket.Subscribe(options.Topic); // if empty subscribes to all while (true) { // read a message var message = socket.ReceiveFrameString(); Logger.LogDebug($"[{options.Id}] Received - {message}"); } } }
public override void Start(Options options) { Logger.LogInformation($"Starting [{options.Id}]"); using (var socket = Context.CreatePushSocket()) { socket.Connect(options.Address()); var sw = Stopwatch.StartNew(); for (var i = 0; i < options.Messages; i++) { // write a message socket.SendFrame($"Message: [{options.Id}] - {i}"); } Logger.LogInformation($" [{options.Id}] - Sent {options.Messages} messages in: {sw.ElapsedMilliseconds} milliseconds"); } }
public override void Start(Options options) { Logger.LogInformation($"Starting [{options.Id}]"); using (var socket = Context.CreateResponseSocket()) { socket.Bind(options.Address()); while (true) { // read a message var message = socket.ReceiveFrameString(); Logger.LogDebug($"[{options.Id}] Received - {message}"); // reply with a response socket.SendFrame($"Thanks for {message} from {options.Id}"); } } }
public override void Start(Options options) { Logger.LogInformation($"Starting [{options.Id}]"); using (var socket = Context.CreatePublisherSocket()) { socket.Bind(options.Address()); var sw = Stopwatch.StartNew(); var i = 0; while (true) { // write some messages socket.SendFrame($"Message A: [{options.Id}] - {i}"); socket.SendFrame($"Message B: [{options.Id}] - {i}"); i++; Thread.Sleep(100); } } }
public override void Start(Options options) { Logger.LogInformation($"Starting [{options.Id}]"); using (var socket = Context.CreatePublisherSocket()) { socket.Bind(options.Address()); var sw = Stopwatch.StartNew(); var i = 0; while(true) { // write some messages socket.SendFrame($"Message A: [{options.Id}] - {i}"); socket.SendFrame($"Message B: [{options.Id}] - {i}"); i++; Thread.Sleep(100); } } }