private void Connect() { ConfigServiceMQ config = getConfig <ConfigServiceMQ>(); //throw new NotImplementedException(); getLogger().LogInformation("Connecting to MQ Service"); ConnectionFactory factory; //factory = new ConnectionFactory() { HostName = config.Host }; factory = new ConnectionFactory { HostName = config.Host, // Port = 5672, UserName = config.User, Password = config.Password, VirtualHost = config.VirtualHost, RequestedHeartbeat = 60 }; // factory.UserName = config.User; // factory.Password = config.Password; //factory.VirtualHost = "/";// config.VirtualHost; //factory.Port = 5672; //TODO:: Handle Server not found (Timeout) mq_connection = factory.CreateConnection( ); //using (mq_connection = factory.CreateConnection()) { mq_channel = mq_connection.CreateModel(); //Create Configuration exchange //mq_channel.ExchangeDeclare(EXCHANGE_CONFIG, "fanout"); //Create Control exchange mq_channel.ExchangeDeclare(EXCHANGE_CONTROL, "direct"); //Create State exchange mq_channel.ExchangeDeclare(EXCHANGE_STATE, "fanout"); /* using (mq_channel = mq_connection.CreateModel()) * { * //Create Configuration exchange * mq_channel.ExchangeDeclare("homemgr.config", "fanout"); * * //Create State exchange * mq_channel.ExchangeDeclare("homemgr.state", "fanout"); * * } */ } }
public ServiceMQ(ConfigServiceMQ config, IManager manager) : base(config, manager) { ILoggerFactory loggerFactory = new LoggerFactory() .AddConsole(); //.AddDebug(); }