Example #1
0
        public void Emit(T objeto, string cola = "default", string ruta = "default", bool duradero = false, bool exclusivo = false, bool autoBorrado = false, IDictionary <string, object> argumentos = null)
        {
            ConnectionFactory conn = new ConnectionFactory();

            conn.Uri = new Uri(_URI_CONEXION);
            using (IConnection cn = conn.CreateConnection())
            {
                using (IModel ch = cn.CreateModel())
                {
                    JsonSerialize <T> jser  = new JsonSerialize <T>();
                    byte[]            datos = jser.GetJsonStr(objeto);

                    //Enviamos
                    ch.QueueDeclare(queue: cola,
                                    durable: duradero,
                                    exclusive: exclusivo,
                                    autoDelete: autoBorrado,
                                    arguments: argumentos);

                    ch.BasicPublish(exchange: "",
                                    routingKey: ruta,
                                    basicProperties: null,
                                    body: datos);
                }
            }
        }