{"id":2448,"date":"2025-03-24T08:47:15","date_gmt":"2025-03-23T23:47:15","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=2448"},"modified":"2025-03-24T08:47:46","modified_gmt":"2025-03-23T23:47:46","slug":"php%e3%82%a8%e3%83%b3%e3%82%b8%e3%83%8b%e3%82%a2%e3%81%ae%e3%81%9f%e3%82%81%e3%81%aerabbitmq%e5%ae%8c%e5%85%a8%e3%82%ac%e3%82%a4%e3%83%89%ef%bc%9a%e5%ae%9f%e8%b7%b5%e3%81%8b%e3%82%89%e9%81%8b%e7%94%a8","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=2448","title":{"rendered":"PHP\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u305f\u3081\u306eRabbitMQ\u5b8c\u5168\u30ac\u30a4\u30c9\uff1a\u5b9f\u8df5\u304b\u3089\u904b\u7528\u307e\u306715\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9"},"content":{"rendered":"\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"\u76ee\u6b21\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">RabbitMQ \u3068\u306f\uff1aPHP \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u3082\u305f\u3089\u3059 5 \u3064\u306e\u9769\u65b0<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-1\">\u975e\u540c\u671f\u51e6\u7406\u306b\u3088\u308b\u5727\u5012\u7684\u306a\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a<\/a>      <\/li>      <li>        <a href=\"#i-2\">\u30b9\u30b1\u30fc\u30e9\u30d6\u30eb\u306a\u30b7\u30b9\u30c6\u30e0\u8a2d\u8a08\u306e\u5b9f\u73fe<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-3\">\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u3078\u306e\u6700\u9069\u5316<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-4\">PHP \u3067\u306e RabbitMQ \u5b9f\u88c5\u624b\u9806\uff1a\u78ba\u5b9f\u306a\u5c0e\u5165\u306e\u305f\u3081\u306b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-5\">Composer \u3067\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u624b\u9806<\/a>      <\/li>      <li>        <a href=\"#i-6\">\u57fa\u672c\u7684\u306a\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-7\">\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u9001\u4fe1\u53d7\u4fe1\u30b3\u30fc\u30c9\u306e\u5b9f\u88c5\u4f8b<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-8\">RabbitMQ \u306e\u904b\u7528\u30c6\u30af\u30cb\u30c3\u30af\uff1a\u30c8\u30e9\u30d6\u30eb\u3092\u672a\u7136\u306b\u9632\u3050<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-9\">\u30e1\u30c3\u30bb\u30fc\u30b8\u30ad\u30e5\u30fc\u306e\u76e3\u8996\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-10\">\u30c7\u30c3\u30c9\u30ec\u30bf\u30fc\u30ad\u30e5\u30fc\u306e\u52b9\u679c\u7684\u306a\u6d3b\u7528\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-11\">\u30b7\u30b9\u30c6\u30e0\u30ea\u30bd\u30fc\u30b9\u306e\u6700\u9069\u5316\u624b\u6cd5<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-12\">RabbitMQ\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5bfe\u7b56\uff1a\u5b89\u5168\u306a\u5b9f\u88c5\u306e\u305f\u3081\u306b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-13\">\u8a8d\u8a3c\u30fb\u8a31\u53ef\u306e\u9069\u5207\u306a\u8a2d\u5b9a\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-14\">SSL\/TLS \u901a\u4fe1\u306e\u5b9f\u88c5\u624b\u9806<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-15\">\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30c1\u30a7\u30c3\u30af\u30ea\u30b9\u30c8\u306e\u6d3b\u7528<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-16\">RabbitMQ \u306e\u6d3b\u7528\u4f8b\uff1a\u5b9f\u8df5\u7684\u306a\u5b9f\u88c5\u30d1\u30bf\u30fc\u30f3<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-17\">\u30d0\u30c3\u30c1\u51e6\u7406\u306e\u975e\u540c\u671f\u5316\u306b\u3088\u308b\u51e6\u7406\u6642\u9593\u306e\u77ed\u7e2e<\/a>      <\/li>      <li>        <a href=\"#i-18\">\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u9593\u306e\u52b9\u7387\u7684\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u30f3\u30b0<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-19\">\u7dca\u6025\u901a\u77e5\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9\u4f8b<\/a>      <\/li>    <\/ul>  <\/li><\/ul>\n      <a href=\"#\" class=\"sgb-toc-button js-toc-button\" rel=\"nofollow\" data-open-dialog=\"true\"><i class=\"fa fa-list\"><\/i><span class=\"sgb-toc-button__text\">\u76ee\u6b21\u3078<\/span><\/a>\n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">RabbitMQ \u3068\u306f\uff1aPHP \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u3082\u305f\u3089\u3059 5 \u3064\u306e\u9769\u65b0<\/h2>\n\n\n\n<p>RabbitMQ\u306f\u3001\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u30d6\u30ed\u30fc\u30ab\u30fc\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3067\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u9593\u306e\u52b9\u7387\u7684\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u30f3\u30b0\u57fa\u76e4\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002ERLANG\u3067\u5b9f\u88c5\u3055\u308c\u305f\u5805\u7262\u306a\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u3068\u3057\u3066\u3001\u591a\u304f\u306e\u4f01\u696d\u3067\u306e\u5b9f\u7e3e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">\u975e\u540c\u671f\u51e6\u7406\u306b\u3088\u308b\u5727\u5012\u7684\u306a\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a<\/h3>\n\n\n\n<p>RabbitMQ\u3092PHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u5c0e\u5165\u3059\u308b\u3053\u3068\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6539\u5584\u304c\u5b9f\u73fe\u3067\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30ea\u30af\u30a8\u30b9\u30c8\u51e6\u7406\u306e\u9ad8\u901f\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u91cd\u3044\u51e6\u7406\u3092\u30ad\u30e5\u30fc\u306b\u59d4\u8b72\u3059\u308b\u3053\u3068\u3067\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u30bf\u30a4\u30e0\u3092\u5927\u5e45\u306b\u77ed\u7e2e<\/li>\n\n\n\n<li>\u30e6\u30fc\u30b6\u30fc\u4f53\u9a13\u306e\u5411\u4e0a\u306b\u3064\u306a\u304c\u308b\u5373\u6642\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u5b9f\u73fe<\/li>\n\n\n\n<li>\u30b5\u30fc\u30d0\u30fc\u30ea\u30bd\u30fc\u30b9\u306e\u52b9\u7387\u7684\u306a\u5229\u7528<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u51e6\u7406\u306e\u30d0\u30c3\u30d5\u30a1\u30ea\u30f3\u30b0\u52b9\u679c<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7a81\u767a\u7684\u306a\u8ca0\u8377\u5897\u5927\u6642\u306b\u3082\u30b7\u30b9\u30c6\u30e0\u306e\u5b89\u5b9a\u6027\u3092\u7dad\u6301<\/li>\n\n\n\n<li>\u30d4\u30fc\u30af\u6642\u306e\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0\u30b3\u30b9\u30c8\u3092\u6700\u9069\u5316<\/li>\n\n\n\n<li>\u30b7\u30b9\u30c6\u30e0\u5168\u4f53\u306e\u30b9\u30eb\u30fc\u30d7\u30c3\u30c8\u5411\u4e0a<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">\u30b9\u30b1\u30fc\u30e9\u30d6\u30eb\u306a\u30b7\u30b9\u30c6\u30e0\u8a2d\u8a08\u306e\u5b9f\u73fe<\/h3>\n\n\n\n<p>RabbitMQ\u306f\u3001\u4ee5\u4e0b\u306e\u7279\u5fb4\u306b\u3088\u308a\u3001\u30b9\u30b1\u30fc\u30e9\u30d6\u30eb\u306a\u30b7\u30b9\u30c6\u30e0\u8a2d\u8a08\u3092\u53ef\u80fd\u306b\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30d7\u30ed\u30c7\u30e5\u30fc\u30b5\u30fc\u5074\u306e\u30b3\u30fc\u30c9\u4f8b\n$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest');\n$channel = $connection-&gt;channel();\n\n\/\/ \u30ad\u30e5\u30fc\u306e\u5ba3\u8a00\n$channel-&gt;queue_declare('task_queue', false, true, false, false);\n\n\/\/ \u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u6c38\u7d9a\u5316\u8a2d\u5b9a\n$msg = new AMQPMessage(\n    $data,\n    array('delivery_mode' =&gt; AMQPMessage::DELIVERY_MODE_PERSISTENT)\n);\n\n\/\/ \u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u9001\u4fe1\n$channel-&gt;basic_publish($msg, '', 'task_queue');<\/pre>\n\n\n\n<p>\u7279\u5fb4\u7684\u306a\u6a5f\u80fd\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30ad\u30e5\u30fc\u306e\u30af\u30e9\u30b9\u30bf\u30ea\u30f3\u30b0<\/li>\n\n\n\n<li>\u9ad8\u53ef\u7528\u6027\u306e\u5b9f\u73fe<\/li>\n\n\n\n<li>\u67d4\u8edf\u306a\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u8ca0\u8377\u5206\u6563\u6a5f\u80fd<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-3\">\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u3078\u306e\u6700\u9069\u5316<\/h3>\n\n\n\n<p>\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u306b\u304a\u3044\u3066\u3001RabbitMQ\u306f\u4ee5\u4e0b\u306e\u5f79\u5272\u3092\u679c\u305f\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30b5\u30fc\u30d3\u30b9\u9593\u901a\u4fe1\u306e\u4fe1\u983c\u6027\u78ba\u4fdd<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u78ba\u5b9f\u306a\u914d\u4fe1<\/li>\n\n\n\n<li>\u969c\u5bb3\u6642\u306e\u30ea\u30ab\u30d0\u30ea\u6a5f\u80fd<\/li>\n\n\n\n<li>\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u7ba1\u7406<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30b7\u30b9\u30c6\u30e0\u9593\u306e\u758e\u7d50\u5408\u5316<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30b5\u30fc\u30d3\u30b9\u9593\u306e\u4f9d\u5b58\u95a2\u4fc2\u306e\u6700\u5c0f\u5316<\/li>\n\n\n\n<li>\u500b\u5225\u30c7\u30d7\u30ed\u30a4\u306e\u5b9f\u73fe<\/li>\n\n\n\n<li>\u67d4\u8edf\u306a\u30b7\u30b9\u30c6\u30e0\u62e1\u5f35<\/li>\n<\/ul>\n\n\n\n<p>\u5b9f\u88c5\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30b3\u30f3\u30b7\u30e5\u30fc\u30de\u30fc\u5074\u306e\u30b3\u30fc\u30c9\u4f8b\n$callback = function ($msg) {\n    \/\/ \u30e1\u30c3\u30bb\u30fc\u30b8\u51e6\u7406\u30ed\u30b8\u30c3\u30af\n    $result = process_message($msg-&gt;body);\n\n    if ($result) {\n        \/\/ \u6b63\u5e38\u51e6\u7406\u5b8c\u4e86\u6642\n        $msg-&gt;delivery_info['channel']-&gt;basic_ack($msg-&gt;delivery_info['delivery_tag']);\n    } else {\n        \/\/ \u30a8\u30e9\u30fc\u6642\u306e\u518d\u30ad\u30e5\u30fc\n        $msg-&gt;delivery_info['channel']-&gt;basic_nack($msg-&gt;delivery_info['delivery_tag'], false, true);\n    }\n};\n\n\/\/ QoS\u306e\u8a2d\u5b9a\n$channel-&gt;basic_qos(null, 1, null);\n\n\/\/ \u30b3\u30f3\u30b7\u30e5\u30fc\u30de\u30fc\u306e\u958b\u59cb\n$channel-&gt;basic_consume('task_queue', '', false, false, false, false, $callback);<\/pre>\n\n\n\n<p>RabbitMQ\u306e\u5c0e\u5165\u306b\u3088\u308a\u3001PHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u4ee5\u4e0b\u306e\u9769\u65b0\u7684\u306a\u6a5f\u80fd\u3092\u7372\u5f97\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u512a\u5148\u9806\u4f4d\u4ed8\u3051<\/li>\n\n\n\n<li>\u67d4\u8edf\u306a\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u30d1\u30bf\u30fc\u30f3<\/li>\n\n\n\n<li>\u30d1\u30d6\u30ea\u30c3\u30b7\u30e5\/\u30b5\u30d6\u30b9\u30af\u30e9\u30a4\u30d6\u30e2\u30c7\u30eb\u306e\u5b9f\u88c5<\/li>\n\n\n\n<li>\u30c7\u30c3\u30c9\u30ec\u30bf\u30fc\u30ad\u30e5\u30fc\u306b\u3088\u308b\u7570\u5e38\u51e6\u7406<\/li>\n\n\n\n<li>TTL\uff08Time-To-Live\uff09\u306b\u3088\u308b\u30e1\u30c3\u30bb\u30fc\u30b8\u5236\u5fa1<\/li>\n<\/ol>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u6a5f\u80fd\u306b\u3088\u308a\u3001\u73fe\u4ee3\u306eWeb\u958b\u767a\u306b\u6c42\u3081\u3089\u308c\u308b\u9ad8\u5ea6\u306a\u8981\u4ef6\u306b\u5bfe\u5fdc\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-4\">PHP \u3067\u306e RabbitMQ \u5b9f\u88c5\u624b\u9806\uff1a\u78ba\u5b9f\u306a\u5c0e\u5165\u306e\u305f\u3081\u306b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-5\">Composer \u3067\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u624b\u9806<\/h3>\n\n\n\n<p>RabbitMQ\u3092PHP\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u5c0e\u5165\u3059\u308b\u6700\u521d\u306e\u30b9\u30c6\u30c3\u30d7\u3068\u3057\u3066\u3001\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Composer\u306e\u4f9d\u5b58\u95a2\u4fc2\u8ffd\u52a0<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># php-amqplib \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\ncomposer require php-amqplib\/php-amqplib\n\n# RabbitMQ \u30b5\u30fc\u30d0\u30fc\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\uff08Ubuntu \u306e\u5834\u5408\uff09\nsudo apt-get install rabbitmq-server\n\n# RabbitMQ \u306e\u7ba1\u7406\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u6709\u52b9\u5316\nsudo rabbitmq-plugins enable rabbitmq_management<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u4f9d\u5b58\u95a2\u4fc2\u78ba\u8a8d<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n    \"require\": {\n        \"php\": \"&gt;=7.4\",\n        \"php-amqplib\/php-amqplib\": \"^3.5\"\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-6\">\u57fa\u672c\u7684\u306a\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\u65b9\u6cd5<\/h3>\n\n\n\n<p>RabbitMQ\u306e\u8a2d\u5b9a\u306f\u3001\u4ee5\u4e0b\u306e\u624b\u9806\u3067\u884c\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u63a5\u7d9a\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ config\/rabbitmq.php\nreturn [\n    'host' =&gt; env('RABBITMQ_HOST', 'localhost'),\n    'port' =&gt; env('RABBITMQ_PORT', 5672),\n    'user' =&gt; env('RABBITMQ_USER', 'guest'),\n    'password' =&gt; env('RABBITMQ_PASSWORD', 'guest'),\n    'vhost' =&gt; env('RABBITMQ_VHOST', '\/'),\n    'exchange' =&gt; [\n        'name' =&gt; 'my_exchange',\n        'type' =&gt; 'direct',\n        'passive' =&gt; false,\n        'durable' =&gt; true,\n        'auto_delete' =&gt; false,\n    ],\n    'queue' =&gt; [\n        'name' =&gt; 'my_queue',\n        'passive' =&gt; false,\n        'durable' =&gt; true,\n        'exclusive' =&gt; false,\n        'auto_delete' =&gt; false,\n    ]\n];<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u63a5\u7d9a\u30af\u30e9\u30b9\u306e\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ src\/RabbitMQ\/Connection.php\nclass RabbitMQConnection\n{\n    private $connection;\n    private $channel;\n    private $config;\n\n    public function __construct(array $config)\n    {\n        $this-&gt;config = $config;\n        $this-&gt;connect();\n    }\n\n    private function connect()\n    {\n        $this-&gt;connection = new AMQPStreamConnection(\n            $this-&gt;config['host'],\n            $this-&gt;config['port'],\n            $this-&gt;config['user'],\n            $this-&gt;config['password'],\n            $this-&gt;config['vhost']\n        );\n\n        $this-&gt;channel = $this-&gt;connection-&gt;channel();\n\n        \/\/ \u30a8\u30af\u30b9\u30c1\u30a7\u30f3\u30b8\u3068\u30ad\u30e5\u30fc\u306e\u5ba3\u8a00\n        $this-&gt;declareExchange();\n        $this-&gt;declareQueue();\n    }\n\n    \/\/ \u305d\u306e\u4ed6\u306e\u30e1\u30bd\u30c3\u30c9...\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-7\">\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u9001\u4fe1\u53d7\u4fe1\u30b3\u30fc\u30c9\u306e\u5b9f\u88c5\u4f8b<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1\uff08Producer\uff09\u306e\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class MessageProducer\n{\n    private $channel;\n    private $exchange;\n\n    public function __construct(AMQPChannel $channel, string $exchange)\n    {\n        $this-&gt;channel = $channel;\n        $this-&gt;exchange = $exchange;\n    }\n\n    public function publish(string $message, string $routingKey = '')\n    {\n        \/\/ \u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u6c38\u7d9a\u5316\u8a2d\u5b9a\n        $properties = [\n            'delivery_mode' =&gt; AMQPMessage::DELIVERY_MODE_PERSISTENT,\n            'content_type' =&gt; 'application\/json',\n            'timestamp' =&gt; time()\n        ];\n\n        $msg = new AMQPMessage(json_encode($message), $properties);\n\n        try {\n            $this-&gt;channel-&gt;basic_publish(\n                $msg,\n                $this-&gt;exchange,\n                $routingKey\n            );\n            return true;\n        } catch (Exception $e) {\n            \/\/ \u30a8\u30e9\u30fc\u30ed\u30b0\u306e\u8a18\u9332\n            error_log(\"Message publishing failed: \" . $e-&gt;getMessage());\n            return false;\n        }\n    }\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30e1\u30c3\u30bb\u30fc\u30b8\u53d7\u4fe1\uff08Consumer\uff09\u306e\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class MessageConsumer\n{\n    private $channel;\n    private $queue;\n\n    public function __construct(AMQPChannel $channel, string $queue)\n    {\n        $this-&gt;channel = $channel;\n        $this-&gt;queue = $queue;\n\n        \/\/ QoS\u306e\u8a2d\u5b9a\n        $this-&gt;channel-&gt;basic_qos(null, 1, null);\n    }\n\n    public function consume(callable $callback)\n    {\n        $this-&gt;channel-&gt;basic_consume(\n            $this-&gt;queue,\n            '',     \/\/ consumer tag\n            false,  \/\/ no local\n            false,  \/\/ no ack\n            false,  \/\/ exclusive\n            false,  \/\/ no wait\n            function ($msg) use ($callback) {\n                try {\n                    $data = json_decode($msg-&gt;body, true);\n                    $result = $callback($data);\n\n                    if ($result) {\n                        $msg-&gt;delivery_info['channel']-&gt;basic_ack(\n                            $msg-&gt;delivery_info['delivery_tag']\n                        );\n                    } else {\n                        \/\/ \u51e6\u7406\u5931\u6557\u6642\u306f\u518d\u30ad\u30e5\u30fc\n                        $msg-&gt;delivery_info['channel']-&gt;basic_nack(\n                            $msg-&gt;delivery_info['delivery_tag'],\n                            false,\n                            true\n                        );\n                    }\n                } catch (Exception $e) {\n                    \/\/ \u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n                    error_log(\"Message processing failed: \" . $e-&gt;getMessage());\n                    \/\/ \u91cd\u5927\u306a\u30a8\u30e9\u30fc\u306e\u5834\u5408\u306f\u30c7\u30c3\u30c9\u30ec\u30bf\u30fc\u30ad\u30e5\u30fc\u3078\n                    $msg-&gt;delivery_info['channel']-&gt;basic_reject(\n                        $msg-&gt;delivery_info['delivery_tag'],\n                        false\n                    );\n                }\n            }\n        );\n\n        \/\/ \u30e1\u30c3\u30bb\u30fc\u30b8\u5f85\u3061\u53d7\u3051\u30eb\u30fc\u30d7\u306e\u958b\u59cb\n        while ($this-&gt;channel-&gt;is_consuming()) {\n            $this-&gt;channel-&gt;wait();\n        }\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u306b\u3088\u308a\u3001\u4fe1\u983c\u6027\u306e\u9ad8\u3044\u30e1\u30c3\u30bb\u30fc\u30b8\u30f3\u30b0\u57fa\u76e4\u3092\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u70b9\u306b\u7279\u306b\u6ce8\u610f\u3092\u6255\u3063\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u6c38\u7d9a\u5316\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u5b9f\u88c5<\/li>\n\n\n\n<li>\u518d\u8a66\u884c\u30e1\u30ab\u30cb\u30ba\u30e0\u306e\u5c0e\u5165<\/li>\n\n\n\n<li>\u30c7\u30c3\u30c9\u30ec\u30bf\u30fc\u30ad\u30e5\u30fc\u306e\u6d3b\u7528<\/li>\n\n\n\n<li>QoS\u306b\u3088\u308b\u8ca0\u8377\u5236\u5fa1<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30b3\u30fc\u30c9\u4f8b\u306f\u3001\u672c\u756a\u74b0\u5883\u3067\u306e\u5229\u7528\u3092\u60f3\u5b9a\u3057\u305f\u5b9f\u88c5\u30d1\u30bf\u30fc\u30f3\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-8\">RabbitMQ \u306e\u904b\u7528\u30c6\u30af\u30cb\u30c3\u30af\uff1a\u30c8\u30e9\u30d6\u30eb\u3092\u672a\u7136\u306b\u9632\u3050<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-9\">\u30e1\u30c3\u30bb\u30fc\u30b8\u30ad\u30e5\u30fc\u306e\u76e3\u8996\u65b9\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u7ba1\u7406\u753b\u9762\u3067\u306e\u76e3\u8996\u9805\u76ee<\/strong><\/li>\n<\/ol>\n\n\n\n<p>RabbitMQ Management Plugin\u3092\u6d3b\u7528\u3057\u305f\u4e3b\u8981\u306a\u76e3\u8996\u9805\u76ee\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u7ba1\u7406\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u72b6\u614b\u78ba\u8a8d\nrabbitmq-plugins list\n# \u7ba1\u7406\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u6709\u52b9\u5316\nrabbitmq-plugins enable rabbitmq_management<\/pre>\n\n\n\n<p>\u76e3\u8996\u3059\u3079\u304d\u91cd\u8981\u306a\u6307\u6a19\uff1a<\/p>\n\n\n<div id=\"id-8490e9ae-9299-49e5-bdde-1d9662fdd9e1\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u76e3\u8996\u9805\u76ee<\/th><th>\u63a8\u5968\u95be\u5024<\/th><th>\u76e3\u8996\u306e\u610f\u7fa9<\/th><\/tr><\/thead><tbody><tr><td>\u30ad\u30e5\u30fc\u306e\u9577\u3055<\/td><td>\u51e6\u7406\u901f\u5ea6\u306b\u5fdc\u3058\u3066\u8a2d\u5b9a<\/td><td>\u30d0\u30c3\u30af\u30ed\u30b0\u306e\u691c\u77e5<\/td><\/tr><tr><td>\u672a\u78ba\u8a8d\u30e1\u30c3\u30bb\u30fc\u30b8\u6570<\/td><td>\u901a\u5e38\u6642\u306e3\u500d\u4ee5\u4e0a\u3067\u8b66\u544a<\/td><td>\u51e6\u7406\u306e\u6ede\u7559\u691c\u77e5<\/td><\/tr><tr><td>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf<\/td><td>\u5168\u4f53\u306e40%\u4ee5\u4e0a\u3067\u8b66\u544a<\/td><td>\u30ea\u30bd\u30fc\u30b9\u67af\u6e07\u306e\u4e88\u9632<\/td><\/tr><tr><td>\u30c7\u30a3\u30b9\u30af\u4f7f\u7528\u91cf<\/td><td>80%\u4ee5\u4e0a\u3067\u8b66\u544a<\/td><td>\u30b9\u30c8\u30ec\u30fc\u30b8\u76e3\u8996<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>PHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304b\u3089\u306e\u76e3\u8996\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u76e3\u8996\u7528\u30af\u30e9\u30b9\u306e\u5b9f\u88c5\u4f8b\nclass RabbitMQMonitor\n{\n    private $connection;\n    private $channel;\n\n    public function checkQueueStatus($queueName)\n    {\n        try {\n            \/\/ \u30ad\u30e5\u30fc\u306e\u72b6\u614b\u3092\u53d6\u5f97\n            $status = $this-&gt;channel-&gt;queue_declare(\n                $queueName,\n                true,   \/\/ passive\n                false,\n                false,\n                false\n            );\n\n            return [\n                'messages_count' =&gt; $status[1],\n                'consumers_count' =&gt; $status[2]\n            ];\n        } catch (Exception $e) {\n            error_log(\"Queue status check failed: \" . $e-&gt;getMessage());\n            return false;\n        }\n    }\n\n    public function getQueueMetrics()\n    {\n        \/\/ HTTP API\u3092\u4f7f\u7528\u3057\u3066\u30e1\u30c8\u30ea\u30af\u30b9\u3092\u53d6\u5f97\n        $url = \"http:\/\/localhost:15672\/api\/queues\";\n        $credentials = base64_encode(\"guest:guest\");\n\n        $ch = curl_init();\n        curl_setopt($ch, CURLOPT_URL, $url);\n        curl_setopt($ch, CURLOPT_HTTPHEADER, [\n            \"Authorization: Basic \" . $credentials\n        ]);\n        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n\n        $response = curl_exec($ch);\n        curl_close($ch);\n\n        return json_decode($response, true);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">\u30c7\u30c3\u30c9\u30ec\u30bf\u30fc\u30ad\u30e5\u30fc\u306e\u52b9\u679c\u7684\u306a\u6d3b\u7528\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c7\u30c3\u30c9\u30ec\u30bf\u30fc\u30ad\u30e5\u30fc\u306e\u8a2d\u5b9a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30c7\u30c3\u30c9\u30ec\u30bf\u30fc\u30ad\u30e5\u30fc\u306e\u8a2d\u5b9a\u4f8b\n$channel-&gt;queue_declare(\n    'main_queue',\n    false,\n    true,\n    false,\n    false,\n    false,\n    new AMQPTable([\n        'x-dead-letter-exchange' =&gt; 'dlx',\n        'x-dead-letter-routing-key' =&gt; 'failed_messages',\n        'x-message-ttl' =&gt; 86400000  \/\/ 24\u6642\u9593\n    ])\n);\n\n\/\/ \u30c7\u30c3\u30c9\u30ec\u30bf\u30fc\u30a8\u30af\u30b9\u30c1\u30a7\u30f3\u30b8\u306e\u5ba3\u8a00\n$channel-&gt;exchange_declare(\n    'dlx',\n    'direct',\n    false,\n    true,\n    false\n);\n\n\/\/ \u30c7\u30c3\u30c9\u30ec\u30bf\u30fc\u30ad\u30e5\u30fc\u306e\u5ba3\u8a00\n$channel-&gt;queue_declare(\n    'dead_letter_queue',\n    false,\n    true,\n    false,\n    false\n);\n\n\/\/ \u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u306e\u8a2d\u5b9a\n$channel-&gt;queue_bind(\n    'dead_letter_queue',\n    'dlx',\n    'failed_messages'\n);<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u5931\u6557\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u51e6\u7406\u6226\u7565<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class DeadLetterProcessor\n{\n    private $channel;\n\n    public function processFailedMessages()\n    {\n        $callback = function ($msg) {\n            $headers = $msg-&gt;get('application_headers');\n            $originalRoutingKey = $headers-&gt;get('x-death')[0]['routing-keys'][0];\n\n            try {\n                \/\/ \u5931\u6557\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u89e3\u6790\n                $messageData = json_decode($msg-&gt;body, true);\n\n                \/\/ \u30a8\u30e9\u30fc\u539f\u56e0\u306e\u7279\u5b9a\u3068\u8a18\u9332\n                $this-&gt;logFailure($messageData, $originalRoutingKey);\n\n                \/\/ \u5fc5\u8981\u306b\u5fdc\u3058\u3066\u518d\u51e6\u7406\u30ad\u30e5\u30fc\u3078\u306e\u8ee2\u9001\n                if ($this-&gt;isRetryable($messageData)) {\n                    $this-&gt;requeueMessage($messageData, $originalRoutingKey);\n                }\n\n                \/\/ \u51e6\u7406\u5b8c\u4e86\u306e\u78ba\u8a8d\n                $msg-&gt;ack();\n\n            } catch (Exception $e) {\n                \/\/ \u91cd\u5927\u306a\u30a8\u30e9\u30fc\u306e\u5834\u5408\u306f\u6c38\u7d9a\u5316\n                $this-&gt;persistFatalError($messageData, $e);\n                $msg-&gt;ack();\n            }\n        };\n\n        \/\/ \u30c7\u30c3\u30c9\u30ec\u30bf\u30fc\u30ad\u30e5\u30fc\u306e\u76e3\u8996\u958b\u59cb\n        $this-&gt;channel-&gt;basic_consume(\n            'dead_letter_queue',\n            '',\n            false,\n            false,\n            false,\n            false,\n            $callback\n        );\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-11\">\u30b7\u30b9\u30c6\u30e0\u30ea\u30bd\u30fc\u30b9\u306e\u6700\u9069\u5316\u624b\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30e1\u30e2\u30ea\u7ba1\u7406\u306e\u6700\u9069\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u76e3\u8996\u3059\u308b\u30af\u30e9\u30b9\nclass MemoryOptimizer\n{\n    private $maxMemory;\n    private $warningThreshold;\n\n    public function __construct($maxMemoryMB = 1024, $warningThreshold = 0.8)\n    {\n        $this-&gt;maxMemory = $maxMemoryMB * 1024 * 1024;\n        $this-&gt;warningThreshold = $warningThreshold;\n    }\n\n    public function checkMemoryUsage()\n    {\n        $currentMemory = memory_get_usage(true);\n        if ($currentMemory &gt; ($this-&gt;maxMemory * $this-&gt;warningThreshold)) {\n            \/\/ \u8b66\u544a\u901a\u77e5\u306e\u9001\u4fe1\n            $this-&gt;sendAlert([\n                'current_memory' =&gt; $currentMemory,\n                'max_memory' =&gt; $this-&gt;maxMemory,\n                'usage_percentage' =&gt; ($currentMemory \/ $this-&gt;maxMemory) * 100\n            ]);\n        }\n    }\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u7ba1\u7406\u306e\u6700\u9069\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u30d7\u30fc\u30eb\u306e\u5b9f\u88c5\u4f8b\nclass ConnectionPool\n{\n    private static $instances = [];\n    private static $maxConnections = 5;\n\n    public static function getInstance($config)\n    {\n        $key = md5(serialize($config));\n\n        if (!isset(self::$instances[$key])) {\n            if (count(self::$instances) &gt;= self::$maxConnections) {\n                throw new Exception('Maximum connection limit reached');\n            }\n\n            self::$instances[$key] = new RabbitMQConnection($config);\n        }\n\n        return self::$instances[$key];\n    }\n\n    public static function releaseConnection($key)\n    {\n        if (isset(self::$instances[$key])) {\n            self::$instances[$key]-&gt;close();\n            unset(self::$instances[$key]);\n        }\n    }\n}<\/pre>\n\n\n\n<p>\u904b\u7528\u4e0a\u306e\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5b9a\u671f\u7684\u306a\u30e1\u30c8\u30ea\u30af\u30b9\u53ce\u96c6\u3068\u5206\u6790<\/li>\n\n\n\n<li>\u30a2\u30e9\u30fc\u30c8\u95be\u5024\u306e\u9069\u5207\u306a\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u30d1\u30bf\u30fc\u30f3\u306e\u5206\u985e\u3068\u5bfe\u5fdc\u7b56\u306e\u6587\u66f8\u5316<\/li>\n\n\n\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u306e\u5b9a\u671f\u7684\u306a\u5b9f\u65bd<\/li>\n\n\n\n<li>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3068\u5fa9\u65e7\u624b\u9806\u306e\u6574\u5099<\/li>\n<\/ol>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u904b\u7528\u30c6\u30af\u30cb\u30c3\u30af\u3092\u9069\u5207\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3067\u3001RabbitMQ\u30b7\u30b9\u30c6\u30e0\u306e\u5b89\u5b9a\u6027\u3068\u4fe1\u983c\u6027\u3092\u78ba\u4fdd\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-12\">RabbitMQ\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5bfe\u7b56\uff1a\u5b89\u5168\u306a\u5b9f\u88c5\u306e\u305f\u3081\u306b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-13\">\u8a8d\u8a3c\u30fb\u8a31\u53ef\u306e\u9069\u5207\u306a\u8a2d\u5b9a\u65b9\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30e6\u30fc\u30b6\u30fc\u7ba1\u7406\u3068\u30a2\u30af\u30bb\u30b9\u5236\u5fa1<\/strong><\/li>\n<\/ol>\n\n\n\n<p>RabbitMQ\u3067\u306e\u6a29\u9650\u7ba1\u7406\u306e\u57fa\u672c\u8a2d\u5b9a\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u65b0\u898f\u30e6\u30fc\u30b6\u30fc\u306e\u4f5c\u6210\nrabbitmqctl add_user app_user strong_password\n\n# \u30bf\u30b0\u306e\u8a2d\u5b9a\uff08\u6a29\u9650\u306e\u4ed8\u4e0e\uff09\nrabbitmqctl set_user_tags app_user monitoring\n\n# vhost\u3067\u306e\u6a29\u9650\u8a2d\u5b9a\nrabbitmqctl set_permissions -p \/ app_user \"^app.*\" \"^app.*\" \"^app.*\"<\/pre>\n\n\n\n<p>PHP\u3067\u306e\u5b89\u5168\u306a\u63a5\u7d9a\u5b9f\u88c5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class SecureRabbitMQConnection\n{\n    private $connection;\n    private $credentials;\n\n    public function __construct(array $credentials)\n    {\n        $this-&gt;validateCredentials($credentials);\n        $this-&gt;credentials = $credentials;\n    }\n\n    private function validateCredentials(array $credentials)\n    {\n        $required = ['host', 'port', 'user', 'password', 'vhost'];\n        foreach ($required as $field) {\n            if (!isset($credentials[$field])) {\n                throw new InvalidArgumentException(\n                    \"Missing required credential: {$field}\"\n                );\n            }\n        }\n    }\n\n    public function connect()\n    {\n        try {\n            $this-&gt;connection = new AMQPStreamConnection(\n                $this-&gt;credentials['host'],\n                $this-&gt;credentials['port'],\n                $this-&gt;credentials['user'],\n                $this-&gt;credentials['password'],\n                $this-&gt;credentials['vhost'],\n                false,                          \/\/ insist\n                'AMQPLAIN',                     \/\/ login method\n                null,                           \/\/ login response\n                'en_US',                        \/\/ locale\n                3.0,                            \/\/ connection timeout\n                3.0,                            \/\/ read write timeout\n                null,                           \/\/ context\n                false,                          \/\/ keepalive\n                0                               \/\/ heartbeat\n            );\n\n            return $this-&gt;connection;\n        } catch (Exception $e) {\n            throw new ConnectionException(\n                \"Failed to establish secure connection: \" . $e-&gt;getMessage()\n            );\n        }\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-14\">SSL\/TLS \u901a\u4fe1\u306e\u5b9f\u88c5\u624b\u9806<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>SSL\u8a3c\u660e\u66f8\u306e\u8a2d\u5b9a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class SSLConfiguration\n{\n    public static function getSSLOptions()\n    {\n        return [\n            'ssl_options' =&gt; [\n                'verify_peer' =&gt; true,\n                'verify_peer_name' =&gt; true,\n                'cafile' =&gt; '\/path\/to\/ca_certificate.pem',\n                'local_cert' =&gt; '\/path\/to\/client_certificate.pem',\n                'local_pk' =&gt; '\/path\/to\/client_key.pem',\n                'passphrase' =&gt; 'your_passphrase',\n                'verify_depth' =&gt; 5,\n                'ciphers' =&gt; 'HIGH:!ADH:!MD5'\n            ]\n        ];\n    }\n}\n\n\/\/ SSL\u63a5\u7d9a\u306e\u5b9f\u88c5\u4f8b\nclass SecureSSLConnection extends SecureRabbitMQConnection\n{\n    public function connect()\n    {\n        $sslOptions = SSLConfiguration::getSSLOptions();\n\n        try {\n            $this-&gt;connection = new AMQPSSLConnection(\n                $this-&gt;credentials['host'],\n                $this-&gt;credentials['port'],\n                $this-&gt;credentials['user'],\n                $this-&gt;credentials['password'],\n                $this-&gt;credentials['vhost'],\n                $sslOptions\n            );\n\n            return $this-&gt;connection;\n        } catch (Exception $e) {\n            throw new SSLConnectionException(\n                \"Failed to establish SSL connection: \" . $e-&gt;getMessage()\n            );\n        }\n    }\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30bb\u30ad\u30e5\u30a2\u306a\u901a\u4fe1\u306e\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u6697\u53f7\u5316\u51e6\u7406\nclass MessageEncryption\n{\n    private $encryptionKey;\n\n    public function __construct($key)\n    {\n        $this-&gt;encryptionKey = $key;\n    }\n\n    public function encrypt($message)\n    {\n        $iv = random_bytes(16);\n        $encrypted = openssl_encrypt(\n            json_encode($message),\n            'AES-256-CBC',\n            $this-&gt;encryptionKey,\n            0,\n            $iv\n        );\n\n        return base64_encode($iv . $encrypted);\n    }\n\n    public function decrypt($encryptedMessage)\n    {\n        $data = base64_decode($encryptedMessage);\n        $iv = substr($data, 0, 16);\n        $encrypted = substr($data, 16);\n\n        $decrypted = openssl_decrypt(\n            $encrypted,\n            'AES-256-CBC',\n            $this-&gt;encryptionKey,\n            0,\n            $iv\n        );\n\n        return json_decode($decrypted, true);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-15\">\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30c1\u30a7\u30c3\u30af\u30ea\u30b9\u30c8\u306e\u6d3b\u7528<\/h3>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30c1\u30a7\u30c3\u30af\u30ea\u30b9\u30c8\u3092\u5b9a\u671f\u7684\u306b\u78ba\u8a8d\u3059\u308b\u3053\u3068\u3092\u304a\u52e7\u3081\u3057\u307e\u3059\uff1a<\/p>\n\n\n<div id=\"id-bee48a05-d6d0-4255-82c6-23d6d92d1a3f\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30c1\u30a7\u30c3\u30af\u9805\u76ee<\/th><th>\u91cd\u8981\u5ea6<\/th><th>\u78ba\u8a8d\u983b\u5ea6<\/th><th>\u5bfe\u5fdc\u65b9\u6cd5<\/th><\/tr><\/thead><tbody><tr><td>\u30d1\u30b9\u30ef\u30fc\u30c9\u5f37\u5ea6<\/td><td>\u9ad8<\/td><td>\u6708\u6b21<\/td><td>\u6700\u4f4e16\u6587\u5b57\u3001\u7279\u6b8a\u6587\u5b57\u3092\u542b\u3080<\/td><\/tr><tr><td>SSL\/TLS\u8a2d\u5b9a<\/td><td>\u9ad8<\/td><td>\u6708\u6b21<\/td><td>\u8a3c\u660e\u66f8\u306e\u6709\u52b9\u671f\u9650\u78ba\u8a8d<\/td><\/tr><tr><td>\u30a2\u30af\u30bb\u30b9\u6a29\u9650<\/td><td>\u9ad8<\/td><td>\u9031\u6b21<\/td><td>\u6700\u5c0f\u6a29\u9650\u306e\u539f\u5247\u306b\u57fa\u3065\u304f\u898b\u76f4\u3057<\/td><\/tr><tr><td>\u30ed\u30b0\u76e3\u67fb<\/td><td>\u4e2d<\/td><td>\u65e5\u6b21<\/td><td>\u7570\u5e38\u30a2\u30af\u30bb\u30b9\u306e\u691c\u77e5<\/td><\/tr><tr><td>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u5206\u96e2<\/td><td>\u9ad8<\/td><td>\u6708\u6b21<\/td><td>VLAN\u8a2d\u5b9a\u306e\u78ba\u8a8d<\/td><\/tr><tr><td>\u6697\u53f7\u5316\u8a2d\u5b9a<\/td><td>\u9ad8<\/td><td>\u6708\u6b21<\/td><td>\u63a8\u5968\u6697\u53f7\u30b9\u30a4\u30fc\u30c8\u306e\u4f7f\u7528\u78ba\u8a8d<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<p>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5b9f\u88c5\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u8a8d\u8a3c\u3068\u30a2\u30af\u30bb\u30b9\u5236\u5fa1<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5f37\u529b\u306a\u30d1\u30b9\u30ef\u30fc\u30c9\u30dd\u30ea\u30b7\u30fc\u306e\u9069\u7528<\/li>\n\n\n\n<li>\u9069\u5207\u306aVHost\u5206\u96e2<\/li>\n\n\n\n<li>\u6700\u5c0f\u6a29\u9650\u306e\u539f\u5247\u306e\u5fb9\u5e95<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u901a\u4fe1\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SSL\/TLS 1.3\u306e\u4f7f\u7528<\/li>\n\n\n\n<li>\u8a3c\u660e\u66f8\u306e\u9069\u5207\u306a\u7ba1\u7406<\/li>\n\n\n\n<li>\u5b89\u5168\u306a\u6697\u53f7\u30b9\u30a4\u30fc\u30c8\u306e\u9078\u629e<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u904b\u7528\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5b9a\u671f\u7684\u306a\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u76e3\u67fb<\/li>\n\n\n\n<li>\u30a4\u30f3\u30b7\u30c7\u30f3\u30c8\u5bfe\u5fdc\u624b\u9806\u306e\u6574\u5099<\/li>\n\n\n\n<li>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30d1\u30c3\u30c1\u306e\u9069\u7528\u7ba1\u7406<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5bfe\u7b56\u3092\u9069\u5207\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3067\u3001RabbitMQ\u30b7\u30b9\u30c6\u30e0\u306e\u5b89\u5168\u6027\u3092\u78ba\u4fdd\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-16\">RabbitMQ \u306e\u6d3b\u7528\u4f8b\uff1a\u5b9f\u8df5\u7684\u306a\u5b9f\u88c5\u30d1\u30bf\u30fc\u30f3<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-17\">\u30d0\u30c3\u30c1\u51e6\u7406\u306e\u975e\u540c\u671f\u5316\u306b\u3088\u308b\u51e6\u7406\u6642\u9593\u306e\u77ed\u7e2e<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5927\u91cf\u30c7\u30fc\u30bf\u51e6\u7406\u306e\u975e\u540c\u671f\u5316\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class BatchProcessor\n{\n    private $channel;\n    private $queueName = 'batch_processing';\n\n    public function __construct(AMQPChannel $channel)\n    {\n        $this-&gt;channel = $channel;\n        $this-&gt;setupQueue();\n    }\n\n    private function setupQueue()\n    {\n        $this-&gt;channel-&gt;queue_declare(\n            $this-&gt;queueName,\n            false,\n            true,\n            false,\n            false,\n            false,\n            new AMQPTable([\n                'x-max-priority' =&gt; 10,\n                'x-message-ttl' =&gt; 3600000  \/\/ 1\u6642\u9593\n            ])\n        );\n    }\n\n    public function enqueueBatchJob(array $data, int $priority = 1)\n    {\n        $message = new AMQPMessage(\n            json_encode($data),\n            [\n                'delivery_mode' =&gt; AMQPMessage::DELIVERY_MODE_PERSISTENT,\n                'priority' =&gt; $priority,\n                'timestamp' =&gt; time()\n            ]\n        );\n\n        $this-&gt;channel-&gt;basic_publish($message, '', $this-&gt;queueName);\n\n        return [\n            'job_id' =&gt; uniqid('batch_', true),\n            'queued_at' =&gt; date('Y-m-d H:i:s'),\n            'priority' =&gt; $priority\n        ];\n    }\n\n    public function processBatchJobs(callable $processor)\n    {\n        $callback = function ($msg) use ($processor) {\n            $data = json_decode($msg-&gt;body, true);\n\n            try {\n                \/\/ \u51e6\u7406\u306e\u9032\u6357\u72b6\u6cc1\u3092\u8a18\u9332\n                $this-&gt;updateProgress($data['job_id'], 'processing');\n\n                \/\/ \u30d0\u30c3\u30c1\u51e6\u7406\u306e\u5b9f\u884c\n                $result = $processor($data);\n\n                \/\/ \u51e6\u7406\u5b8c\u4e86\u3092\u8a18\u9332\n                $this-&gt;updateProgress($data['job_id'], 'completed', $result);\n\n                $msg-&gt;delivery_info['channel']-&gt;basic_ack(\n                    $msg-&gt;delivery_info['delivery_tag']\n                );\n            } catch (Exception $e) {\n                \/\/ \u30a8\u30e9\u30fc\u60c5\u5831\u3092\u8a18\u9332\n                $this-&gt;updateProgress($data['job_id'], 'failed', null, $e-&gt;getMessage());\n\n                \/\/ \u518d\u8a66\u884c\u304c\u5fc5\u8981\u306a\u5834\u5408\n                if ($this-&gt;shouldRetry($data)) {\n                    $msg-&gt;delivery_info['channel']-&gt;basic_nack(\n                        $msg-&gt;delivery_info['delivery_tag'],\n                        false,\n                        true\n                    );\n                } else {\n                    $msg-&gt;delivery_info['channel']-&gt;basic_ack(\n                        $msg-&gt;delivery_info['delivery_tag']\n                    );\n                }\n            }\n        };\n\n        $this-&gt;channel-&gt;basic_qos(null, 1, null);\n        $this-&gt;channel-&gt;basic_consume(\n            $this-&gt;queueName,\n            '',\n            false,\n            false,\n            false,\n            false,\n            $callback\n        );\n\n        while ($this-&gt;channel-&gt;is_consuming()) {\n            $this-&gt;channel-&gt;wait();\n        }\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-18\">\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u9593\u306e\u52b9\u7387\u7684\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u30f3\u30b0<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30a4\u30d9\u30f3\u30c8\u99c6\u52d5\u578b\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u306e\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class MicroserviceMessaging\n{\n    private $channel;\n    private $exchangeName = 'microservice_events';\n\n    public function __construct(AMQPChannel $channel)\n    {\n        $this-&gt;channel = $channel;\n        $this-&gt;setupExchange();\n    }\n\n    private function setupExchange()\n    {\n        $this-&gt;channel-&gt;exchange_declare(\n            $this-&gt;exchangeName,\n            'topic',\n            false,\n            true,\n            false\n        );\n    }\n\n    public function publishEvent(string $routingKey, array $eventData)\n    {\n        $message = new AMQPMessage(\n            json_encode([\n                'event_id' =&gt; uniqid('evt_', true),\n                'timestamp' =&gt; microtime(true),\n                'data' =&gt; $eventData\n            ]),\n            [\n                'delivery_mode' =&gt; AMQPMessage::DELIVERY_MODE_PERSISTENT,\n                'content_type' =&gt; 'application\/json'\n            ]\n        );\n\n        $this-&gt;channel-&gt;basic_publish(\n            $message,\n            $this-&gt;exchangeName,\n            $routingKey\n        );\n    }\n\n    public function subscribeToEvents(array $routingPatterns, callable $handler)\n    {\n        $queueName = 'service_' . uniqid();\n\n        \/\/ \u30ad\u30e5\u30fc\u306e\u5ba3\u8a00\n        $this-&gt;channel-&gt;queue_declare(\n            $queueName,\n            false,\n            true,\n            true,\n            false\n        );\n\n        \/\/ \u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u30d1\u30bf\u30fc\u30f3\u306e\u8a2d\u5b9a\n        foreach ($routingPatterns as $pattern) {\n            $this-&gt;channel-&gt;queue_bind(\n                $queueName,\n                $this-&gt;exchangeName,\n                $pattern\n            );\n        }\n\n        \/\/ \u30e1\u30c3\u30bb\u30fc\u30b8\u51e6\u7406\n        $this-&gt;channel-&gt;basic_consume(\n            $queueName,\n            '',\n            false,\n            false,\n            false,\n            false,\n            function ($msg) use ($handler) {\n                try {\n                    $event = json_decode($msg-&gt;body, true);\n                    $handler($event);\n                    $msg-&gt;delivery_info['channel']-&gt;basic_ack(\n                        $msg-&gt;delivery_info['delivery_tag']\n                    );\n                } catch (Exception $e) {\n                    \/\/ \u30a8\u30e9\u30fc\u30ed\u30b0\u306e\u8a18\u9332\n                    error_log(\"Event processing error: \" . $e-&gt;getMessage());\n                    \/\/ \u91cd\u5927\u306a\u30a8\u30e9\u30fc\u306e\u5834\u5408\u306f\u518d\u30ad\u30e5\u30fc\u3057\u306a\u3044\n                    $msg-&gt;delivery_info['channel']-&gt;basic_reject(\n                        $msg-&gt;delivery_info['delivery_tag'],\n                        false\n                    );\n                }\n            }\n        );\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-19\">\u7dca\u6025\u901a\u77e5\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9\u4f8b<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u512a\u5148\u5ea6\u4ed8\u304d\u30e1\u30c3\u30bb\u30fc\u30b8\u30f3\u30b0\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class EmergencyNotificationSystem\n{\n    private $channel;\n    private $exchange = 'emergency_notifications';\n\n    public function __construct(AMQPChannel $channel)\n    {\n        $this-&gt;channel = $channel;\n        $this-&gt;setupInfrastructure();\n    }\n\n    private function setupInfrastructure()\n    {\n        \/\/ Fanout\u30a8\u30af\u30b9\u30c1\u30a7\u30f3\u30b8\u306e\u8a2d\u5b9a\n        $this-&gt;channel-&gt;exchange_declare(\n            $this-&gt;exchange,\n            'fanout',\n            false,\n            true,\n            false\n        );\n\n        \/\/ \u512a\u5148\u5ea6\u4ed8\u304d\u30ad\u30e5\u30fc\u306e\u8a2d\u5b9a\n        $this-&gt;channel-&gt;queue_declare(\n            'emergency_queue',\n            false,\n            true,\n            false,\n            false,\n            false,\n            new AMQPTable([\n                'x-max-priority' =&gt; 10,\n                'x-message-ttl' =&gt; 300000  \/\/ 5\u5206\n            ])\n        );\n    }\n\n    public function broadcastEmergencyMessage(\n        string $message,\n        int $priority,\n        array $recipients\n    ) {\n        $notification = [\n            'message' =&gt; $message,\n            'recipients' =&gt; $recipients,\n            'timestamp' =&gt; microtime(true),\n            'notification_id' =&gt; uniqid('emg_', true)\n        ];\n\n        $msg = new AMQPMessage(\n            json_encode($notification),\n            [\n                'delivery_mode' =&gt; AMQPMessage::DELIVERY_MODE_PERSISTENT,\n                'priority' =&gt; $priority,\n                'expiration' =&gt; '300000'  \/\/ 5\u5206\n            ]\n        );\n\n        $this-&gt;channel-&gt;basic_publish($msg, $this-&gt;exchange);\n\n        return $notification['notification_id'];\n    }\n\n    public function handleEmergencyNotifications(callable $notificationHandler)\n    {\n        $this-&gt;channel-&gt;basic_qos(null, 1, null);\n\n        $callback = function ($msg) use ($notificationHandler) {\n            $notification = json_decode($msg-&gt;body, true);\n\n            try {\n                $result = $notificationHandler($notification);\n\n                if ($result) {\n                    $msg-&gt;delivery_info['channel']-&gt;basic_ack(\n                        $msg-&gt;delivery_info['delivery_tag']\n                    );\n                } else {\n                    \/\/ \u51e6\u7406\u5931\u6557\u6642\u306f\u5373\u6642\u518d\u8a66\u884c\n                    $msg-&gt;delivery_info['channel']-&gt;basic_nack(\n                        $msg-&gt;delivery_info['delivery_tag'],\n                        false,\n                        true\n                    );\n                }\n            } catch (Exception $e) {\n                \/\/ \u30a8\u30e9\u30fc\u30ed\u30b0\u306e\u8a18\u9332\n                error_log(\"Emergency notification error: \" . $e-&gt;getMessage());\n                \/\/ \u7dca\u6025\u30e1\u30c3\u30bb\u30fc\u30b8\u306f\u5e38\u306b\u518d\u8a66\u884c\n                $msg-&gt;delivery_info['channel']-&gt;basic_nack(\n                    $msg-&gt;delivery_info['delivery_tag'],\n                    false,\n                    true\n                );\n            }\n        };\n\n        $this-&gt;channel-&gt;basic_consume(\n            'emergency_queue',\n            '',\n            false,\n            false,\n            false,\n            false,\n            $callback\n        );\n    }\n}<\/pre>\n\n\n\n<p>\u5b9f\u88c5\u306e\u30dd\u30a4\u30f3\u30c8\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d0\u30c3\u30c1\u51e6\u7406\u306e\u6700\u9069\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u512a\u5148\u5ea6\u306b\u3088\u308b\u51e6\u7406\u306e\u5236\u5fa1<\/li>\n\n\n\n<li>\u9032\u6357\u72b6\u6cc1\u306e\u30c8\u30e9\u30c3\u30ad\u30f3\u30b0<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3068\u518d\u8a66\u884c\u30ed\u30b8\u30c3\u30af<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u9023\u643a<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30a4\u30d9\u30f3\u30c8\u306e\u6c38\u7d9a\u5316<\/li>\n\n\n\n<li>\u67d4\u8edf\u306a\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0<\/li>\n\n\n\n<li>\u969c\u5bb3\u306b\u5f37\u3044\u8a2d\u8a08<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u7dca\u6025\u901a\u77e5\u30b7\u30b9\u30c6\u30e0<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5373\u6642\u6027\u306e\u78ba\u4fdd<\/li>\n\n\n\n<li>\u512a\u5148\u5ea6\u306b\u57fa\u3065\u304f\u51e6\u7406<\/li>\n\n\n\n<li>\u914d\u4fe1\u4fdd\u8a3c\u306e\u5b9f\u88c5<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u306f\u3001\u5b9f\u969b\u306e\u30d7\u30ed\u30c0\u30af\u30b7\u30e7\u30f3\u74b0\u5883\u3067\u306e\u4f7f\u7528\u3092\u60f3\u5b9a\u3057\u305f\u5805\u7262\u306a\u8a2d\u8a08\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning: Undefined array key &#8220;is_admin&#8221; in \/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/ &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":{"0":"post-2448","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-php","7":"nothumb"},"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2448","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2448"}],"version-history":[{"count":2,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2448\/revisions"}],"predecessor-version":[{"id":2450,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2448\/revisions\/2450"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2448"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}