当前位置:网站首页>channel. Detailed explanation of queuedeclare parameters

channel. Detailed explanation of queuedeclare parameters

2022-07-07 08:49:00 Mikaelemmmm

channel.QueueDeclare(name, durable, autoDelete, exclusive, noWait, args)

 

name: The queue name

 

durable: Persistent or not , The queue declaration is stored in memory by default , If rabbitmq Restart will lose , If you want to exist after restart, you need to make the queue persistent , Save to Erlang Self contained Mnesia In the database , When rabbitmq The database will be read after restart

 

autoDelete: Whether to automatically delete the queue after data consumption in the queue is completed , Whether the queue is automatically deleted after the last consumer disconnects , Can pass RabbitMQ Management, View the number of consumers in a queue , When consumers = 0 The queue will be deleted automatically

 

exclusive: Is it exclusive , It does two things , One : When the connection is closed connection.close() Whether the queue will be automatically deleted ; Two : Whether the queue is private private, If not exclusive , You can use both consumers to access the same queue , No problem , If it's exclusive , Lock the current queue , Other channels channel It's not accessible , If forced access, an exception will be reported :com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=405, reply-text=RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'queue_name' in vhost '/', class-id=50, method-id=20) Generally equal to true It is used in the scenario that only one consumer can consume in a queue

 

noWait: Whether to wait for the server to return

 

args: Related parameters , At present, it is generally nil

 

原网站

版权声明
本文为[Mikaelemmmm]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130630226092.html