当前位置: 代码迷 >> 综合 >> new Queue(REGISTER_DELAY_QUEUE, true, false, false, params)
  详细解决方案

new Queue(REGISTER_DELAY_QUEUE, true, false, false, params)

热度:60   发布时间:2023-11-08 01:04:13.0
@Beanpublic Queue delayProcessQueue() {Map<String, Object> params = new HashMap<>();// x-dead-letter-exchange 声明了队列里的死信转发到的DLX名称,params.put("x-dead-letter-exchange", REGISTER_EXCHANGE_NAME);// x-dead-letter-routing-key 声明了这些死信在转发时携带的 routing-key 名称。params.put("x-dead-letter-routing-key", ROUTING_KEY);return new Queue(REGISTER_DELAY_QUEUE, true, false, false, params);}

解释上述代码中的 Queue类的API:

// 构造一个新的队列,给出一个名称、耐久性标志、排他和自动删除标志和参数;

construct a new queue,given a name,durability flag, exclusive and auto-delete flag,and arguments;

// 队列名字
name;

// 如果声明一个持久队列(该队列将在服务器重新启动后继续存在),则为true;
true if we are declaring a durable queue(the queue will survive a server restart) ; 

// 如果我们声明一个排他队列(该队列将仅由声明者的连接使用),则为true;
true if we are  declaring an exclusive queue(the queue will only be used by the declarer`s connection);

// 如果服务器不再使用时应删除队列,则为true;
true if the server should delete the queue  when it is no longer in use; 

// 用于声明队列的参数;
the argument used to declare hthe queue;

  相关解决方案