本文权当各位看官对RabbitMQ的基本概念以及使用场景有了一定的了解,如果你还对它所知甚少或者只是停留在仅仅是听说过,建议你先看看这篇文章,在对RabbitMQ有了基本认识后,我们正式开启我们的RabbitMQ之旅吧,希望本文能够帮助大家在实际用到消息队列时有所帮助,如有表述的不当之处,还望各位看官指正。

一、消息队列的安装

1、 RabbitMQ是用Erlang编程语言进行开发,所以首先得在Erlang官网下载Erlang运行的环境,如图,选择所需对应文件进行下载,并进行安装:

2、 设置环境变量,如图

3、 去RabbitMQ官网下载对应操作系统的安装文件,并进行安装如图:

4、 以管理员方式打开cmd,定位到RabbitMQ安装目录sbin文件夹下,依次执行以下命令

(1)     rabbitmq-service install

(2)     rabbitmq-service enable

(3)     rabbitmq-service start

如图:

到这里我们的RabbitMQ服务已经安装好了,利用Windows + R键,输入services.msc查看,RabbitMQ服务已经处于运行的状态了。

5、 到这里不要以为我们的工作就结束了,接下来我们为RabbitMQ设置用户以及密码

在cmd中执行 rabbitmqctl list_users 查看RabbitMQ已存在的用户,如图

这里发现有两个账号 rabbit 是我之前添加的,guest 是RabbitMQ自带的,

执行以下命令,添加RabbitMQ用户,并设置相应权限:

rabbitmqctl add_user bestadmin 123456

rabbitmqctl set_permissions  bestadmin ".*"  ".*"  ".*"

rabbitmqctl set_user_tags bestadmin administrator

如图:

6、 RabbitMQ有一个可视化界面,进行消息的管理,不过需要用命名rabbitmq-plugins enable rabbitmq_management 命令进行启动,接下来我们便可以在浏览器输入127.0.0.1:15672中进行查看,如图:

输入我们刚设置的用户名bestuser 密码123,如图:

一、消息队列的使用

我们知道RabbitMQ的Exchange常用交换器类型分为fanout、direct、topic、headers 4种类型,这里我们将对fanout、direct、topic 3种类型以实际代码的形式进行讲解,至于关于交换器对各类型的具体讲解,请参照文章开始给出的链接进行了解,这里就不再赘述,我们新建了如下图的解决方案:

1、RabbitMQHelper 帮助类,对常用的消息入队以及消费消息进行了简单的封装:

 /// <summary>
