{"id":78042,"date":"2018-06-22T01:00:53","date_gmt":"2018-06-21T22:00:53","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=78042"},"modified":"2023-12-11T12:15:03","modified_gmt":"2023-12-11T10:15:03","slug":"spring-reactor-tutorial","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html","title":{"rendered":"Spring Reactor Tutorial"},"content":{"rendered":"<p>In the world of RESTful services where a lot of work actually happens behind the scenes, we often have to do much of the processing in our application which doesn&#8217;t actually affect the response which needs to be sent to a real-world user. These business decisions can be taken <strong>reactively<\/strong> so that they do not have any impact to a user interacting with the application. Spring Framework provides us with an excellent project, termed as Spring Reactor project which allows us to manage this background processing very well in the background. Before diving into the lesson, one thing we must note is that <strong>Reactive Programming is not same as concurrent programming<\/strong>.<\/p>\n<p>One of the use-cases in RESTful programming for reactive behaviour is that most of the times, services are fundamentally blocking and synchronous. Reactive Programming allows us to expand beyond the scope of synchronous thread and complex orchestrations can be done without demonstrating a blocking behaviour. Let us deep dive into the lesson to understand how this reactive behaviour can be integrated into a Spring Boot-based application.<\/p>\n<div class=\"toc\">\n<h3>Table Of Contents<\/h3>\n<dl>\n<dt><a href=\"#introduction\">1. Introduction<\/a><\/dt>\n<dt><a href=\"#reactor_jvm\">2. Reactor in the JVM<\/a><\/dt>\n<dt><a href=\"#setup_project\">3. Making the Spring Boot Project with Maven<\/a><\/dt>\n<dt><a href=\"#add_maven\">4. Adding Maven dependencies<\/a><\/dt>\n<dt><a href=\"#project_structure\">5. Project Structure<\/a><\/dt>\n<dt><a href=\"#understand_app\">6. Understanding the sample application<\/a><\/dt>\n<dt><a href=\"#define_pojo\">7. Defining the POJO Model<\/a><\/dt>\n<dt><a href=\"#define_service\">8. Defining the Service<\/a><\/dt>\n<dt><a href=\"#event_consumer\">9. Defining the Event Consumer<\/a><\/dt>\n<dt><a href=\"#java_config\">10. Defining the Java Configuration<\/a><\/dt>\n<dt><a href=\"#spring_boot_class\">11. Defining the Spring Boot class<\/a><\/dt>\n<dt><a href=\"#running_project\">12. Running the project<\/a><\/dt>\n<dt><a href=\"#conclusion\">13. Conclusion<\/a><\/dt>\n<dt><a href=\"#download_code\">14. Download the Source Code<\/a><\/dt>\n<\/dl>\n<\/div>\n<h2 id=\"introduction\">1. Introduction<\/h2>\n<p>In this Spring Reactor lesson, we will learn how we can get started with reactive behaviour in a Spring Boot project and start producing and consuming messages in the same application itself. Apart from a simple project, we will see how Spring Reactive flow works and how requests are managed when there are several handlers for the different type of requests.<\/p>\n<p>With the uprise of <a href=\"https:\/\/www.javacodegeeks.com\/2017\/12\/what-are-microservices.html\" target=\"_blank\" rel=\"noopener\">Microservices<\/a>, the necessity of asynchronous communication between the involved services became a mainstream requirement. For communication among various services involved, we can use projects like <a href=\"https:\/\/www.javacodegeeks.com\/2018\/05\/spring-apache-kafka-tutorial.html\" target=\"_blank\" rel=\"noopener\">Apache Kafka<\/a>. Now, asynchronous communication is also desirable for time-consuming requests within the same application as well. This is where the actual use-case of <strong>Spring Reactor<\/strong> comes into play.<\/p>\n<p>Please note that Reactor pattern, as demonstrated in this application is to be used only when a user doesn&#8217;t expect a response directly from the application as we only execute background jobs using this Reactor demonstration. Using Reactors are a very good choice when it is possible for developers to assign a little more heap memory to the application (depending on the number of threads this app will use) and they want to execute tasks in <strong>parallel<\/strong> and <strong>order of execution of tasks<\/strong> doesn&#8217;t really matter. This point is important actually so we will say it again by rephrasing it, it is <strong>not possible to confirm the order of execution of jobs<\/strong> when they are executed in parallel.<\/p>\n<h2 id=\"reactor_jvm\">2. Reactor in the JVM<\/h2>\n<p>The Reactor, as stated by <a href=\"https:\/\/spring.io\/blog\/2013\/05\/13\/reactor-a-foundation-for-asynchronous-applications-on-the-jvm\" target=\"_blank\" rel=\"noopener\">Spring<\/a> itself, is a foundational framework for asynchronous applications on the JVM which on modest hardware, makes it possible to process over <strong>15,000,000 events per second<\/strong> with the fastest non-blocking <code>Dispatcher<\/code>. As it sounds, the Reactor framework is based on the <a href=\"https:\/\/dzone.com\/articles\/understanding-reactor-pattern-thread-based-and-eve\" target=\"_blank\" rel=\"noopener\">Reactor design pattern<\/a>.<\/p>\n<p>The most important thing about Spring Reactor is the level of abstraction this framework provides to a Java Developer developing applications using Spring. This abstraction makes implementing the functionality in our own application very easy. Let&#8217;s get started with a sample project to see how we can make use of this framework in a near to reality application. The reactor project also supports non-blocking inter-process communication (IPC) with the reactor-ipc components but its discussion is out of the scope for this lesson.<\/p>\n<h2 id=\"setup_project\">3. Making the Spring Boot Project with Maven<\/h2>\n<p>We will be using one of the many Maven archetypes to create a sample project for our example. To create the project execute the following command in a directory that you will use as workspace:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Creating a Project<\/em><\/span><\/p>\n<pre class=\"brush:bash\">mvn archetype:generate -DgroupId=com.javacodegeeks.example -DartifactId=JCG-BootReactor-Example -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false\n<\/pre>\n<p>If you are running maven for the first time, it will take a few seconds to accomplish the generate command because maven has to download all the required plugins and artifacts in order to make the generation task. Once we run this project, we will see the following output and the project will be created:<\/p>\n<p><figure id=\"attachment_78488\" aria-describedby=\"caption-attachment-78488\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/project-setup.png\"><img decoding=\"async\" class=\"size-full wp-image-78488\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/project-setup.png\" alt=\"Spring Reactor Project setup\" width=\"820\" height=\"567\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/project-setup.png 820w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/project-setup-300x207.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/project-setup-768x531.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-78488\" class=\"wp-caption-text\">Spring Reactor Project setup<\/figcaption><\/figure><\/p>\n<h2 id=\"add_maven\">4. Adding Maven dependencies<\/h2>\n<p>Once you have created the project, feel free to open it in your favourite IDE. Next step is to add appropriate Maven Dependencies to the project. We will work with following dependencies in our project:<\/p>\n<ul>\n<li><code>spring-boot-starter-web<\/code>: This dependency marks this project as a Web project and it adds dependencies in order to create controllers and make Web-related classes<\/li>\n<li><code>reactor-bus<\/code>: This is the dependency which brings all the Reactor related dependencies into the project classpath<\/li>\n<li><code>spring-boot-starter-test<\/code>: This dependency collects all test related JARs into the project like <a href=\"https:\/\/www.javacodegeeks.com\/2014\/11\/junit-tutorial-unit-testing.html\" target=\"_blank\" rel=\"noopener\">JUnit<\/a> and <a href=\"https:\/\/www.javacodegeeks.com\/2015\/11\/testing-with-mockito.html\" target=\"_blank\" rel=\"noopener\">Mockito<\/a><\/li>\n<\/ul>\n<p>Here is the <code>pom.xml<\/code> file with the appropriate dependencies added:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml\">  &lt;parent&gt;\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n    &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\n    &lt;version&gt;1.5.10.RELEASE&lt;\/version&gt;\n    &lt;relativePath\/&gt; &lt;!-- lookup parent from repository --&gt;\n  &lt;\/parent&gt;\n\n  &lt;properties&gt;\n    &lt;project.build.sourceEncoding&gt;UTF-8&lt;\/project.build.sourceEncoding&gt;\n    &lt;project.reporting.outputEncoding&gt;UTF-8&lt;\/project.reporting.outputEncoding&gt;\n    &lt;java.version&gt;1.8&lt;\/java.version&gt;\n  &lt;\/properties&gt;\n\n  &lt;dependencies&gt;\n\n    &lt;dependency&gt;\n      &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n      &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;\n    &lt;\/dependency&gt;\n\n    &lt;dependency&gt;\n      &lt;groupId&gt;io.projectreactor&lt;\/groupId&gt;\n      &lt;artifactId&gt;reactor-bus&lt;\/artifactId&gt;\n      &lt;version&gt;2.0.8.RELEASE&lt;\/version&gt;\n    &lt;\/dependency&gt;\n\n    &lt;dependency&gt;\n      &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n      &lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt;\n      &lt;scope&gt;test&lt;\/scope&gt;\n    &lt;\/dependency&gt;\n\n  &lt;\/dependencies&gt;\n\n  &lt;build&gt;\n    &lt;plugins&gt;\n      &lt;plugin&gt;\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n        &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt;\n      &lt;\/plugin&gt;\n    &lt;\/plugins&gt;\n  &lt;\/build&gt;\n<\/pre>\n<p>Find the latest Maven dependencies on <a href=\"http:\/\/search.maven.org\/#search|ga|1|g%3A%22org.springframework.boot%22\" target=\"_blank\" rel=\"noopener\">Maven Central<\/a>. We have added a Maven plugin for Spring boot projects as well which help us to make this project into a runnable JAR so that the project is easy to deploy without the help of any modern tools and dependencies. The JAR we obtain from this plugin is completely ready to be deployed as an executable file.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Finally, to understand all the JARs which are added to the project when we added this dependency, we can run a simple Maven command which allows us to see a complete Dependency Tree for a project when we add some dependencies to it. This dependency tree will also show how many dependencies were added when we added some of our own dependencies in a well-placed hierarchial manner. Here is a command which we can use for the same:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Check Dependency Tree<\/em><\/span><\/p>\n<pre class=\"brush:bash\">mvn dependency:tree\n<\/pre>\n<p>When we run this command, it will show us the following Dependency Tree:<\/p>\n<p><figure id=\"attachment_78489\" aria-describedby=\"caption-attachment-78489\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/dependency-tree.png\"><img decoding=\"async\" class=\"size-full wp-image-78489\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/dependency-tree.png\" alt=\"Maven Dependency Tree\" width=\"820\" height=\"993\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/dependency-tree.png 820w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/dependency-tree-248x300.png 248w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/dependency-tree-768x930.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-78489\" class=\"wp-caption-text\">Maven Dependency Tree<\/figcaption><\/figure><\/p>\n<p>Noticed something? So many dependencies were added by just adding three dependencies to the project. Spring Boot collects all related dependencies itself and leave nothing for us in that matter. The biggest advantage is that all these dependencies are guaranteed to be compatible with each other as these dependencies are managed and provided by Spring Boot project&#8217;s pom file itself.<\/p>\n<h2 id=\"project_structure\">5. Project Structure<\/h2>\n<p>Before we move on and start working on the code for the project, let\u2019s present here the project structure we will have once we\u2019re finished adding all the code to the project so that we know where to places classes we will make in this project:<\/p>\n<p><figure id=\"attachment_78050\" aria-describedby=\"caption-attachment-78050\" style=\"width: 414px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/project-structure.png\"><img decoding=\"async\" class=\"size-full wp-image-78050\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/project-structure.png\" alt=\"Spring Reactor Project structure\" width=\"414\" height=\"507\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/project-structure.png 414w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/project-structure-245x300.png 245w\" sizes=\"(max-width: 414px) 100vw, 414px\" \/><\/a><figcaption id=\"caption-attachment-78050\" class=\"wp-caption-text\">Spring Reactor Project structure<\/figcaption><\/figure><\/p>\n<p>We have divided the project into multiple packages so that the principle of separation of concern is followed and code remains modular which makes the extension of the project fairly easy.<\/p>\n<h2 id=\"understand_app\">6. Understanding the sample application<\/h2>\n<p>To keep the aplication simple to understand and also close to a real-life situation, we will consider a scenario of a logistic application which manages the delivery of various shipments placed in the system.<\/p>\n<p>This application receives updates from an external provider about the location of a shipment being delivered to the customer at a given address. Once our application receives this update, it has various operations to perform, like:<\/p>\n<ul>\n<li>Update location for shipment in the database<\/li>\n<li>Sending notification to user&#8217;s mobile device<\/li>\n<li>Send an email notification<\/li>\n<li>Send an SMS to user<\/li>\n<\/ul>\n<p>We choose to exhibit reactive behavior for these operations as user doesn&#8217;t depend on these operations to happen in exact real-time as they are mostly background tasks which can take a little long time as well and user won&#8217;t be highly affected if the status update for a shipment is few minutes late. Let&#8217;s get started with the model creation first.<br \/>\n[ulp id=&#8217;oiCtu6x3AwpaVNPI&#8217;]<br \/>\n&nbsp;<\/p>\n<h2 id=\"define_pojo\">7. Defining the POJO Model<\/h2>\n<p>We will start by defining our POJO which represents a shipment being sent to a customer which have fields like <code>shipmentId<\/code>, <code>currentLocation<\/code> etc. Let&#8217;s define this POJO here:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Shipment.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.example.model;\n\npublic class Shipment {\n    \n    private String shipmentId;\n    private String name;\n    private String currentLocation;\n    private String deliveryAddress;\n    private String status;\n\n    \/\/standard setters and getters\n}\n<\/pre>\n<p>We have defined some basic fields here. We omitted standard getters and setters for brevity but they are necessary to be made as Jackson uses them during Serialization and Deserialization of an Object.<\/p>\n<h2 id=\"define_service\">8. Defining the Service<\/h2>\n<p>We will define a basic interface which defines the contract for the functionality we will use next which will define the business logic which needs to execute once the even is being consumed by the application.<\/p>\n<p>Here is the contract definition we will be using:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>ShipmentService.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.example.service;\n\nimport com.javacodegeeks.example.model.Shipment;\n\npublic interface ShipmentService {\n    void shipmentLocationUpdate(Shipment shipment);\n}\n<\/pre>\n<p>We only have one method definition in this interface as this is al we need for now. Let&#8217;s now move on to implement this service where we will actually demonstrating a sleep method which just mocks the operation behavior for this class:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>ShipmentServiceImpl.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.example.service;\n\nimport com.javacodegeeks.example.model.Shipment;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframework.stereotype.Service;\n\n@Service\npublic class ShipmentServiceImpl implements ShipmentService {\n    \n    private final Logger LOG = LoggerFactory.getLogger(\"ShipmentService\");\n\n    @Override\n    public void shipmentLocationUpdate(Shipment shipment) throws InterruptedException {\n        LOG.info(\"Shipment data: {}\", shipment.getShipmentId());\n        \n        Thread.sleep(3000);\n\n        LOG.info(\"Shipment with ID: {} reached at javacodegeeks!!!\", shipment.getShipmentId());\n    }\n}\n<\/pre>\n<p>For the illustration purposes, when this service is called with shipment details, it just provides some print statements, use a delay of 3000 milliseconds to realize the time which the operations we defined in the previous section might have taken. Note that each of those operations could have taken much more time than just 3 seconds but the application is free from that (until the threads start to pile up on the heap memory for the application which needs to be managed).<\/p>\n<h2 id=\"event_consumer\">9. Defining the Event Consumer<\/h2>\n<p>In this section, we will finally see how we can define a consumer which listen for events shipment location updates. This consumer can be invoked by just putting an event for shipment update on the SPring&#8217;s EventBus we will define and use shortly.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>EventHandler.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.example.handler;\n\nimport com.javacodegeeks.example.model.Shipment;\nimport com.javacodegeeks.example.service.ShipmentService;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Service;\nimport reactor.bus.Event;\nimport reactor.fn.Consumer;\n\n@Service\npublic class EventHandler implements Consumer&lt;Event&lt;Shipment&gt;&gt; {\n    \n    private final ShipmentService shipmentService;\n\n    @Autowired\n    public EventHandler(ShipmentService shipmentService) {\n        this.shipmentService = shipmentService;\n    }\n\n    @Override\n    public void accept(Event&lt;Shipment&gt; shipmentEvent) {\n        Shipment shipment = shipmentEvent.getData();\n        try {\n            shipmentService.shipmentLocationUpdate(shipment);\n        } catch (InterruptedException e) {\n            \/\/do something as bad things have happened\n        }\n    }\n}\n<\/pre>\n<p>This consumer service accepts the object in the event bus and informs our service class so that it can perform necessary operations asynchronously. Note that we will be defining a thread pool as well which will be used to run this consumer so that different threads can be used to run the service method call. Even if we don&#8217;t define the thread pool ourself, Spring Boot will do this for us with some fixed number of maximum threads in the pool.<\/p>\n<p>The good thing about this consumer class is that it receives a <code>Shipment<\/code> object itself from the event bus and there are no conversion or casting needed to be done in the class itself which is a common area of errors and also increases the time taken for business logic to execute.<\/p>\n<h2 id=\"java_config\">10. Defining the Java Configuration<\/h2>\n<p>We can define the configurations with Java in our application. Let&#8217;s do those definitions here:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>ReactorConfig.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.example.config;\n\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.context.annotation.Configuration;\nimport reactor.Environment;\nimport reactor.bus.EventBus;\n\n@Configuration\npublic class ReactorConfig {\n\n    @Bean\n    Environment env() {\n        return Environment.initializeIfEmpty().assignErrorJournal();\n    }\n\n    @Bean\n    EventBus createEventBus(Environment env) {\n        return EventBus.create(env, Environment.THREAD_POOL);\n    }\n}\n<\/pre>\n<p>Clearly, there is nothing special here. We just initialised our thread pool with some number (default here). We just wanted to demonstrate how you can alter the number of threads if you want to, depending on your application use-case.<\/p>\n<h2 id=\"spring_boot_class\">11. Defining the Spring Boot class<\/h2>\n<p>At the final stage, we will make the Spring Boot class with which we can publish a message which can be consumed by the event handler we defined earlier. Here is the class definition for the main class:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Application.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.example;\n\nimport com.javacodegeeks.example.handler.EventHandler;\nimport com.javacodegeeks.example.model.Shipment;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.boot.CommandLineRunner;\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\nimport reactor.bus.Event;\nimport reactor.bus.EventBus;\n\nimport static reactor.bus.selector.Selectors.$;\n\n@SpringBootApplication\npublic class Application implements CommandLineRunner {\n\n    private final Logger LOG = LoggerFactory.getLogger(\"Application\");\n\n    private final EventBus eventBus;\n    private final EventHandler eventHandler;\n\n    @Autowired\n    public Application(EventBus eventBus, EventHandler eventHandler) {\n        this.eventBus = eventBus;\n        this.eventHandler = eventHandler;\n    }\n\n    public static void main(String[] args) {\n        SpringApplication.run(Application.class, args);\n    }\n\n    @Override\n    public void run(String... strings) throws Exception {\n        eventBus.on($(\"eventHandler\"), eventHandler);\n\n        \/\/Publish messages here\n        for (int i = 0; i &lt; 10; i++) {\n            Shipment shipment = new Shipment();\n            shipment.setShipmentId(String.valueOf(i));\n            eventBus.notify(\"eventHandler\", Event.wrap(shipment));\n            LOG.info(\"Published shipment number {}.\", i);\n        }\n    }\n}\n<\/pre>\n<p>We have used an interface CommandLineRunner to make this class run code with which we can test the producer and config class code we wrote. In this class, we publish a message to the specified topic and listen for it in the consumer class we defined in the same application. Note that we use Spring&#8217;s own event bus to carry the jobs and these jobs will not be put on the disk. If this application is gracefully killed using Spring Boot actuator, these jobs will be persisted on disk automatically so that they can be requeued when the application comes back up.<\/p>\n<p>In the next section, we will run our project with a simple Maven command.<\/p>\n<h2 id=\"running_project\">12. Running the project<\/h2>\n<p>Now that the main class definition is done, we can run our project. Running the application is easy with maven, just use the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:bash\">mvn spring-boot:run\n<\/pre>\n<p>Once we execute the above command, we will see that a message has been published and same app consumed the message in the event handler:<\/p>\n<p><figure id=\"attachment_78490\" aria-describedby=\"caption-attachment-78490\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/running-project.png\"><img decoding=\"async\" class=\"size-full wp-image-78490\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/running-project.png\" alt=\"Running Spring Reactor application\" width=\"820\" height=\"453\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/running-project.png 820w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/running-project-300x166.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/running-project-768x424.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-78490\" class=\"wp-caption-text\">Running Spring Reactor application<\/figcaption><\/figure><\/p>\n<p>We saw that events were published when the application was started using the <code>CommandLineRunner<\/code> method we used in a non-blocking mode. Once the events were published, it was consumed by the event handler in parallel. If you take a close look at the consumer, you will notice that Spring define four threads in the thread pool to manage these events. This is the default limit on the number of threads Spring defines to manage events in parallel.<\/p>\n<h2 id=\"conclusion\">13. Conclusion<\/h2>\n<p>In this lesson, we looked at how easy and quick it is to construct a Spring Boot app with Reactor project integrated into it. As we already said, a well-designed reactor pattern in your application can have a throughput as high as 15,000,000 (that&#8217;s <strong>six zeroes<\/strong>) events per second. This shows that how efficiently the internal queue for this reactor is implemented.<\/p>\n<p>In the small application we defined, we demonstrated a simple way of defining the thread pool executor which defined four threads and a consumer which make use of this thread pool to manage events in parallel. One of the most common problems faced in applications which rely on asynchronous behaviour for execution of operations is that run out of memory very soon as there are multiple threads which start to occupy heap space and create objects as they start to process. It is important to make sure that while starting the application, we assign good heap size to the application which directly depends on the size of the thread pool defined for the application.<\/p>\n<p>The reactive style of programming is one of the most common programming styles which is in uprise right now as applications have started to exploit CPU cores with their parallel execution which is a very good idea to use hardware at the application level. The Reactor provides a complete non-blocking programming foundation for JVM and is also available for Groovy or Kotlin. Due to the fact that Java is not a reactive language in itself, it does not support coroutines natively. There are several JVM languages like Scala and Clojure which support reactive models better in terms of nativeness, but Java itself does not do the same (at least not until version 9).<\/p>\n<h2 id=\"download_code\">14. Download the Source Code<\/h2>\n<p>This was an example of Java programming language with Spring Boot and Reactor pattern.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <strong><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2018\/06\/JCG-BootReactor-Example.zip\" target=\"_blank\" rel=\"noopener\">Reactor Example<\/a><\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In the world of RESTful services where a lot of work actually happens behind the scenes, we often have to do much of the processing in our application which doesn&#8217;t actually affect the response which needs to be sent to a real-world user. These business decisions can be taken reactively so that they do not &hellip;<\/p>\n","protected":false},"author":20016,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[1767,1421,30,854],"class_list":["post-78042","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-reactive-programming","tag-reactor","tag-spring","tag-spring-boot"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring Reactor Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn more about Spring? Then check out our detailed example on Spring Reactor! You can also download our FREE Spring Framework Cookbook!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Reactor Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about Spring? Then check out our detailed example on Spring Reactor! You can also download our FREE Spring Framework Cookbook!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-06-21T22:00:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-11T10:15:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Shubham Aggarwal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shubham Aggarwal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/06\\\/spring-reactor-tutorial.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/06\\\/spring-reactor-tutorial.html\"},\"author\":{\"name\":\"Shubham Aggarwal\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/0953481a8babbb7a63907edb41f357ad\"},\"headline\":\"Spring Reactor Tutorial\",\"datePublished\":\"2018-06-21T22:00:53+00:00\",\"dateModified\":\"2023-12-11T10:15:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/06\\\/spring-reactor-tutorial.html\"},\"wordCount\":2417,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/06\\\/spring-reactor-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"Reactive Programming\",\"Reactor\",\"Spring\",\"Spring Boot\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/06\\\/spring-reactor-tutorial.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/06\\\/spring-reactor-tutorial.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/06\\\/spring-reactor-tutorial.html\",\"name\":\"Spring Reactor Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/06\\\/spring-reactor-tutorial.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/06\\\/spring-reactor-tutorial.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2018-06-21T22:00:53+00:00\",\"dateModified\":\"2023-12-11T10:15:03+00:00\",\"description\":\"Interested to learn more about Spring? Then check out our detailed example on Spring Reactor! You can also download our FREE Spring Framework Cookbook!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/06\\\/spring-reactor-tutorial.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/06\\\/spring-reactor-tutorial.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/06\\\/spring-reactor-tutorial.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2018\\\/06\\\/spring-reactor-tutorial.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Spring Reactor Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/0953481a8babbb7a63907edb41f357ad\",\"name\":\"Shubham Aggarwal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g\",\"caption\":\"Shubham Aggarwal\"},\"description\":\"Shubham is a Java EE Engineer with about 3 years of experience in building quality products with Spring Boot, Spring Data, AWS, Kafka, PrestoDB.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sbmaggarwal\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/shubham-aggarwal\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Reactor Tutorial - Java Code Geeks","description":"Interested to learn more about Spring? Then check out our detailed example on Spring Reactor! You can also download our FREE Spring Framework Cookbook!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html","og_locale":"en_US","og_type":"article","og_title":"Spring Reactor Tutorial - Java Code Geeks","og_description":"Interested to learn more about Spring? Then check out our detailed example on Spring Reactor! You can also download our FREE Spring Framework Cookbook!","og_url":"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2018-06-21T22:00:53+00:00","article_modified_time":"2023-12-11T10:15:03+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Shubham Aggarwal","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Shubham Aggarwal","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html"},"author":{"name":"Shubham Aggarwal","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/0953481a8babbb7a63907edb41f357ad"},"headline":"Spring Reactor Tutorial","datePublished":"2018-06-21T22:00:53+00:00","dateModified":"2023-12-11T10:15:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html"},"wordCount":2417,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["Reactive Programming","Reactor","Spring","Spring Boot"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html","url":"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html","name":"Spring Reactor Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2018-06-21T22:00:53+00:00","dateModified":"2023-12-11T10:15:03+00:00","description":"Interested to learn more about Spring? Then check out our detailed example on Spring Reactor! You can also download our FREE Spring Framework Cookbook!","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2018\/06\/spring-reactor-tutorial.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Spring Reactor Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/0953481a8babbb7a63907edb41f357ad","name":"Shubham Aggarwal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3f2c210fd210e1cafb930887d5f4c29613eb8183e62743a99e0cb93dcaec1a2b?s=96&d=mm&r=g","caption":"Shubham Aggarwal"},"description":"Shubham is a Java EE Engineer with about 3 years of experience in building quality products with Spring Boot, Spring Data, AWS, Kafka, PrestoDB.","sameAs":["https:\/\/www.linkedin.com\/in\/sbmaggarwal\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/shubham-aggarwal"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/78042","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/20016"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=78042"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/78042\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=78042"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=78042"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=78042"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}