{"id":27055,"date":"2024-11-24T18:44:56","date_gmt":"2024-11-24T10:44:56","guid":{"rendered":"https:\/\/fwq.ai\/blog\/?p=27055"},"modified":"2024-11-24T18:44:56","modified_gmt":"2024-11-24T10:44:56","slug":"amqp%e6%96%87%e4%bb%b6%e4%b8%ad%e7%9a%84%e5%b8%b8%e9%87%8f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27055\/","title":{"rendered":"AMQP\u6587\u4ef6\u4e2d\u7684\u5e38\u91cf"},"content":{"rendered":"<p>\/**<br \/>\n* Passing in this constant as a flag will forcefully disable all other flags.<br \/>\n* Use this if you want to temporarily disable the amqp.auto_ack ini setting.<br \/>\n* \u4f20\u9012\u8fd9\u4e2a\u53c2\u6570\u4f5c\u4e3a\u6807\u5fd7\u5c06\u5b8c\u5168\u7981\u7528\u5176\u4ed6\u6807\u5fd7,\u5982\u679c\u4f60\u60f3\u4e34\u65f6\u7981\u7528amqp.auto_ack\u8bbe\u7f6e\u8d77\u6548<br \/>\n*\/<\/p>\n<p>&nbsp;<\/p>\n<p><strong>define(\u2018AMQP_NOPARAM\u2019, 0);<\/strong><\/p>\n<p>\/**<br \/>\n* Durable exchanges and queues will survive a broker restart, complete with all of their data.<br \/>\n* \u6301\u4e45\u5316\u4ea4\u6362\u673a\u548c\u961f\u5217,\u5f53\u4ee3\u7406\u91cd\u542f\u52a8\u540e\u4f9d\u7136\u5b58\u5728,\u5e76\u5305\u62ec\u5b83\u4eec\u4e2d\u7684\u5b8c\u6574\u6570\u636e<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_DURABLE\u2019, 2);<\/strong><\/p>\n<p>\/**<br \/>\n* Passive exchanges and queues will not be redeclared, but the broker will throw an error if the exchange or queue does not exist.<br \/>\n* \u88ab\u52a8\u6a21\u5f0f\u7684\u4ea4\u6362\u673a\u548c\u961f\u5217\u4e0d\u80fd\u88ab\u91cd\u65b0\u5b9a\u4e49,\u4f46\u662f\u5982\u679c\u4ea4\u6362\u673a\u548c\u961f\u5217\u4e0d\u5b58\u5728,\u4ee3\u7406\u5c06\u6254\u51fa\u4e00\u4e2a\u9519\u8bef\u63d0\u793a<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_PASSIVE\u2019, 4);<\/strong><\/p>\n<p>\/**<br \/>\n* Valid for queues only, this flag indicates that only one client can be listening to and consuming from this queue.<br \/>\n* \u4ec5\u5bf9\u961f\u5217\u6709\u6548,\u8fd9\u4e2a\u4eba\u6807\u5fd7\u5b9a\u4e49\u961f\u5217\u4ec5\u5141\u8bb8\u4e00\u4e2a\u5ba2\u6237\u7aef\u8fde\u63a5\u5e76\u4e14\u4ece\u5176\u6d88\u8d39\u6d88\u606f<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_EXCLUSIVE\u2019, 8);<\/strong><\/p>\n<p>\/**<br \/>\n* For exchanges, the auto delete flag indicates that the exchange will be deleted as soon as no more queues are bound<br \/>\n* to it. If no queues were ever bound the exchange, the exchange will never be deleted. For queues, the auto delete<br \/>\n* flag indicates that the queue will be deleted as soon as there are no more listeners subscribed to it. If no<br \/>\n* subscription has ever been active, the queue will never be deleted. Note: Exclusive queues will always be<br \/>\n* automatically deleted with the client disconnects.<br \/>\n* \u5bf9\u4ea4\u6362\u673a\u800c\u8a00,\u81ea\u52a8\u5220\u9664\u6807\u5fd7\u8868\u793a\u4ea4\u6362\u673a\u5c06\u5728\u6ca1\u6709\u961f\u5217\u7ed1\u5b9a\u7684\u60c5\u51b5\u4e0b\u88ab\u81ea\u52a8\u5220\u9664,\u5982\u679c\u4ece\u6ca1\u6709\u961f\u5217\u548c\u5176\u7ed1\u5b9a\u8fc7,\u8fd9\u4e2a\u4ea4\u6362\u673a\u5c06\u4e0d\u4f1a\u88ab\u5220\u9664.<br \/>\n* \u5bf9\u961f\u5217\u800c\u8a00,\u81ea\u52a8\u5220\u9664\u6807\u5fd7\u8868\u793a\u5982\u679c\u6ca1\u6709\u6d88\u8d39\u8005\u548c\u4f60\u7ed1\u5b9a\u7684\u8bdd\u5c06\u88ab\u81ea\u52a8\u5220\u9664,\u5982\u679c\u4ece\u6ca1\u6709\u6d88\u8d39\u8005\u548c\u5176\u7ed1\u5b9a,\u5c06\u4e0d\u88ab\u5220\u9664,\u72ec\u5360\u961f\u5217\u5728\u5ba2\u6237\u65ad<br \/>\n* \u5f00\u8fde\u63a5\u7684\u65f6\u5019\u5c06\u603b\u662f\u4f1a\u88ab\u5220\u9664<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_AUTODELETE\u2019, 16);<\/strong><\/p>\n<p>\/**<br \/>\n* Clients are not allowed to make specific queue bindings to exchanges defined with this flag.<br \/>\n* \u8fd9\u4e2a\u6807\u5fd7\u6807\u8bc6\u4e0d\u5141\u8bb8\u81ea\u5b9a\u4e49\u961f\u5217\u7ed1\u5b9a\u5230\u4ea4\u6362\u673a\u4e0a<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_INTERNAL\u2019, 32);<\/strong><\/p>\n<p>\/**<br \/>\n* When passed to the consume method for a clustered environment, do not consume from the local node.<br \/>\n* \u5728\u96c6\u7fa4\u73af\u5883\u6d88\u8d39\u65b9\u6cd5\u4e2d\u4f20\u9012\u8fd9\u4e2a\u53c2\u6570,\u8868\u793a\u5c06\u4e0d\u4f1a\u4ece\u672c\u5730\u7ad9\u70b9\u6d88\u8d39\u6d88\u606f<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_NOLOCAL\u2019, 64);<\/strong><\/p>\n<p>\/**<br \/>\n* When passed to the {@link AMQPQueue::get()} and {@link AMQPQueue::get()} methods as a flag,<br \/>\n* the messages will be immediately marked as acknowledged by the server upon delivery.<br \/>\n* \u5f53\u5728\u961f\u5217get\u65b9\u6cd5\u4e2d\u4f5c\u4e3a\u6807\u5fd7\u4f20\u9012\u8fd9\u4e2a\u53c2\u6570\u7684\u65f6\u5019,\u6d88\u606f\u5c06\u5728\u88ab\u670d\u52a1\u5668\u8f93\u51fa\u4e4b\u524d\u6807\u5fd7\u4e3aacknowledged (\u5df2\u6536\u5230)<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_AUTOACK\u2019, 128);<\/strong><\/p>\n<p>\/**<br \/>\n* Passed on queue creation, this flag indicates that the queue should be deleted if it becomes empty.<br \/>\n* \u5728\u961f\u5217\u5efa\u7acb\u65f6\u5019\u4f20\u9012\u8fd9\u4e2a\u53c2\u6570,\u8fd9\u4e2a\u6807\u5fd7\u8868\u793a\u961f\u5217\u5c06\u5728\u4e3a\u7a7a\u7684\u65f6\u5019\u88ab\u5220\u9664<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_IFEMPTY\u2019, 256);<\/strong><\/p>\n<p>\/**<br \/>\n* Passed on queue or exchange creation, this flag indicates that the queue or exchange should be<br \/>\n* deleted when no clients are connected to the given queue or exchange.<br \/>\n* \u5728\u4ea4\u6362\u673a\u6216\u8005\u961f\u5217\u5efa\u7acb\u7684\u65f6\u5019\u4f20\u9012\u8fd9\u4e2a\u53c2\u6570,\u8fd9\u4e2a\u6807\u5fd7\u8868\u793a\u6ca1\u6709\u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u65f6\u5019,\u4ea4\u6362\u673a\u6216\u8005\u961f\u5217\u5c06\u88ab\u5220\u9664<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_IFUNUSED\u2019, 512);<\/strong><\/p>\n<p>\/**<br \/>\n* When publishing a message, the message must be routed to a valid queue. If it is not, an error will be returned.<br \/>\n* \u5f53\u53d1\u5e03\u6d88\u606f\u7684\u65f6\u5019,\u6d88\u606f\u5fc5\u987b\u88ab\u6b63\u786e\u8def\u7531\u5230\u4e00\u4e2a\u6709\u6548\u7684\u961f\u5217,\u5426\u5219\u5c06\u8fd4\u56de\u4e00\u4e2a\u9519\u8bef<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_MANDATORY\u2019, 1024);<\/strong><\/p>\n<p>\/**<br \/>\n* When publishing a message, mark this message for immediate processing by the broker. (High priority message.)<br \/>\n* \u5f53\u53d1\u5e03\u6d88\u606f\u65f6\u5019,\u8fd9\u4e2a\u6d88\u606f\u5c06\u88ab\u7acb\u5373\u5904\u7406.<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_IMMEDIATE\u2019, 2048);<\/strong><\/p>\n<p>\/**<br \/>\n* If set during a call to {@link AMQPQueue::ack()}, the delivery tag is treated as \u201cup to and including\u201d, so that multiple<br \/>\n* messages can be acknowledged with a single method. If set to zero, the delivery tag refers to a single message.<br \/>\n* If the AMQP_MULTIPLE flag is set, and the delivery tag is zero, this indicates acknowledgement of all outstanding<br \/>\n* messages.<br \/>\n* \u5f53\u5728\u8c03\u7528AMQPQueue::ack\u65f6\u5019\u8bbe\u7f6e\u8fd9\u4e2a\u6807\u5fd7,\u4f20\u9012\u6807\u7b7e\u5c06\u88ab\u89c6\u4e3a\u6700\u5927\u5305\u542b\u6570\u91cf,\u4ee5\u4fbf\u901a\u8fc7\u5355\u4e2a\u65b9\u6cd5\u6807\u793a\u591a\u4e2a\u6d88\u606f\u4e3a\u5df2\u6536\u5230,\u5982\u679c\u8bbe\u7f6e\u4e3a0<br \/>\n* \u4f20\u9012\u6807\u7b7e\u6307\u5411\u5355\u4e2a\u6d88\u606f,\u5982\u679c\u8bbe\u7f6e\u4e86AMQP_MULTIPLE,\u5e76\u4e14\u4f20\u9012\u6807\u7b7e\u662f0,\u5c06\u6240\u6709\u672a\u5b8c\u6210\u6d88\u606f\u6807\u793a\u4e3a\u5df2\u6536\u5230<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_MULTIPLE\u2019, 4096);<\/strong><\/p>\n<p>\/**<br \/>\n* If set during a call to {@link AMQPExchange::bind()}, the server will not respond to the method.The client should not wait<br \/>\n* for a reply method. If the server could not complete the method it will raise a channel or connection exception.<br \/>\n* \u5f53\u5728\u8c03\u7528AMQPExchange::bind()\u65b9\u6cd5\u7684\u65f6\u5019,\u670d\u52a1\u5668\u5c06\u4e0d\u54cd\u5e94\u8bf7\u6c42,\u5ba2\u6237\u7aef\u5c06\u4e0d\u5e94\u8be5\u7b49\u5f85\u54cd\u5e94,\u5982\u679c\u670d\u52a1\u5668\u65e0\u6cd5\u5b8c\u6210\u8be5\u65b9\u6cd5,\u5c06\u4f1a\u629b\u51fa\u4e00\u4e2a\u5f02\u5e38<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_NOWAIT\u2019, 8192);<\/strong><\/p>\n<p>\/**<br \/>\n* If set during a call to {@link AMQPQueue::nack()}, the message will be placed back to the queue.<br \/>\n* \u5982\u679c\u5728\u8c03\u7528AMQPQueue::nack\u65b9\u6cd5\u65f6\u5019\u8bbe\u7f6e,\u6d88\u606f\u5c06\u4f1a\u88ab\u4f20\u9012\u56de\u961f\u5217<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_REQUEUE\u2019, 16384);<\/strong><\/p>\n<p>\/**<br \/>\n* A direct exchange type.<br \/>\n* direct\u7c7b\u578b\u4ea4\u6362\u673a<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_EX_TYPE_DIRECT\u2019, \u2018direct\u2019);<\/strong><\/p>\n<p>\/**<br \/>\n* A fanout exchange type.<br \/>\n* fanout\u7c7b\u578b\u4ea4\u6362\u673a<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_EX_TYPE_FANOUT\u2019, \u2018fanout\u2019);<\/strong><\/p>\n<p>\/**<br \/>\n* A topic exchange type.<br \/>\n* topic\u7c7b\u578b\u4ea4\u6362\u673a<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_EX_TYPE_TOPIC\u2019, \u2018topic\u2019);<\/strong><\/p>\n<p>\/**<br \/>\n* A header exchange type.<br \/>\n* header\u7c7b\u578b\u4ea4\u6362\u673a<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_EX_TYPE_HEADERS\u2019, \u2018headers\u2019);<\/strong><\/p>\n<p>\/**<br \/>\n* socket\u8fde\u63a5\u8d85\u65f6\u8bbe\u7f6e<br \/>\n*\/<br \/>\n<strong>define(\u2018AMQP_OS_SOCKET_TIMEOUT_ERRNO\u2019, 536870947);<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/** * Passing in this constant as a flag will forcefully disable all other flags. * Use this if you want to temporarily disable the amqp.auto_ack ini setting. * \u4f20\u9012\u8fd9\u4e2a\u53c2\u6570\u4f5c\u4e3a\u6807\u5fd7\u5c06\u5b8c\u5168\u7981\u7528\u5176\u4ed6\u6807\u5fd7,\u5982\u679c\u4f60\u60f3\u4e34\u65f6\u7981\u7528amqp.auto_ack\u8bbe\u7f6e\u8d77\u6548 *\/ &nbsp; define(\u2018AMQP_NOPARAM\u2019, 0); \/** * Durable exchanges and queues will survive a broker restart, complete with all of their data. * \u6301\u4e45\u5316\u4ea4\u6362\u673a\u548c\u961f\u5217,\u5f53\u4ee3\u7406\u91cd\u542f\u52a8\u540e\u4f9d\u7136\u5b58\u5728,\u5e76\u5305\u62ec\u5b83\u4eec\u4e2d\u7684\u5b8c\u6574\u6570\u636e *\/ define(\u2018AMQP_DURABLE\u2019, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-27055","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27055","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=27055"}],"version-history":[{"count":1,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27055\/revisions"}],"predecessor-version":[{"id":27060,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27055\/revisions\/27060"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27055"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}