/// RabbitMQHelper
/// </summary>
public class RabbitMQHelper
{
private static ConnectionFactory _connectionFactory = null;
private static readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings { Formatting = Formatting.None, NullValueHandling = NullValueHandling.Ignore }; /// <summary>
/// 构造函数
/// </summary>
static RabbitMQHelper()
{
_connectionFactory = new ConnectionFactory();
_connectionFactory.HostName = ConfigurationManager.AppSettings["HostName"].ToString();
_connectionFactory.UserName = ConfigurationManager.AppSettings["UserName"].ToString();
_connectionFactory.Password = ConfigurationManager.AppSettings["Password"].ToString();
_connectionFactory.AutomaticRecoveryEnabled = true;
} #region 单消息入队
/// <summary>
/// 单消息入队
/// </summary>
/// <param name="exchangeName">交换器名称</param>
/// <param name="exchangeType">交换器类型</param>
/// <param name="routingKey">路由关键字</param>
/// <param name="queueName">队列名称</param>
/// <param name="message">消息实例</param>
/// <param name="arguments">消息的参数信息(如: 队列过期时间:x-expires;消息过期时间:x-message-ttl;过期消息转向路由:x-dead-letter-exchange;过期消息转向路由:x-dead-letter-routing-key 等。)</param>
public static void Enqueue<TItem>(string exchangeName, string exchangeType, string routingKey, string queueName, TItem message, IDictionary<string, object> arguments = null)
{
if (message != null)
{
using (IConnection connection = _connectionFactory.CreateConnection())
{
using (IModel channel = connection.CreateModel())
{
channel.ExchangeDeclare(exchangeName, exchangeType, true, false, arguments);
channel.QueueDeclare(queueName, true, false, false, arguments);
channel.QueueBind(queueName, exchangeName, routingKey);
var properties = channel.CreateBasicProperties();
properties.Persistent = true; //使消息持久化
properties.ContentType = "application/json";
string messageString = JsonConvert.SerializeObject(message, _jsonSettings);
byte[] body = Encoding.UTF8.GetBytes(messageString);
channel.BasicPublish(exchangeName, routingKey, properties, body);
}
}
}
}
#endregion #region 单消息入队(字符串入队)
/// <summary>
/// 单消息入队(字符串入队)
/// </summary>
/// <param name="exchangeName">交换器名称</param>
/// <param name="exchangeType">交换器类型</param>
/// <param name="routingKey">路由关键字</param>
/// <param name="queueName">队列名称</param>
/// <param name="message">消息实例</param>
/// <param name="arguments">消息的参数信息(如: 队列过期时间:x-expires;消息过期时间:x-message-ttl;过期消息转向路由:x-dead-letter-exchange;过期消息转向路由:x-dead-letter-routing-key 等。)</param>
public static void Enqueue(string exchangeName, string exchangeType, string routingKey, string queueName, string message, IDictionary<string, object> arguments = null)
{
if (!string.IsNullOrWhiteSpace(message))
{
using (IConnection connection = _connectionFactory.CreateConnection())
{
using (IModel channel = connection.CreateModel())
{
channel.ExchangeDeclare(exchangeName, exchangeType, true, false, arguments);
channel.QueueDeclare(queueName, true, false, false, arguments);
channel.QueueBind(queueName, exchangeName, routingKey);
var properties = channel.CreateBasicProperties();
properties.Persistent = true; //使消息持久化
byte[] body = Encoding.UTF8.GetBytes(message);
channel.BasicPublish(exchangeName, routingKey, properties, body);
}
}
}
}
#endregion #region 消息批量入队
/// <summary>
/// 消息批量入队
/// </summary>
/// <param name="exchangeName">交换器名称</param>
/// <param name="exchangeType">交换器类型</param>
/// <param name="routingKey">路由关键字</param>
/// <param name="queueName">队列名称</param>
/// <param name="list">消息集合</param>
/// <param name="arguments">消息的参数信息(如: 队列过期时间:x-expires;消息过期时间:x-message-ttl;过期消息转向路由:x-dead-letter-exchange;过期消息转向路由:x-dead-letter-routing-key 等。)</param>
public static void Enqueue<TItem>(string exchangeName, string exchangeType, string routingKey, string queueName, List<TItem> list, IDictionary<string, object> arguments = null)
{
if (list != null && list.Count > )
{
using (IConnection connection = _connectionFactory.CreateConnection())
{
using (IModel channel = connection.CreateModel())
{
foreach (TItem item in list)
{
if (item != null)
{
channel.ExchangeDeclare(exchangeName, exchangeType, true, false, arguments);
channel.QueueDeclare(queueName, true, false, false, arguments);
channel.QueueBind(queueName, exchangeName, routingKey);
string messageString = JsonConvert.SerializeObject(item, _jsonSettings);
byte[] body = Encoding.UTF8.GetBytes(messageString);
var properties = channel.CreateBasicProperties();//使消息持久化
properties.ContentType = "application/json";
properties.Persistent = true;
channel.BasicPublish(exchangeName, routingKey, properties, body);
}
}
}
}
}
}
#endregion #region 消费消息队列(旧的方式)
/// <summary>
/// 消费消息队列
/// </summary>
/// <typeparam name="TItem">消息对象</typeparam>
/// <param name="exchangeName">交换器名称</param>
/// <param name="exchangeType">交换器类型</param>
/// <param name="routingKey">路由关键字</param>
/// <param name="queueName">队列名称</param>
/// <param name="func">消费消息的具体操作</param>
/// <param name="failFunc">消费消息失败的具体操作</param>
/// <param name="tryTimes">消费失败后,继续尝试消费的次数</param>
/// <param name="arguments">消息的参数信息(如: 队列过期时间:x-expires;消息过期时间:x-message-ttl;过期消息转向路由:x-dead-letter-exchange;过期消息转向路由:x-dead-letter-routing-key 等。)</param>
/// <param name="isAgain">是否重新入队</param>
public static void Consume<TItem>(string exchangeName, string exchangeType, string routingKey, string queueName, Func<TItem, bool> func, Func<TItem, bool> failFunc = null,
int tryTimes = , IDictionary<string, object> arguments = null, bool isAgain = false)
{
try
{
int consumeCount = ;//尝试消费次数
bool isConsumeSuccess;//是否消费成功
using (IConnection connection = _connectionFactory.CreateConnection())
{
using (IModel channel = connection.CreateModel())
{
channel.ExchangeDeclare(exchangeName, exchangeType, true, false, arguments);
channel.QueueDeclare(queueName, true, false, false, arguments);
channel.QueueBind(queueName, exchangeName, routingKey);
QueueingBasicConsumer consumer = new QueueingBasicConsumer(channel);
channel.BasicConsume(queueName, false, consumer);
while (true)
{
var ea = consumer.Queue.Dequeue();
var body = ea.Body;
var message = Encoding.UTF8.GetString(body);
TItem queueMessage = JsonConvert.DeserializeObject<TItem>(message, _jsonSettings);
if (queueMessage != null)
{
consumeCount = ;
while (true)
{
consumeCount++;
isConsumeSuccess = func(queueMessage);
if (isConsumeSuccess || consumeCount >= tryTimes)
{
channel.BasicAck(ea.DeliveryTag, false);//将队列里面的消息进行释放
if (!isConsumeSuccess && failFunc != null)
{
failFunc(queueMessage);//消费消息失败的具体操作
}
#region 消息处理失败后重新入队
if (!isConsumeSuccess && isAgain)
{
var properties = channel.CreateBasicProperties();
properties.Persistent = true;
channel.BasicPublish(exchangeName, routingKey, properties, body);
}
#endregion
break;
}
}
}
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion #region 消费消息队列(旧的方式)
/// <summary>
/// 消费消息队列
/// </summary>
/// <param name="exchangeName">交换器名称</param>
/// <param name="exchangeType">交换器类型</param>
/// <param name="routingKey">路由关键字</param>
/// <param name="queueName">队列名称</param>
/// <param name="func">消费消息的具体操作</param>
/// <param name="failFunc">消费消息失败的具体操作</param>
/// <param name="tryTimes">消费失败后,继续尝试消费的次数</param>
/// <param name="arguments">消息的参数信息(如: 队列过期时间:x-expires;消息过期时间:x-message-ttl;过期消息转向路由:x-dead-letter-exchange;过期消息转向路由:x-dead-letter-routing-key 等。)</param>
/// <param name="isAgain">是否重新入队</param>
public static void ConsumeString(string exchangeName, string exchangeType, string routingKey, string queueName, Func<string, bool> func, Func<string, bool> failFunc = null,
int tryTimes = , IDictionary<string, object> arguments = null, bool isAgain = false)
{
try
{
int consumeCount = ;//尝试消费次数
using (IConnection connection = _connectionFactory.CreateConnection())
{
using (IModel channel = connection.CreateModel())
{
channel.ExchangeDeclare(exchangeName, exchangeType, true, false, arguments);
channel.QueueDeclare(queueName, true, false, false, arguments);
channel.QueueBind(queueName, exchangeName, routingKey);
QueueingBasicConsumer consumer = new QueueingBasicConsumer(channel);
channel.BasicConsume(queueName, false, consumer);
while (true)
{
var ea = consumer.Queue.Dequeue();
var body = ea.Body;
var message = Encoding.UTF8.GetString(body);
if (!string.IsNullOrWhiteSpace(message))
{
consumeCount = ;
while (true)
{
consumeCount++;
bool isConsumeSuccess = func(message);
if (isConsumeSuccess || consumeCount >= tryTimes)
{
channel.BasicAck(ea.DeliveryTag, false);//将队列里面的消息进行释放
if (!isConsumeSuccess && failFunc != null)
{
failFunc(message);//消费消息失败的具体操作
}
#region 消息处理失败后重新入队
if (!isConsumeSuccess && isAgain)
{
var properties = channel.CreateBasicProperties();
properties.Persistent = true;
channel.BasicPublish(exchangeName, routingKey, properties, body);
}
#endregion
break;
}
}
}
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion #region 消费消息队列(新的方式)
/// <summary>
/// 消费消息队列
/// </summary>
/// <typeparam name="TItem">消息对象</typeparam>
/// <param name="exchangeName">交换器名称</param>
/// <param name="exchangeType">交换器类型</param>
/// <param name="routingKey">路由关键字</param>
/// <param name="queueName">队列名称</param>
/// <param name="func">消费消息的具体操作</param>
/// <param name="tryTimes">消费失败后,继续尝试消费的次数</param>
/// <param name="arguments">消息的参数信息(如: 队列过期时间:x-expires;消息过期时间:x-message-ttl;过期消息转向路由:x-dead-letter-exchange;过期消息转向路由:x-dead-letter-routing-key 等。)</param>
public static void NewConsume<TItem>(string exchangeName, string exchangeType, string routingKey, string queueName, Func<TItem, bool> func, int tryTimes = , IDictionary<string, object> arguments = null)
{
try
{
int consumeCount = ;//尝试消费次数
using (IConnection connection = _connectionFactory.CreateConnection())
{
using (IModel channel = connection.CreateModel())
{
channel.ExchangeDeclare(exchangeName, exchangeType, true, false, arguments);
channel.QueueDeclare(queueName, true, false, false, arguments);
channel.QueueBind(queueName, exchangeName, routingKey);
EventingBasicConsumer consumer = new EventingBasicConsumer(channel);
consumer.Received += (sender, eventArgs) =>
{
byte[] body = eventArgs.Body;
if (body != null && body.Length > )
{
string message = Encoding.UTF8.GetString(body);
if (!string.IsNullOrWhiteSpace(message))
{
TItem queueMessage = JsonConvert.DeserializeObject<TItem>(message, _jsonSettings);
if (queueMessage != null)
{
consumeCount = ;
while (true)
{
consumeCount++;
bool isConsumeSuccess = func(queueMessage);
if (isConsumeSuccess || consumeCount >= tryTimes)
{
channel.BasicAck(eventArgs.DeliveryTag, false);//将队列里面的消息进行释放
break;
}
}
}
}
}
};
channel.BasicConsume(queueName, false, consumer);
}
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion #region 消费消息队列(新的方式)
/// <summary>
/// 消费消息队列
/// </summary>
/// <param name="exchangeName">交换器名称</param>
/// <param name="exchangeType">交换器类型</param>
/// <param name="routingKey">路由关键字</param>
/// <param name="queueName">队列名称</param>
/// <param name="func">消费消息的具体操作</param>
/// <param name="failFunc">消费消息失败的具体操作</param>
/// <param name="tryTimes">消费失败后,继续尝试消费的次数</param>
/// <param name="arguments">消息的参数信息(如: 队列过期时间:x-expires;消息过期时间:x-message-ttl;过期消息转向路由:x-dead-letter-exchange;过期消息转向路由:x-dead-letter-routing-key 等。)</param>
/// <param name="isAgain">是否重新入队</param>
public static void NewConsumeString(string exchangeName, string exchangeType, string routingKey, string queueName, Func<string, bool> func, Func<string, bool> failFunc = null,
int tryTimes = , IDictionary<string, object> arguments = null, bool isAgain = false)
{
try
{
int consumeCount = ;//尝试消费次数
using (IConnection connection = _connectionFactory.CreateConnection())
{
using (IModel channel = connection.CreateModel())
{
channel.ExchangeDeclare(exchangeName, exchangeType, true, false, arguments);
channel.QueueDeclare(queueName, true, false, false, arguments);
channel.QueueBind(queueName, exchangeName, routingKey);
EventingBasicConsumer consumer = new EventingBasicConsumer(channel);
consumer.Received += (sender, eventArgs) =>
{
byte[] body = eventArgs.Body;
if (body != null && body.Length > )
{
string message = Encoding.UTF8.GetString(body);
if (!string.IsNullOrWhiteSpace(message))
{
consumeCount = ;
while (true)
{
consumeCount++;
bool isConsumeSuccess = func(message);
if (isConsumeSuccess || consumeCount >= tryTimes)
{
channel.BasicAck(eventArgs.DeliveryTag, false);//将队列里面的消息进行释放
if (!isConsumeSuccess && failFunc != null)
{
failFunc(message);//消费消息失败的具体操作
}
#region 消息处理失败后重新入队
if (!isConsumeSuccess && isAgain)
{
var properties = channel.CreateBasicProperties();
properties.Persistent = true;
channel.BasicPublish(exchangeName, routingKey, properties, body);
}
#endregion
break;
}
}
}
}
};
channel.BasicConsume(queueName, false, consumer);
}
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}

 备注:需要说明的是这里在对消费消息的方法进行封装的过程中使用了泛型委托,这样我们就只需要按照自己的业务需求,对消息进行处理了。

2、 fanout类型:简单的说适合这样的场景,一个生产者产生的消息,需要将该消息发送到多个消息队列,供多个消费者进行消费。这里,为了对该场景进行还原,所以新建了RabbitMQConsumer,RabbitMQConsumer1两个消费者。

生产者代码:

       public Form1()
{
InitializeComponent();
} private void Producer_Click(object sender, EventArgs e)
{
RabbitMQHelper.Enqueue("developExchange", "fanout", "", new Developer() { Id = Guid.NewGuid(), Name = "nickdeng", Position = "开发" });
}

消费者1代码:

  class Program
{
static void Main(string[] args)
{
RabbitMQHelper.Consume<Developer>("developExchange", "fanout", "", "developQueue", ConsumeMessage);
} /// <summary>
/// 消费消息
/// </summary>
/// <param name="developer">处理对象</param>
/// <returns>消费结果</returns>
public static bool ConsumeMessage(Developer developer)
{
string message = JsonConvert.SerializeObject(developer);
Console.Write(message);
return true;
}
}

消费者2代码:

  class Program
{
static void Main(string[] args)
{
RabbitMQHelper.Consume<Developer>("developExchange", "fanout", "", "developQueue1", ConsumeMessage);
} /// <summary>
/// 消费消息
/// </summary>
/// <param name="developer">处理对象</param>
/// <returns>消费结果</returns>
public static bool ConsumeMessage(Developer developer)
{
string message = JsonConvert.SerializeObject(developer);
Console.Write(message);
return true;
}
}

消费者1与消费者2的代码,眨眼一看,不是一样的吗?仔细看会发现它们在的消息队列名称不一样,消费者1的队列名称是“developQueue”,消息者2的队列名称是“developQueue1”,因为这两个消息队列都与交换器“developExchange”进行了绑定,所以生产者产生的消息将被推送到这两个消息队列。运行代码,得到如下图结果:

3、direct类型:直译过来就是直接的意思,该类型适用于点对点的使用场景,生产者将消息发送到指定的消息队列:

生产者代码:

      public Form1()
{
InitializeComponent();
} private void Producer_Click(object sender, EventArgs e)
{
RabbitMQHelper.Enqueue("developExchange1", "direct", "directkey", new Developer() { Id = Guid.NewGuid(), Name = "nickdeng", Position = "开发" });
}

消费者1代码:

        static void Main(string[] args)
{
RabbitMQHelper.Consume<Developer>("developExchange1", "direct", "directkey", "developQueue", ConsumeMessage);
} /// <summary>
/// 消费消息
/// </summary>
/// <param name="developer">处理对象</param>
/// <returns>消费结果</returns>
public static bool ConsumeMessage(Developer developer)
{
string message = JsonConvert.SerializeObject(developer);
Console.Write(message);
return true;
}

消费者2代码:

        static void Main(string[] args)
{
RabbitMQHelper.Consume<Developer>("developExchange1", "direct", "directkey1", "developQueue1", ConsumeMessage);
} /// <summary>
/// 消费消息
/// </summary>
/// <param name="developer">处理对象</param>
/// <returns>消费结果</returns>
public static bool ConsumeMessage(Developer developer)
{
string message = JsonConvert.SerializeObject(developer);
Console.Write(message);
return true;
}

生产者的路由关键字是“directkey”,消费者1的路由关键字为”directkey“,消费者2的路由关键字为”directkey1“,仅仅一字相差,生产者产生的消息就只有消费者1能够收到,运行代码得到如图结果:

至于topic类型,这里就不再以代码进行讲解了,其实大致使用方法与上面的direct类型相似,不同之处在于topic类型可通过路由关键字进行模糊匹配,将消息路由到相应队列,大家可根据自己的实际使用场景,进行类型的选择。

RabbitMQ消息队列随笔的更多相关文章

  1. 使用EasyNetQ组件操作RabbitMQ消息队列服务

    RabbitMQ是一个由erlang开发的AMQP(Advanved Message Queue)的开源实现,是实现消息队列应用的一个中间件,消息队列中间件是分布式系统中重要的组件,主要解决应用耦合, ...

  2. RabbitMQ消息队列(一): Detailed Introduction 详细介绍

     http://blog.csdn.net/anzhsoft/article/details/19563091 RabbitMQ消息队列(一): Detailed Introduction 详细介绍 ...

  3. RabbitMQ消息队列1: Detailed Introduction 详细介绍

    1. 历史 RabbitMQ是一个由erlang开发的AMQP(Advanced Message Queue )的开源实现.AMQP 的出现其实也是应了广大人民群众的需求,虽然在同步消息通讯的世界里有 ...

  4. (转)RabbitMQ消息队列(九):Publisher的消息确认机制

    在前面的文章中提到了queue和consumer之间的消息确认机制:通过设置ack.那么Publisher能不到知道他post的Message有没有到达queue,甚至更近一步,是否被某个Consum ...

  5. (转)RabbitMQ消息队列(七):适用于云计算集群的远程调用(RPC)

    在云计算环境中,很多时候需要用它其他机器的计算资源,我们有可能会在接收到Message进行处理时,会把一部分计算任务分配到其他节点来完成.那么,RabbitMQ如何使用RPC呢?在本篇文章中,我们将会 ...

  6. (转)RabbitMQ消息队列(六):使用主题进行消息分发

    在上篇文章RabbitMQ消息队列(五):Routing 消息路由 中,我们实现了一个简单的日志系统.Consumer可以监听不同severity的log.但是,这也是它之所以叫做简单日志系统的原因, ...

  7. (转)RabbitMQ消息队列(四):分发到多Consumer(Publish/Subscribe)

    上篇文章中,我们把每个Message都是deliver到某个Consumer.在这篇文章中,我们将会将同一个Message deliver到多个Consumer中.这个模式也被成为 "pub ...

  8. RabbitMQ消息队列应用

    RabbitMQ消息队列应用 消息通信组件Net分布式系统的核心中间件之一,应用与系统高并发,各个组件之间解耦的依赖的场景.本框架采用消息队列中间件主要应用于两方面:一是解决部分高并发的业务处理:二是 ...

  9. RabbitMQ消息队列(四):分发到多Consumer(Publish/Subscribe)

    上篇文章中,我们把每个Message都是deliver到某个Consumer.在这篇文章中,我们将会将同一个Message deliver到多个Consumer中.这个模式也被成为 "pub ...

随机推荐

  1. Redis系列-存储篇list主要操作函数小结(转)

    在总结list之前,先要弄明白几个跟list相关的概念: 列表:一个从左到右的队列,个人理解更类似于一个栈,常规模式下,先进列表的元素,后出. 表头元素:列表最左端第一个元素. 表尾元素:列表最右端的 ...

  2. mysql忘记root密码且忘了安装目录如何修改root密码

    问题背景 很久之前在本机上安装mysql,也没用过(主要是用Oracle),导致root密码忘记.更严重的是,连自己的安装目录都忘记了. 遇到的问题 1.在任务管理器可以找到mysql的服务已经起来, ...

  3. 模块:(日期选择)jquery、bootstrap实现日期下拉选择+bootstrap jquery UI自带动画的日期选择器

    一:jquery.bootstrap实现日期下拉选择 点击文本框弹出窗口 弹窗显示日期时间选择下拉 年份取当前年份的前后各5年 天数随年份和月份的变化而变化 点击保存,文本框中显示选中的日期 代码部分 ...

  4. 【BZOJ4198】[Noi2015]荷马史诗 贪心+堆

    [BZOJ4198][Noi2015]荷马史诗 Description 追逐影子的人,自己就是影子. ——荷马 Allison 最近迷上了文学.她喜欢在一个慵懒的午后,细细地品上一杯卡布奇诺,静静地阅 ...

  5. EasyDSS流媒体视频实时回传与录像管理解决方案

    一.背景 1.1 方案背景 随着互联网基础设施建设的不断完善和发展,带宽的不断提速,尤其是光纤入户,4G/5G/NB-IoT各种技术的大规模商用,视频在各行各业越来越受到重视,无论是传统的视频媒体转向 ...

  6. Angular入门(二) 服务

    目的:为了不再把相同的代码复制一遍又一遍,我们要创建一个单一的可复用的数据服务,并且把它注入到需要它的那些组件中. ※  文件命名约定:服务名称的小写形式(基本名),加上.service后缀,如果服务 ...

  7. Asp.Net中判断是否登录,及是否有权限?

    不需要在每个页面都做判段, 方法一:只需要做以下处理即可 using System; using System.Collections.Generic; using System.Linq; usin ...

  8. Upgrading Elasticsearch

    Upgrading Elasticsearch | Elasticsearch Reference [5.6] | Elastic https://www.elastic.co/guide/en/el ...

  9. squared-error loss is much more repaidly updated than mean-absolute-deviation when searching for splits

    平方差损失能较绝对值差损失更快地更新

  10. 【题解】 CF734F 【Anton and School】

    题解 CF734F [Anton and School] 传送门 这种将位运算和普通运算结合起来的题目要拆位来考虑,可以得到\(log_{2}(\)值域\()\)的算法,甚至将值域看成常数. 根据 \ ...