rabbitmq series of problem solving: 406, "PRECONDITION_FAILED - inequivalent arg 'durable'

  1. Install rabbitmq, see the official website of the document: https://www.rabbitmq.com/#getstarted

  Because after I first installed the rabbitmq own hand to create a queue, behind and in accordance with the "hello world" example to go to the official test, the results were "406," PRECONDITION_FAILED - inequivalent arg 'durable' "error message.

  First in the queue 1. Management page created

  

 

 

 

exchanges 2. created

  

 

 

 

   The figure above the red line of durable refers to whether persistence, you can see the set when I create is true.

  3. The official hello world example:

             Document official website address: https: //www.rabbitmq.com/tutorials/tutorial-one-python.html

  Code (python version):

   (Producer)

 

 

  (consumer)

 

 

But when I run the above code, but given:

  

 

   Error message translates roughly meaning: the current queue of durable property is true, but when we declare queue last parameter is indeed false.

 The reason for this error is caused by the page now created the queue and exchanges, but the code declared queue to use when, durable transfer of property is false.

 ok, then the code how to engage? Return the wrong file can be found from the stack section pyhton error message: File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pika/adapters/blocking_connection.py"

  Then find the file, look at the source is what happens:

  

 

 

   可以看出来,这个函数里默认durable为false,那么我们将自己的代码改造一下,设置durable为true.

  

 

 执行结果:

  

 

 可以看到是成功了的。

要注意的是,生产者和消费者对queue的声明函数里,这个durable必须保持一致。

 

Guess you like

Origin www.cnblogs.com/zhaohuaxishi/p/12107392.html