public EventHubObserver(EventHubConfig config) { try { _config = config; _eventHubClient = EventHubClient.CreateFromConnectionString(_config.ConnectionString, config.EventHubName); this._logger = new Logger(ConfigurationManager.AppSettings["logger_path"]); } catch (Exception ex) { _logger.Write(ex); throw ex; } }
static void Main(string[] args) { var config = new EventHubConfig(); // Uncomment for picking from Configuration config.ConnectionString = ConfigurationManager.AppSettings["EventHubConnectionString"]; config.EventHubName = ConfigurationManager.AppSettings["EventHubName"]; //To push 1 event per second var eventHubevents = Observable.Interval(TimeSpan.FromSeconds(0.2)).Select(i => FundCode.Generate()); //To send Data to EventHub as JSON var eventHubDis = eventHubevents.Subscribe(new EventHubObserver(config)); Console.ReadLine(); eventHubDis.Dispose(); }