public void StartTracking(Action <ILoggerData> callback) { var factory = new ConnectionFactory() { Uri = new Uri(ConfigurationAccessor.GetConfig().RabbitMQ.Url), UserName = ConfigurationAccessor.GetConfig().RabbitMQ.UserName, Password = ConfigurationAccessor.GetConfig().RabbitMQ.Password }; IConnection connection = factory.CreateConnection(); IModel channel = connection.CreateModel(); var queueName = channel.QueueDeclare().QueueName; channel.QueueBind(queue: queueName, exchange: ConfigurationAccessor.GetConfig().RabbitMQ.QueueName, routingKey: ""); var consumer = new EventingBasicConsumer(channel); consumer.Received += (model, ea) => { var body = ea.Body; var message = Encoding.UTF8.GetString(body); var cmd = JsonConvert.DeserializeObject <LoggerData>(message); callback(cmd); }; channel.BasicConsume(queue: queueName, autoAck: true, consumer: consumer); }
static void Main() { ConfigurationAccessor.GetConfig(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmLogger()); }
public static ILogConnector GetLogConnector() { var config = ConfigurationAccessor.GetConfig(); if (config.SourceName == "RabbitMQ") { return(new RabbitMQLogConnector(config as RabbitMQConfiguration)); } throw new ConfigurationException("This is no matched connector."); }
public static ILogConnector GetLogConnector() { var config = ConfigurationAccessor.GetConfig(); foreach (var connector in _connectors) { if (config.Source == connector.Name) { return(connector); } } throw new ConfigurationException("This is no matched connector."); }