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);
 }
示例#2
0
 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);
 }