Exemplo n.º 1
0
        public static RabbitContext Create(this RabbitContext ctx, string fileName)
        {
            ctx = new RabbitContext();

            var    filePath     = Path.Combine(@"Configuration", fileName);
            string fullFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filePath);
            string json         = File.ReadAllText(fullFilePath);

            ctx = JsonConvert.DeserializeObject <RabbitContext>(json);
            return(ctx);
        }
Exemplo n.º 2
0
        public Receiver(RabbitContext ctx)
        {
            this.ctx = ctx;

            try
            {
                var factory = new ConnectionFactory()
                {
                    VirtualHost = ctx.Connection.VirtualHost,
                    HostName    = ctx.Connection.HostName,
                    UserName    = ctx.Connection.UserName,
                    Password    = ctx.Connection.Password
                };

                this.connection = Connection.Connect();
                this.channel    = connection.CreateModel();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"RabbitListener init error,ex:{ex.Message}");
                throw ex;
            }
        }
Exemplo n.º 3
0
 public Sender(RabbitContext ctx)
 {
     this.ctx = ctx;
 }