zoukankan      html  css  js  c++  java
  • RabbitMQ 队列、消息持久化

    RabbitMQ的消息队列的持久化是一个很不错的功能,设置也非常简单。如下代码:

    1、设置队列持久化(在声明队列的时候设置)

    channel.QueueDeclare(queue: "q.log.error",//队列名称
                         durable: true,//当前队列是否持久化 true:是 false:不是
                         exclusive: false,
                         autoDelete: false,
                         arguments: null);

    2、设置消息持久化(发布消息的时候设置)

     var body = Encoding.UTF8.GetBytes("测试消息");
     var properties = channel.CreateBasicProperties();
     //设置消息持久化
     properties.SetPersistent(true);                
     channel.BasicPublish(exchange: "e.log",
                          routingKey: "log.error",
                          basicProperties: properties,
                          body: body);
  • 相关阅读:
    Swagger入门
    UOS
    Java多线程
    英语语法小知识-Unit1
    MVVM
    Vue入门
    Mybatis入门
    Python pip install
    js 触发LinkButton点击事件,执行后台方法
    ajax 请求 ascx
  • 原文地址:https://www.cnblogs.com/williamwsj/p/8109366.html
Copyright © 2011-2022 走看看