public Publisher(string baseAddress, ushort publisherPort, ushort snapshotPort, IEnumerable <string> topics, int publishInterval = 20, int maxBulkSize = 100) { _publishInterval = publishInterval; _maxBulkSize = maxBulkSize; _messageIds = topics.ToDictionary(x => x, x => 0L); _snapshotCache = new SnapshotCache(topics); _snapshotServer = new SnapshotServer($"{baseAddress}:{snapshotPort}", _snapshotCache); _publishServer = new ReliableServer(TimeSpan.FromSeconds(5), $"{baseAddress}:{publisherPort}", _publishInterval, OnReceiveTimeout); _consumerTask = Task.Factory.StartNew(ConsumeMessages, _cancellationTokenSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); }
private static void Main(string[] args) { using (NetMQContext context = NetMQContext.Create()) { ReliableServer server = new ReliableServer(context, "tcp://*:6669"); while (true) { NetMQMessage message = new NetMQMessage(); message.Append("A"); message.Append(new Random().Next().ToString()); server.Publish(message); Thread.Sleep(1000); } } }
public Publisher(string baseAddress, ushort publisherPort, ushort snapshotPort, IEnumerable <string> topics) { _snapshotCache = new SnapshotCache(topics); _publishServer = new ReliableServer(TimeSpan.FromSeconds(5), $"{baseAddress}:{publisherPort}"); _snapshotServer = new SnapshotServer($"{baseAddress}:{snapshotPort}", _snapshotCache); }