{"id":210,"date":"2020-04-15T22:18:08","date_gmt":"2020-04-15T22:18:08","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/microservices\/?p=210"},"modified":"2020-04-17T20:19:57","modified_gmt":"2020-04-17T20:19:57","slug":"rabbitmq-in-microservices-step-by-step-tutorial-with-springboot","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/microservices\/rabbitmq-in-microservices-step-by-step-tutorial-with-springboot\/","title":{"rendered":"RabbitMQ in Microservices &#8211; Step by Step Tutorial with SpringBoot"},"content":{"rendered":"<p>In this step by step tutorial, you will learn about RabbitMQ. We would build a Spring Boot project using IntelliJ. This tutorial covers the following<\/p>\n<ol>\n<li><a href=\"#t1\">What is RabbitMQ?<\/a><\/li>\n<li><a href=\"#t2\">How to Install and Configure RabbitMQ<\/a><\/li>\n<li><a href=\"#t3\">View the RabbitMQ Console<\/a><\/li>\n<li><a href=\"#t4\">Setup the Spring Application and Profiles<\/a><\/li>\n<li><a href=\"#t5\">Send a Message to the Queue<\/a><\/li>\n<li><a href=\"#t6\">Receive a Message from the Queue<\/a><\/li>\n<li><a href=\"#t7\">Testing Send and Receive<\/a><\/li>\n<li><a href=\"#vid\">Watch the Video<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t1\">1. What is RabbitMQ?<\/strong><\/h5>\n<p>Well, RabbitMQ is a message broker. The next question is, &#8216;what is message broker?&#8217;. A message broker is simply a computer program that relays messages from the source(sender) to the destination(receiver).<\/p>\n<p>The sender and receiver could be different microservices. Or perhaps, completed different applications.<\/p>\n<p><strong>Why we need a Message Broker<\/strong><\/p>\n<p>According to the book &#8216;Practical Microservices Architectural Patterns&#8217;, messages helps to gracefully accommodate downtime or failures of coordinating applications. This means that if a microservice wants to send a message to another microservice but the destination microservice is down, then the message broker could store this message. So when the destination microservice is up, it could retrieve this message from the message broker.<\/p>\n<p>We&#8217;ll demonstrate this in this tutorial.<\/p>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t2\">2. How to Install and Configure RabbitMQ<\/strong><\/h5>\n<p>To install and configure RabbitMQ, follow the steps below:<\/p>\n<p><strong>Step 1:<\/strong> Download and install Erlang. RabbitMQ requires Erlang to be available in your machine. <a href=\"http:\/\/erlang.org\/download\/otp_win64_22.3.exe\">Download Erlang here<\/a><\/p>\n<p><strong>Step 2<\/strong>: Set ERLANG_HOME environment veriable to the location of your Erlang installation (you can see the video on how to do this). In my setup, the ERLANG_HOME is set to <span style=\"color: #800000;\">D:\\ProgramFiles\\erl10.7<\/span><\/p>\n<p><strong>Step 3<\/strong>: Download <a href=\"https:\/\/github.com\/rabbitmq\/rabbitmq-server\/releases\/download\/v3.8.3\/rabbitmq-server-3.8.3.exe\">RabbitMQ from here.<\/a> Simply run the installer to install RabbitMQ.<\/p>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t3\">3. Start RabbitMQ and View the Dashboard<\/strong><\/h5>\n<p>RabbitMQ provides a management dashboard as an HTTP-bases API for managing and monitoring the RabbitMQ server. This comes with a dashboard which you can access from the browser. Follow the steps below:<\/p>\n<p><strong>Step 1<\/strong>: Open command prompt and navigate to sbin folder inside the RabbitMQ install directory. For me, the directory is D:\\ProgramFiles\\RabbitMQ Server\\rabbitmq_server-3.8.3\\sbin<\/p>\n<p><strong>Step 2<\/strong>: Enable the management dashboard using the command:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">rabbitmq-plugins enable rabbitmq_management\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Step 3<\/strong>: Start RabbitMQ by running the command<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">rabbitmq-server.bat\r\n<\/pre>\n<p>The above command starts up the management console in default port 15672<\/p>\n<p><strong>Step 4:<\/strong> Open your browser and visit<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">http:\/\/127.0.0.1:15672\r\n<\/pre>\n<p>Login using the username: quest and password: guest;<\/p>\n<p>The dashboard is shown below:<\/p>\n<figure id=\"attachment_212\" aria-describedby=\"caption-attachment-212\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.kindsonthegenius.com\/microservices\/rabbitmq-in-microservices-step-by-step-tutorial-with-springboot\/rabbitmq-login\/#main\" rel=\"attachment wp-att-212\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-212 size-medium\" src=\"https:\/\/www.kindsonthegenius.com\/microservices\/wp-content\/uploads\/sites\/18\/2020\/04\/RabbitMQ-Login-300x167.jpg\" alt=\"\" width=\"300\" height=\"167\" srcset=\"https:\/\/www.kindsonthegenius.com\/microservices\/wp-content\/uploads\/sites\/18\/2020\/04\/RabbitMQ-Login-300x167.jpg 300w, https:\/\/www.kindsonthegenius.com\/microservices\/wp-content\/uploads\/sites\/18\/2020\/04\/RabbitMQ-Login.jpg 727w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-212\" class=\"wp-caption-text\">RabbitMQ Login<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>Once you login, you&#8217;ll see the dashboard as shown below:<\/p>\n<figure id=\"attachment_214\" aria-describedby=\"caption-attachment-214\" style=\"width: 640px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.kindsonthegenius.com\/microservices\/rabbitmq-in-microservices-step-by-step-tutorial-with-springboot\/rabbitmq-dashboard-window\/#main\" target=\"_blank\" rel=\"attachment noopener wp-att-214 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-214 size-large\" src=\"https:\/\/www.kindsonthegenius.com\/microservices\/wp-content\/uploads\/sites\/18\/2020\/04\/RabbitMQ-Dashboard-Window-1024x562.jpg\" alt=\"RabbitMQ Dashboard Window\" width=\"640\" height=\"351\" srcset=\"https:\/\/www.kindsonthegenius.com\/microservices\/wp-content\/uploads\/sites\/18\/2020\/04\/RabbitMQ-Dashboard-Window-1024x562.jpg 1024w, https:\/\/www.kindsonthegenius.com\/microservices\/wp-content\/uploads\/sites\/18\/2020\/04\/RabbitMQ-Dashboard-Window-300x165.jpg 300w, https:\/\/www.kindsonthegenius.com\/microservices\/wp-content\/uploads\/sites\/18\/2020\/04\/RabbitMQ-Dashboard-Window-768x421.jpg 768w, https:\/\/www.kindsonthegenius.com\/microservices\/wp-content\/uploads\/sites\/18\/2020\/04\/RabbitMQ-Dashboard-Window.jpg 1393w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><figcaption id=\"caption-attachment-214\" class=\"wp-caption-text\">RabbitMQ Dashboard Window<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t4\">4. Setup the Spring Application and Profiles<\/strong><\/h5>\n<p>Build a new Spring Starter project (you can use Spring Tool Suite or IntellliJ IDE).<\/p>\n<p>Add the following dependencies:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #007700;\">&lt;dependency&gt;<\/span>\r\n\t<span style=\"color: #007700;\">&lt;groupId&gt;<\/span>org.slf4j<span style=\"color: #007700;\">&lt;\/groupId&gt;<\/span>\r\n\t<span style=\"color: #007700;\">&lt;artifactId&gt;<\/span>slf4j-api<span style=\"color: #007700;\">&lt;\/artifactId&gt;<\/span>\r\n\t<span style=\"color: #007700;\">&lt;version&gt;<\/span>1.7.30<span style=\"color: #007700;\">&lt;\/version&gt;<\/span>\r\n<span style=\"color: #007700;\">&lt;\/dependency&gt;<\/span>\r\n\r\n<span style=\"color: #007700;\">&lt;dependency&gt;<\/span>\r\n\t<span style=\"color: #007700;\">&lt;groupId&gt;<\/span>org.springframework.boot<span style=\"color: #007700;\">&lt;\/groupId&gt;<\/span>\r\n\t<span style=\"color: #007700;\">&lt;artifactId&gt;<\/span>spring-boot-starter-amqp<span style=\"color: #007700;\">&lt;\/artifactId&gt;<\/span>\r\n<span style=\"color: #007700;\">&lt;\/dependency&gt;<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Next, in the base application class you need to declare a logger factory and the queue-name. The logger factory is used to log messages to the output. Use the two lines below:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> String QUEUE_NAME <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"hello\"<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">static<\/span> Logger logger \r\n\t\t<span style=\"color: #333333;\">=<\/span> LoggerFactory<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getLogger<\/span><span style=\"color: #333333;\">(<\/span>DistributedMessagingApplication<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">class<\/span><span style=\"color: #333333;\">);<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Now, you need to creat etwo profiles: send and receive. The Send.java class would run on the &#8216;send&#8217; profile while the Receive.java would run on the receive profile.<\/p>\n<p>You need to create these profile using the Run Configuration. Just in case, you don&#8217;t know, profiles allow you to split an application into two parts which can run separately.<\/p>\n<p><a href=\"https:\/\/www.kindsonthegenius.com\/microservices\/cqrs-with-axon-tutorial-part-8-setup-spring-profiles\/#t3\" target=\"_blank\" rel=\"noopener noreferrer\">See how to create profile here.<\/a><\/p>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t5\">5. Send a Message to the Queue<\/strong><\/h5>\n<p>Create a class named Send.java. This class contains the code to send a message to the queue. Also notice the @Profile annotation. This means that this class would run independently on the &#8216;send&#8217; profile.<\/p>\n<p>The content of the Send.java class is given below<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #555555; font-weight: bold;\">@Profile<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"send\"<\/span><span style=\"color: #333333;\">)<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">Send<\/span> <span style=\"color: #333333;\">{<\/span>\r\n    <span style=\"color: #008800; font-weight: bold;\">static<\/span> Logger logger \r\n            <span style=\"color: #333333;\">=<\/span> LoggerFactory<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getLogger<\/span><span style=\"color: #333333;\">(<\/span>Receive<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">class<\/span><span style=\"color: #333333;\">);<\/span>\r\n\r\n    <span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> String QUEUE_NAME <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"hello\"<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n    <span style=\"color: #008800; font-weight: bold;\">public<\/span>  <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">[]<\/span> argv<span style=\"color: #333333;\">)<\/span>\r\n            <span style=\"color: #008800; font-weight: bold;\">throws<\/span> IOException<span style=\"color: #333333;\">,<\/span> TimeoutException <span style=\"color: #333333;\">{<\/span>\r\n        ConnectionFactory factory <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> ConnectionFactory<span style=\"color: #333333;\">();<\/span>\r\n        factory<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setHost<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"localhost\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n        Connection connection <span style=\"color: #333333;\">=<\/span> factory<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">newConnection<\/span><span style=\"color: #333333;\">();<\/span>\r\n        Channel channel <span style=\"color: #333333;\">=<\/span> connection<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">createChannel<\/span><span style=\"color: #333333;\">();<\/span>\r\n        channel<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">queueDeclare<\/span><span style=\"color: #333333;\">(<\/span>QUEUE_NAME<span style=\"color: #333333;\">,<\/span>\r\n                <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">,<\/span>\r\n                <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">,<\/span>\r\n                <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">,<\/span>\r\n                <span style=\"color: #008800; font-weight: bold;\">null<\/span><span style=\"color: #333333;\">);<\/span>\r\n        String message <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"Welcome to RabbitMQ\"<\/span><span style=\"color: #333333;\">;<\/span>\r\n        channel<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">basicPublish<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"\"<\/span><span style=\"color: #333333;\">,<\/span>\r\n                QUEUE_NAME<span style=\"color: #333333;\">,<\/span>\r\n                <span style=\"color: #008800; font-weight: bold;\">null<\/span><span style=\"color: #333333;\">,<\/span>\r\n                message<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getBytes<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"UTF-8\"<\/span><span style=\"color: #333333;\">));<\/span>\r\n        logger<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">debug<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"[!] Sent '\"<\/span> <span style=\"color: #333333;\">+<\/span> message <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">\"'\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n        channel<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">close<\/span><span style=\"color: #333333;\">();<\/span>\r\n        connection<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">close<\/span><span style=\"color: #333333;\">();<\/span>\r\n    <span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t6\">6. Receive a Message from the Queue<\/strong><\/h5>\n<p>Create a class named Receive.java. This class would run on the &#8216;receive&#8217; profile. You also need to create the receive profile as before.<\/p>\n<p>The content of the file is given below:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #555555; font-weight: bold;\">@Profile<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"receive\"<\/span><span style=\"color: #333333;\">)<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">Receive<\/span> <span style=\"color: #333333;\">{<\/span>\r\n    <span style=\"color: #008800; font-weight: bold;\">static<\/span> Logger logger <span style=\"color: #333333;\">=<\/span> LoggerFactory<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getLogger<\/span><span style=\"color: #333333;\">(<\/span>Receive<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">class<\/span><span style=\"color: #333333;\">);<\/span>\r\n\r\n    <span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> String QUEUE_NAME <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"hello\"<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n    <span style=\"color: #008800; font-weight: bold;\">public<\/span>  <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">[]<\/span> argv<span style=\"color: #333333;\">)<\/span> \r\n            <span style=\"color: #008800; font-weight: bold;\">throws<\/span> IOException<span style=\"color: #333333;\">,<\/span> TimeoutException <span style=\"color: #333333;\">{<\/span>\r\n        ConnectionFactory factory <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> ConnectionFactory<span style=\"color: #333333;\">();<\/span>\r\n        factory<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setHost<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"localhost\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n        Connection connection <span style=\"color: #333333;\">=<\/span> factory<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">newConnection<\/span><span style=\"color: #333333;\">();<\/span>\r\n        Channel channel <span style=\"color: #333333;\">=<\/span> connection<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">createChannel<\/span><span style=\"color: #333333;\">();<\/span>\r\n        channel<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">queueDeclare<\/span><span style=\"color: #333333;\">(<\/span>QUEUE_NAME<span style=\"color: #333333;\">,<\/span> \r\n                <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #008800; font-weight: bold;\">null<\/span><span style=\"color: #333333;\">);<\/span>\r\n        logger<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">info<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"[!] Waiting for messages. To exit press Ctrl+C\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\r\n        Consumer consumer <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> DefaultConsumer<span style=\"color: #333333;\">(<\/span>channel<span style=\"color: #333333;\">){<\/span>\r\n            <span style=\"color: #555555; font-weight: bold;\">@Override<\/span>\r\n            <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">handleDelivery<\/span><span style=\"color: #333333;\">(<\/span>String consumerTag<span style=\"color: #333333;\">,<\/span>\r\n                                       Envelope envelope<span style=\"color: #333333;\">,<\/span>\r\n                                       AMQP<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">BasicProperties<\/span> properties<span style=\"color: #333333;\">,<\/span>\r\n                                       <span style=\"color: #333399; font-weight: bold;\">byte<\/span><span style=\"color: #333333;\">[]<\/span> body<span style=\"color: #333333;\">)<\/span>\r\n                    <span style=\"color: #008800; font-weight: bold;\">throws<\/span> IOException <span style=\"color: #333333;\">{<\/span>\r\n                String message <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> String<span style=\"color: #333333;\">(<\/span>body<span style=\"color: #333333;\">,<\/span> <span style=\"background-color: #fff0f0;\">\"UTF-8\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n                logger<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">info<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"[x] Message Recieved' \"<\/span> <span style=\"color: #333333;\">+<\/span> message <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">\"'\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n            <span style=\"color: #333333;\">}<\/span>\r\n        <span style=\"color: #333333;\">};<\/span>\r\n        channel<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">basicConsume<\/span><span style=\"color: #333333;\">(<\/span>QUEUE_NAME<span style=\"color: #333333;\">,<\/span> <span style=\"color: #008800; font-weight: bold;\">true<\/span><span style=\"color: #333333;\">,<\/span> consumer<span style=\"color: #333333;\">);<\/span>\r\n    <span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t7\">7. Testing Send and\u00a0<\/strong>Receive<\/h5>\n<p>Now you can first run the application using the &#8216;send&#8217; configuration. You&#8217;ll see in the console window a message that says: &#8220;Message sent&#8230;<\/p>\n<p>Then go back to the RabbitMQ Dashboard.<\/p>\n<p>Click on the Queues tabs<\/p>\n<p>Expand on Messages and click on GetMessages.<\/p>\n<p>You will see the message &#8220;Welcome to RabbitMQ&#8221;<\/p>\n<p>Go back to IntelliJ and run the application using the &#8216;receive&#8217; configuration.<\/p>\n<p>One the application starts, you can see in the console window that the message is received.<\/p>\n<p>Finally, go back and check the RabbitMQ Dashbaord for the messages. You&#8217;ll notice that they are no longer there.<\/p>\n<p>So once a message is published, then it is retrieved and removed from the queue.<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/qcfEChxM7Mk\" width=\"100%\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\ufeff<\/span><\/iframe><\/p>\n<p>Thanks for learning!. If you have any challenges please let me know in a comment. Also, you can watch the video for clarification.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this step by step tutorial, you will learn about RabbitMQ. We would build a Spring Boot project using IntelliJ. This tutorial covers the following &hellip; <\/p>\n","protected":false},"author":1,"featured_media":215,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[57,2,58],"tags":[25,36],"class_list":["post-210","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-messaging","category-microservices","category-rabbitmq","tag-spring-boot","tag-spring-profiles"],"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/microservices\/wp-json\/wp\/v2\/posts\/210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/microservices\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/microservices\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/microservices\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/microservices\/wp-json\/wp\/v2\/comments?post=210"}],"version-history":[{"count":7,"href":"https:\/\/www.kindsonthegenius.com\/microservices\/wp-json\/wp\/v2\/posts\/210\/revisions"}],"predecessor-version":[{"id":226,"href":"https:\/\/www.kindsonthegenius.com\/microservices\/wp-json\/wp\/v2\/posts\/210\/revisions\/226"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/microservices\/wp-json\/wp\/v2\/media\/215"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/microservices\/wp-json\/wp\/v2\/media?parent=210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/microservices\/wp-json\/wp\/v2\/categories?post=210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/microservices\/wp-json\/wp\/v2\/tags?post=210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}