{"id":444988,"date":"2025-01-14T21:01:03","date_gmt":"2025-01-14T21:01:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=444988"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=444988","title":{"rendered":"<span>RabbitMQ + Java Spring<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u043e\u043d\u044f\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0442\u0440\u0443\u0434\u0430 \u0442\u0435\u043c, \u043a\u0442\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 Spring \u0438 Spring Web \u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0440\u0430\u0437 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438, \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 \u0438 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 (\u043f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f &#8212; \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b \u043f\u0430\u0442\u0442\u0435\u0440\u043d Model View Controller).<\/p>\n<h2>\u0421 \u0447\u0435\u0433\u043e \u0432\u0441\u0451 \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u043e\u0441\u044c<\/h2>\n<p>\u041f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u043a\u043e \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u0438 \u0441 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c RabbitMQ \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 Spring Framework. \u0414\u043e \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u0447\u0438\u0442\u0430\u043b \u043e RabbitMQ \u0438 \u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u043c\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0441\u043e\u0431\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b, \u0442\u0430\u043a \u0447\u0442\u043e \u0447\u0430\u0441\u0442\u044c \u0441\u0432\u043e\u0438\u0445 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0430 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0438 \u0435\u0451 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445.<\/p>\n<h2>\u041e RabbitMQ \u0432\u043a\u0440\u0430\u0442\u0446\u0435<\/h2>\n<p>RabbitMQ &#8212; \u0431\u0440\u043e\u043a\u0435\u0440 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u0414\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0435\u0441\u0442\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0441\u043b\u0430\u0431\u043e\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443. RabbitMQ \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0441 \u043f\u043e\u0447\u0442\u043e\u0439, \u043a\u0443\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u043f\u0438\u0441\u044c\u043c\u0430. \u0415\u0441\u043b\u0438 \u043f\u0438\u0441\u044c\u043c\u043e \u043f\u0440\u0438\u0448\u043b\u043e \u043d\u0430 \u043f\u043e\u0447\u0442\u0443, \u0442\u043e \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u0435 \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. \u0422\u0430\u043a\u0436\u0435 \u0438 \u0432 RabbitMQ: \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0435\u0435 \u043f\u0438\u0441\u044c\u043c\u043e \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441 \u0441\u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0431\u0440\u0430\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442. \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u043b\u0430\u0431\u0438\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441, \u0432\u0435\u0434\u044c &#171;\u043f\u0438\u0441\u044c\u043c\u0430&#187; \u043e\u043d \u0441\u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0451\u043c \u0442\u0435\u043c\u043f\u0435.<\/p>\n<p>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0433\u0434\u0435 \u043e\u043d\u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f. \u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0430\u044f \u0435\u0433\u043e \u0441\u0443\u0434\u044c\u0431\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0432\u0448\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435. \u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f, \u0432 \u043a\u0430\u043a\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u043d\u043e \u043f\u043e\u043f\u0430\u0434\u0451\u0442. \u0414\u0430\u043d\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c. \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438\u043b\u0438 topic. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445 \u0438 \u043e\u0431\u043c\u0435\u043d\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e \u043d\u0438\u043c \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435: <a href=\"https:\/\/www.rabbitmq.com\/tutorials\/amqp-concepts\" rel=\"noopener noreferrer nofollow\">https:\/\/www.rabbitmq.com\/tutorials\/amqp-concepts<\/a>.<\/p>\n<p>\u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0445\u0435\u043c\u0443:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f9a\/1f1\/56e\/f9a1f156e3de4245060a2f68ec28cf2a.webp\" alt=\"\u0421\u0445\u0435\u043c\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439\" title=\"\u0421\u0445\u0435\u043c\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439\" width=\"638\" height=\"479\"\/><\/p>\n<div><figcaption>\u0421\u0445\u0435\u043c\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430 \u0441\u0445\u0435\u043c\u0435 P &#8212; producer, \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. X &#8212; \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 (\u043e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432 \u043a\u0430\u043a\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435), Q1, Q2, Q3 &#8212; \u043e\u0447\u0435\u0440\u0435\u0434\u0438, C1, C2, C3 &#8212; \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0438. \u0421\u0445\u0435\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0430\u043a\u0430\u044f, \u043a\u0430\u043a \u0443\u043a\u0430\u0437\u0430\u043d\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438. \u0423 \u043e\u0434\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440\u043e\u0432 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u0439, \u0432\u0441\u0451 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0430\u043c\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432.  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e RabbitMQ \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u044c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442: <a href=\"https:\/\/www.rabbitmq.com\/\" rel=\"noopener noreferrer nofollow\">https:\/\/www.rabbitmq.com\/<\/a>. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0436\u0435 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 Java \u0441 \u0434\u0432\u0443\u043c\u044f \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438, \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c RabbitMQ.<\/p>\n<h2>\u0420\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 RabbitMQ<\/h2>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u044f \u0432\u0437\u044f\u043b\u0441\u044f \u0437\u0430 \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 RabbitMQ. \u0411\u043b\u0430\u0433\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430 Windows \u043d\u0443\u0436\u0435\u043d \u043b\u0438\u0448\u044c \u043f\u0440\u0435\u0434\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 Docker \u0438 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 RabbitMQ \u043d\u0430 \u0441\u0432\u043e\u0451\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"bash\">docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:4.0-management<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"http:\/\/localhost:15672\/\" rel=\"noopener noreferrer nofollow\">http:\/\/localhost:15672<\/a> \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/159\/531\/d14\/159531d14cf9392cb406499aea56cba6.png\" alt=\"\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 RabbitMQ\" title=\"\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 RabbitMQ\" width=\"443\" height=\"203\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/159\/531\/d14\/159531d14cf9392cb406499aea56cba6.png\"\/><\/p>\n<div><figcaption>\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 RabbitMQ<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u0443 \u043b\u043e\u0433\u0438\u043d \u0438 \u043f\u0430\u0440\u043e\u043b\u044c: <strong>guest <\/strong><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0447\u0443\u0434\u0435\u0441\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/53d\/4ee\/439\/53d4ee4392a908e36e1719653ba00baa.png\" alt=\"UI RabbitMQ\" title=\"UI RabbitMQ\" width=\"1865\" height=\"883\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/53d\/4ee\/439\/53d4ee4392a908e36e1719653ba00baa.png\"\/><\/p>\n<div><figcaption>UI RabbitMQ<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0440\u0438 \u0434\u043e\u043b\u0436\u043d\u043e\u043c \u0437\u043d\u0430\u043d\u0438\u0438 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 UI \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0442\u0440\u0443\u0434\u0430.<\/p>\n<p>UI \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 RabbitMQ, \u043e \u0435\u0451 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u0445, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043a \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435&#8230;<\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/p>\n<h2>RabbitMQProducer<\/h2>\n<p> \u0414\u0430\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u043e\u0434\u043d\u0443 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 RabbitMQ.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt; &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt; &lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt; &lt;version&gt;3.4.1&lt;\/version&gt; &lt;relativePath\/&gt; &lt;!-- lookup parent from repository --&gt; &lt;\/parent&gt; &lt;groupId&gt;org.example&lt;\/groupId&gt; &lt;artifactId&gt;RabbitMQProducer&lt;\/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt; &lt;name&gt;RabbitMQProducer&lt;\/name&gt; &lt;description&gt;RabbitMQProducer&lt;\/description&gt; &lt;url\/&gt; &lt;licenses&gt; &lt;license\/&gt; &lt;\/licenses&gt; &lt;developers&gt; &lt;developer\/&gt; &lt;\/developers&gt; &lt;scm&gt; &lt;connection\/&gt; &lt;developerConnection\/&gt; &lt;tag\/&gt; &lt;url\/&gt; &lt;\/scm&gt; &lt;properties&gt; &lt;java.version&gt;21&lt;\/java.version&gt; &lt;\/properties&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-amqp&lt;\/artifactId&gt; &lt;\/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt; &lt;\/dependency&gt;  &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt; &lt;scope&gt;test&lt;\/scope&gt; &lt;\/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.amqp&lt;\/groupId&gt; &lt;artifactId&gt;spring-rabbit-test&lt;\/artifactId&gt; &lt;scope&gt;test&lt;\/scope&gt; &lt;\/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springdoc&lt;\/groupId&gt; &lt;artifactId&gt;springdoc-openapi-starter-webmvc-ui&lt;\/artifactId&gt; &lt;version&gt;2.0.2&lt;\/version&gt; &lt;\/dependency&gt; &lt;\/dependencies&gt;  &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt; &lt;\/plugin&gt; &lt;\/plugins&gt; &lt;\/build&gt;  &lt;\/project&gt; <\/code><\/pre>\n<p>\u0421\u0440\u0435\u0434\u0438 \u043d\u0438\u0445 Spring Web \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f REST, Spring RabbitMQ \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 RabbitMQ \u0438 Srping Openapi \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f Swagger.<\/p>\n<p>\u0421\u043f\u0435\u0440\u0432\u0430 \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0430\u0439\u043b\u0430 application.properties:<\/p>\n<pre><code>spring.application.name=RabbitMQProducer  spring.rabbitmq.username=guest spring.rabbitmq.password=guest spring.rabbitmq.host=localhost spring.rabbitmq.port=5672  server.port=8081  rabbitmq.queue.name=message_queue rabbitmq.queue_with_delay.name=delay_queue<\/code><\/pre>\n<p>\u041f\u043e\u0434 spring.rabbitmq \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a rabbitmq, server.port \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0432\u0435\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c \u043f\u043e\u0440\u0442\u0443 (\u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043f\u0440\u043e\u0441\u0442\u0443 \u0437\u0430\u043d\u044f\u0442 \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c). \u0414\u0432\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0441\u0442\u0440\u043e\u043a\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 (\u0434\u0435-\u0444\u0430\u043a\u0442\u043e \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 Java Code, \u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439, \u043a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0434\u0430 \u0438 \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0449\u0435 \u0438\u0437 application.properties, \u0447\u0435\u043c \u043f\u043e\u0442\u043e\u043c \u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0434\u0435 \u0438 \u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0430\u043c).<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0443\u043a\u0430\u0436\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439:<\/p>\n<pre><code class=\"java\">package org.example.rabbitmqproducer.config;  import org.springframework.amqp.core.Queue; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;   @Configuration public class RabbitMQConfig {      @Value(\"${rabbitmq.queue.name}\")     private String queueName;      @Value(\"${rabbitmq.queue_with_delay.name}\")     private String queueWithDelayName;      \/**      * \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u044c      * @return \u041e\u0447\u0435\u0440\u0435\u0434\u044c RabbitMQ      *\/     @Bean     public Queue queue() {         return new Queue(queueName, false);     }      @Bean     public Queue queue2() {         return new Queue(queueWithDelayName, false);     }  } <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 @Value \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 application.properties.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0431\u0440\u043e\u043a\u0435\u0440:<\/p>\n<pre><code class=\"java\">package org.example.rabbitmqproducer.service;  import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service;  @Service public class MessageService {      private final RabbitTemplate template;      @Value(\"${rabbitmq.queue.name}\")     private String messageQueue;      @Value(\"${rabbitmq.queue_with_delay.name}\")     private String messageWithDelayQueue;      @Autowired     public MessageService(RabbitTemplate template) {         this.template = template;     }      \/**      * \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c      * @param message \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435      *\/     public void sendMessage(String message) {         template.convertAndSend(messageQueue, message);     }      \/**      * \u041f\u043e\u0441\u044b\u043b\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u043c \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439      * @param message \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435      *\/     public void sendMessageToQueueWithDelay(String message) {         template.convertAndSend(messageWithDelayQueue, message);     }  } <\/code><\/pre>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u0433\u0434\u0435 \u043c\u0435\u0442\u043e\u0434 POST \u043f\u043e \u043f\u0443\u0442\u0438 \/message \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 message_queue \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0430 \u043c\u0435\u0442\u043e\u0434 POST \u043f\u043e \u043f\u0443\u0442\u0438 \/message\/with_delay \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c delay_queue:<\/p>\n<pre><code class=\"java\">package org.example.rabbitmqproducer.controller;  import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import org.example.rabbitmqproducer.service.MessageService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping;  @Controller @Tag(name = \"Message Controller\", description = \"Controller to send message to RabbitMQ\") @RequestMapping(\"\/message\") public class MessageController {      private final MessageService service;      @Autowired     public MessageController(MessageService service) {         this.service = service;     }      @Operation(description = \"Send message to RabbitMQ\")     @ApiResponse(responseCode = \"204\")     @PostMapping     public ResponseEntity&lt;Void&gt; sendMessage(String message) {         service.sendMessage(message);         return ResponseEntity.noContent().build();     }      @Operation(description = \"Send message to RabbitMQ in queue with delay\")     @ApiResponse(responseCode = \"204\")     @PostMapping(\"\/with_delay\")     public ResponseEntity&lt;Void&gt; sendMessageWithDelay(String message) {         service.sendMessageToQueueWithDelay(message);         return ResponseEntity.noContent().build();     } } <\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p> \u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0438 \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e, \u0442\u043e \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"http:\/\/localhost:8081\/swagger-ui\/index.html#\/\" rel=\"noopener noreferrer nofollow\">http:\/\/localhost:8081\/swagger-ui\/index.html#\/<\/a> \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u043e\u0434\u043d\u044f\u0442\u044b\u0439 Swagger:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/906\/b5c\/113\/906b5c113691aa77e971e90525864dcc.png\" width=\"1838\" height=\"667\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/906\/b5c\/113\/906b5c113691aa77e971e90525864dcc.png\"\/><\/figure>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u043e\u043c \/message \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u0438 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u043e\u043c \/message\/with_delay \u043e\u0434\u0438\u043d \u0440\u0430\u0437:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d06\/9d1\/677\/d069d167755cea078d6dba9f410ae8d6.png\" alt=\"\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439\" title=\"\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439\" width=\"1877\" height=\"865\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d06\/9d1\/677\/d069d167755cea078d6dba9f410ae8d6.png\"\/><\/p>\n<div><figcaption>\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<\/figcaption><\/div>\n<\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043f\u0440\u0438\u0448\u043b\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0438\u0445.<\/p>\n<h2>RabbitMQConsumer<\/h2>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"  xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt; &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt; &lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt; &lt;version&gt;3.4.1&lt;\/version&gt; &lt;relativePath\/&gt; &lt;!-- lookup parent from repository --&gt; &lt;\/parent&gt; &lt;groupId&gt;org.example&lt;\/groupId&gt; &lt;artifactId&gt;RabbitMQConsumer&lt;\/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt; &lt;name&gt;RabbitMQProducer&lt;\/name&gt; &lt;description&gt;RabbitMQConsumer&lt;\/description&gt; &lt;url\/&gt; &lt;licenses&gt; &lt;license\/&gt; &lt;\/licenses&gt; &lt;developers&gt; &lt;developer\/&gt; &lt;\/developers&gt; &lt;scm&gt; &lt;connection\/&gt; &lt;developerConnection\/&gt; &lt;tag\/&gt; &lt;url\/&gt; &lt;\/scm&gt; &lt;properties&gt; &lt;java.version&gt;21&lt;\/java.version&gt; &lt;\/properties&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-amqp&lt;\/artifactId&gt; &lt;\/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt; &lt;scope&gt;test&lt;\/scope&gt; &lt;\/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.amqp&lt;\/groupId&gt; &lt;artifactId&gt;spring-rabbit-test&lt;\/artifactId&gt; &lt;scope&gt;test&lt;\/scope&gt; &lt;\/dependency&gt; &lt;\/dependencies&gt;  &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt; &lt;\/plugin&gt; &lt;\/plugins&gt; &lt;\/build&gt;  &lt;\/project&gt; <\/code><\/pre>\n<p>\u0421\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c \u0432 application.properties:<\/p>\n<pre><code>spring.application.name=RabbitMQConsumer  spring.rabbitmq.username=guest spring.rabbitmq.password=guest spring.rabbitmq.host=localhost spring.rabbitmq.port=5672  server.port=8082  rabbitmq.queue.name=message_queue rabbitmq.queue_with_delay.name=delay_queue<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0438\u0437 Spring \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043d\u0443\u0436\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e Spring RabbitMQ<\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"java\">package org.example.rabbitmqconsumer.listener;  import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Component;  import java.util.Random;  @Component public class RabbitMQListener {      private final static Random RANDOM = new Random();      @RabbitListener(queues = \"#{@environment.getProperty('rabbitmq.queue.name')}\")     public void receiveMessage(String message) {         System.out.println(\"Received message: \" + message);     }      @RabbitListener(queues = \"#{@environment.getProperty('rabbitmq.queue_with_delay.name')}\")     public void receiveMessageWithDelay(String message) throws InterruptedException {         var delay = RANDOM.nextInt(10000);         Thread.sleep(delay);         System.out.println(\"Received message: \" + message + \" with delay: \" + delay);     }  } <\/code><\/pre>\n<p>\u041e\u0441\u043e\u0431\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 \u0438\u0437 application.properties.<\/p>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 receiveMessage \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0435. \u0412 \u043c\u0435\u0442\u043e\u0434\u0435 receiveMessageWithDelay \u0441\u0438\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u0434\u043e 10 \u0441\u0435\u043a\u0443\u043d\u0434. \u041c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 delay_queue.<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0443\u0432\u0438\u0434\u0438\u043c \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0435:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/885\/73c\/e6d\/88573ce6d3eadc2045594564a9f9bc0d.png\" alt=\"\u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\" title=\"\u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\" width=\"432\" height=\"109\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/885\/73c\/e6d\/88573ce6d3eadc2045594564a9f9bc0d.png\"\/><\/p>\n<div><figcaption>\u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u043e\u0441\u044c \u0438 \u0441\u0430\u043c\u043e \u0437\u0430\u0431\u0440\u0430\u043b\u043e \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435. \u041c\u043e\u0436\u043d\u043e \u0435\u0449\u0451 &#171;\u043f\u043e\u0431\u0430\u043b\u043e\u0432\u0430\u0442\u044c\u0441\u044f&#187; \u0438 \u043f\u043e\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0432 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 delay_queue RabbitMQ:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3d5\/207\/ba2\/3d5207ba219c35737bcd036ef181effe.png\" alt=\"\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 delay_queue\" title=\"\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 delay_queue\" width=\"1878\" height=\"887\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3d5\/207\/ba2\/3d5207ba219c35737bcd036ef181effe.png\"\/><\/p>\n<div><figcaption>\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 delay_queue<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0430 message_queue:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/552\/c19\/59e\/552c1959ecdb2fde47a0c4f445a0f8dd.png\" alt=\"\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 message_queue\" title=\"\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 message_queue\" width=\"1869\" height=\"874\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/552\/c19\/59e\/552c1959ecdb2fde47a0c4f445a0f8dd.png\"\/><\/p>\n<div><figcaption>\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 message_queue<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u0438\u0434\u0438\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0443. \u0412 message_queue \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f. \u0410 \u0432\u043e\u0442 \u0432 delay_queue \u0437\u0430\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u0437-\u0437\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438.<\/p>\n<p><strong>GitHub \u043f\u0440\u043e\u0435\u043a\u0442\u0430: <\/strong><a href=\"https:\/\/github.com\/3abubenni\/rabbitmq\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/3abubenni\/rabbitmq<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/873450\/\"> https:\/\/habr.com\/ru\/articles\/873450\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u043e\u043d\u044f\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0442\u0440\u0443\u0434\u0430 \u0442\u0435\u043c, \u043a\u0442\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 Spring \u0438 Spring Web \u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0440\u0430\u0437 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438, \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 \u0438 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 (\u043f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f &#8212; \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b \u043f\u0430\u0442\u0442\u0435\u0440\u043d Model View Controller).<\/p>\n<h2>\u0421 \u0447\u0435\u0433\u043e \u0432\u0441\u0451 \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u043e\u0441\u044c<\/h2>\n<p>\u041f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u043a\u043e \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u0438 \u0441 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c RabbitMQ \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 Spring Framework. \u0414\u043e \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u0447\u0438\u0442\u0430\u043b \u043e RabbitMQ \u0438 \u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u043c\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0441\u043e\u0431\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b, \u0442\u0430\u043a \u0447\u0442\u043e \u0447\u0430\u0441\u0442\u044c \u0441\u0432\u043e\u0438\u0445 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0430 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0438 \u0435\u0451 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445.<\/p>\n<h2>\u041e RabbitMQ \u0432\u043a\u0440\u0430\u0442\u0446\u0435<\/h2>\n<p>RabbitMQ &#8212; \u0431\u0440\u043e\u043a\u0435\u0440 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u0414\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0435\u0441\u0442\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0441\u043b\u0430\u0431\u043e\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443. RabbitMQ \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0441 \u043f\u043e\u0447\u0442\u043e\u0439, \u043a\u0443\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u043f\u0438\u0441\u044c\u043c\u0430. \u0415\u0441\u043b\u0438 \u043f\u0438\u0441\u044c\u043c\u043e \u043f\u0440\u0438\u0448\u043b\u043e \u043d\u0430 \u043f\u043e\u0447\u0442\u0443, \u0442\u043e \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u0435 \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. \u0422\u0430\u043a\u0436\u0435 \u0438 \u0432 RabbitMQ: \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0435\u0435 \u043f\u0438\u0441\u044c\u043c\u043e \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441 \u0441\u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0431\u0440\u0430\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442. \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u043b\u0430\u0431\u0438\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441, \u0432\u0435\u0434\u044c &#171;\u043f\u0438\u0441\u044c\u043c\u0430&#187; \u043e\u043d \u0441\u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0451\u043c \u0442\u0435\u043c\u043f\u0435.<\/p>\n<p>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0433\u0434\u0435 \u043e\u043d\u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f. \u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0430\u044f \u0435\u0433\u043e \u0441\u0443\u0434\u044c\u0431\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0432\u0448\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435. \u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f, \u0432 \u043a\u0430\u043a\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u043d\u043e \u043f\u043e\u043f\u0430\u0434\u0451\u0442. \u0414\u0430\u043d\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c. \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438\u043b\u0438 topic. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u0445 \u0438 \u043e\u0431\u043c\u0435\u043d\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e \u043d\u0438\u043c \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435: <a href=\"https:\/\/www.rabbitmq.com\/tutorials\/amqp-concepts\" rel=\"noopener noreferrer nofollow\">https:\/\/www.rabbitmq.com\/tutorials\/amqp-concepts<\/a>.<\/p>\n<p>\u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0445\u0435\u043c\u0443:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u0445\u0435\u043c\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430 \u0441\u0445\u0435\u043c\u0435 P &#8212; producer, \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. X &#8212; \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0442\u043e\u0440 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 (\u043e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432 \u043a\u0430\u043a\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435), Q1, Q2, Q3 &#8212; \u043e\u0447\u0435\u0440\u0435\u0434\u0438, C1, C2, C3 &#8212; \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0438. \u0421\u0445\u0435\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0430\u043a\u0430\u044f, \u043a\u0430\u043a \u0443\u043a\u0430\u0437\u0430\u043d\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438. \u0423 \u043e\u0434\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440\u043e\u0432 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u0439, \u0432\u0441\u0451 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0430\u043c\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432.  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e RabbitMQ \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u044c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442: <a href=\"https:\/\/www.rabbitmq.com\/\" rel=\"noopener noreferrer nofollow\">https:\/\/www.rabbitmq.com\/<\/a>. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0436\u0435 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 Java \u0441 \u0434\u0432\u0443\u043c\u044f \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438, \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c RabbitMQ.<\/p>\n<h2>\u0420\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 RabbitMQ<\/h2>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u044f \u0432\u0437\u044f\u043b\u0441\u044f \u0437\u0430 \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 RabbitMQ. \u0411\u043b\u0430\u0433\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430 Windows \u043d\u0443\u0436\u0435\u043d \u043b\u0438\u0448\u044c \u043f\u0440\u0435\u0434\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 Docker \u0438 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 RabbitMQ \u043d\u0430 \u0441\u0432\u043e\u0451\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"bash\">docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:4.0-management<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"http:\/\/localhost:15672\/\" rel=\"noopener noreferrer nofollow\">http:\/\/localhost:15672<\/a> \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<figure class=\"\">\n<div><figcaption>\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 RabbitMQ<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u0443 \u043b\u043e\u0433\u0438\u043d \u0438 \u043f\u0430\u0440\u043e\u043b\u044c: <strong>guest <\/strong><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0447\u0443\u0434\u0435\u0441\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>UI RabbitMQ<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0440\u0438 \u0434\u043e\u043b\u0436\u043d\u043e\u043c \u0437\u043d\u0430\u043d\u0438\u0438 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 UI \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0442\u0440\u0443\u0434\u0430.<\/p>\n<p>UI \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 RabbitMQ, \u043e \u0435\u0451 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u0445, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043a \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435&#8230;<\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/p>\n<h2>RabbitMQProducer<\/h2>\n<p> \u0414\u0430\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u043e\u0434\u043d\u0443 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 RabbitMQ.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt; &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt; &lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt; &lt;version&gt;3.4.1&lt;\/version&gt; &lt;relativePath\/&gt; &lt;!-- lookup parent from repository --&gt; &lt;\/parent&gt; &lt;groupId&gt;org.example&lt;\/groupId&gt; &lt;artifactId&gt;RabbitMQProducer&lt;\/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt; &lt;name&gt;RabbitMQProducer&lt;\/name&gt; &lt;description&gt;RabbitMQProducer&lt;\/description&gt; &lt;url\/&gt; &lt;licenses&gt; &lt;license\/&gt; &lt;\/licenses&gt; &lt;developers&gt; &lt;developer\/&gt; &lt;\/developers&gt; &lt;scm&gt; &lt;connection\/&gt; &lt;developerConnection\/&gt; &lt;tag\/&gt; &lt;url\/&gt; &lt;\/scm&gt; &lt;properties&gt; &lt;java.version&gt;21&lt;\/java.version&gt; &lt;\/properties&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-amqp&lt;\/artifactId&gt; &lt;\/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt; &lt;\/dependency&gt;  &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt; &lt;scope&gt;test&lt;\/scope&gt; &lt;\/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.amqp&lt;\/groupId&gt; &lt;artifactId&gt;spring-rabbit-test&lt;\/artifactId&gt; &lt;scope&gt;test&lt;\/scope&gt; &lt;\/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springdoc&lt;\/groupId&gt; &lt;artifactId&gt;springdoc-openapi-starter-webmvc-ui&lt;\/artifactId&gt; &lt;version&gt;2.0.2&lt;\/version&gt; &lt;\/dependency&gt; &lt;\/dependencies&gt;  &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt; &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt; &lt;\/plugin&gt; &lt;\/plugins&gt; &lt;\/build&gt;  &lt;\/project&gt; <\/code><\/pre>\n<p>\u0421\u0440\u0435\u0434\u0438 \u043d\u0438\u0445 Spring Web \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f REST, Spring RabbitMQ \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 RabbitMQ \u0438 Srping Openapi \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f Swagger.<\/p>\n<p>\u0421\u043f\u0435\u0440\u0432\u0430 \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0430\u0439\u043b\u0430 application.properties:<\/p>\n<pre><code>spring.application.name=RabbitMQProducer  spring.rabbitmq.username=guest spring.rabbitmq.password=guest spring.rabbitmq.host=localhost spring.rabbitmq.port=5672  server.port=8081  rabbitmq.queue.name=message_queue rabbitmq.queue_with_delay.name=delay_queue<\/code><\/pre>\n<p>\u041f\u043e\u0434 spring.rabbitmq \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a rabbitmq, server.port \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0432\u0435\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c \u043f\u043e\u0440\u0442\u0443 (\u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043f\u0440\u043e\u0441\u0442\u0443 \u0437\u0430\u043d\u044f\u0442 \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c). \u0414\u0432\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0441\u0442\u0440\u043e\u043a\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 (\u0434\u0435-\u0444\u0430\u043a\u0442\u043e \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 Java Code, \u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439, \u043a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0434\u0430 \u0438 \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0449\u0435 \u0438\u0437 application.properties, \u0447\u0435\u043c \u043f\u043e\u0442\u043e\u043c \u043a\u043e\u043f\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0434\u0435 \u0438 \u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0430\u043c).<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0443\u043a\u0430\u0436\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439:<\/p>\n<pre><code class=\"java\">package org.example.rabbitmqproducer.config;  import org.springframework.amqp.core.Queue; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;   @Configuration public class RabbitMQConfig {      @Value(\"${rabbitmq.queue.name}\")     private String queueName;      @Value(\"${rabbitmq.queue_with_delay.name}\")     private String queueWithDelayName;      \/**      * \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u044c      * @return \u041e\u0447\u0435\u0440\u0435\u0434\u044c RabbitMQ      *\/     @Bean     public Queue queue() {         return new Queue(queueName, false);     }      @Bean     public Queue queue2() {         return new Queue(queueWithDelayName, false);     }  } <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 @Value \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 application.properties.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0431\u0440\u043e\u043a\u0435\u0440:<\/p>\n<pre><code class=\"java\">package org.example.rabbitmqproducer.service;  import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service;  @Service public class MessageService {      private final RabbitTemplate template;      @Value(\"${rabbitmq.queue.name}\")     private String messageQueue;      @Value(\"${rabbitmq.queue_with_delay.name}\")     private String messageWithDelayQueue;      @Autowired     public MessageService(RabbitTemplate template) {         this.template = template;     }      \/**      * \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c      * @param message \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435      *\/     public void sendMessage(String message) {         template.convertAndSend(messageQueue, message);     }      \/**      * \u041f\u043e\u0441\u044b\u043b\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u043c \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439      * @param message \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435      *\/     public void sendMessageToQueueWithDelay(String message) {         template.convertAndSend(messageWithDelayQueue, message);     }  } <\/code><\/pre>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u0433\u0434\u0435 \u043c\u0435\u0442\u043e\u0434 POST \u043f\u043e \u043f\u0443\u0442\u0438 \/message \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 message_queue \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0430 \u043c\u0435\u0442\u043e\u0434 POST \u043f\u043e \u043f\u0443\u0442\u0438 \/message\/with_delay \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c delay_queue:<\/p>\n<pre><code class=\"java\">package org.example.rabbitmqproducer.controller;  import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import org.example.rabbitmqproducer.service.MessageService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping;  @Controller @Tag(name = \"Message Controller\", description = \"Controller to send message to RabbitMQ\") @RequestMapping(\"\/message\") public class MessageController {      private final MessageService service;      @Autowired     public MessageController(MessageService service) {         this.service = service;     }      @Operation(description = \"Send message to RabbitMQ\")     @ApiResponse(responseCode = \"204\")     @PostMapping     public ResponseEntity&lt;Void&gt; sendMessage(String message) {         service.sendMessage(message);         return ResponseEntity.noContent().build();     }      @Operation(description = \"Send message to RabbitMQ in queue with delay\")     @ApiResponse(responseCode = \"204\")     @PostMapping(\"\/with_delay\")     public ResponseEntity&lt;Void&gt; sendMessageWithDelay(String message) {         service.sendMessageToQueueWithDelay(message);         return ResponseEntity.noContent().build();     } } <\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p> \u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0438 \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e, \u0442\u043e \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <a href=\"http:\/\/localhost:8081\/swagger-ui\/index.html#\/\" rel=\"noopener noreferrer nofollow\">http:\/\/localhost:8081\/swagger-ui\/index.html#\/<\/a> \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u043e\u0434\u043d\u044f\u0442\u044b\u0439 Swagger:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u043e\u043c \/message \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u0438 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u043e\u043c \/message\/with_delay \u043e\u0434\u0438\u043d \u0440\u0430\u0437:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<\/figcaption><\/div>\n<\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043f\u0440\u0438\u0448\u043b\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0438\u0445.<\/p>\n<h2>RabbitMQConsumer<\/h2>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-444988","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/444988","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=444988"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/444988\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=444988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=444988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=444988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}