protected override void OnReceive(object message) { if (message is string s && s == ActorMessage.Start) { if (_isStarted) { return; } _consumer = _consumerFactory.Create(new [] { _topic }, _consumerGroup); _consumer.MessageReceived += ConsumerOnMessageReceived; _consumer.Start(); } }
public void Start() { var topics = _topics.Value; if (topics.Any()) { Task.Factory.StartNew(() => { using (var client = _consumerFactory.Create(GroupId)) { InitEventConsumer(client); client.Subscribe(topics); client.Listening(pollingDelay, cancellationTokenSource.Token); } }, cancellationTokenSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); } compositeTask = Task.CompletedTask; }