public void Sub(string topic, Action <string> onMsg) { _unSub = false; var opiton = new ConsumerOptions(topic, _brokerHelper.GetBroker()); _consumer = new Consumer(opiton); Task.Run(() => { while (!_unSub) { var msgs = _consumer.Consume(); Parallel.ForEach(msgs, msg => { onMsg(Encoding.UTF8.GetString(msg.Value)); }); } }); }
public ProduceHelper(BrokerHelper brokerHelper) { _brokerHelper = brokerHelper; _producer = new Producer(_brokerHelper.GetBroker()); }