<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amit Nathani on Medium]]></title>
        <description><![CDATA[Stories by Amit Nathani on Medium]]></description>
        <link>https://medium.com/@amitknx?source=rss-2d54b7d0fedd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0zRPWWmnw62xHSR5OAp8Hg.jpeg</url>
            <title>Stories by Amit Nathani on Medium</title>
            <link>https://medium.com/@amitknx?source=rss-2d54b7d0fedd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 23:57:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amitknx/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Survival of the Luckiest]]></title>
            <link>https://medium.com/@amitknx/survival-of-the-luckiest-5589e261f8fc?source=rss-2d54b7d0fedd------2</link>
            <guid isPermaLink="false">https://medium.com/p/5589e261f8fc</guid>
            <category><![CDATA[traffic]]></category>
            <category><![CDATA[survival]]></category>
            <category><![CDATA[accident]]></category>
            <category><![CDATA[india]]></category>
            <dc:creator><![CDATA[Amit Nathani]]></dc:creator>
            <pubDate>Wed, 25 Dec 2024 17:15:07 GMT</pubDate>
            <atom:updated>2024-12-25T17:15:07.056Z</atom:updated>
            <content:encoded><![CDATA[<p>It is remarkable how the concept has shifted from Darwin’s “Survival of the fittest” to what feels like India’s “Survival of the luckiest.”</p><p>In India, the moment you step out of the house, you rely on luck at every step. For example, imagine you’re heading to the office in the morning. You take your car out of the parking lot, and on your way to work, you must survive speeding vehicles, vehicles coming from the wrong direction (every time I go out, I encounter at least 5–10 such vehicles; it happens so often that sometimes I get confused if I am the one driving in the wrong direction), potholes, water-logging, billboards (not kidding), unmarked speed breakers, to name a few. There is a song from the movie Golmaal 3, “Apna har din aise jiyo, jaise ki aakhri ho(English translation: live every day like it’s your last)” I think about this song every time I step out of the house.</p><p>On my way home from the gym today, I was waiting at a red light and thinking about this blog. When the light turned green and I started crossing the road, I, along with a dozen other people, narrowly survived a speeding car. And let’s not forget the continuous honking on the roads, especially by two-wheelers. What is it with this incessant honking? Whenever I take a walk down the street, I have to wear headphones to prevent my ears from exploding — and I am not even exaggerating. Quick commerce services are just adding fuel to this fire.</p><p>In 2022, a total of 1,68,491 people died in road accidents in India. Two-wheelers accounted for 44% of all road accident fatalities, which is around 75,000 deaths. For reference, the total deaths due to lung cancer in the same year were approximately 66,000. The number of tobacco consumers and registered two-wheelers in India is roughly the same, around 250 million. I think it is high time the government forces two-wheeler companies to add accident photos on vehicles, much like tobacco companies are required to include warning images on their products. It makes complete sense, as 77% of two-wheeler fatalities involved people not wearing helmets.</p><p>My wife argued that such measures wouldn’t make any difference. She believes people will continue driving recklessly and without helmets, even if accident pictures are plastered on vehicles.</p><blockquote>This made me think: people fear death only when it is certain; otherwise, they gamble with probability and chance.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5589e261f8fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing Your Campaign with Adobe-Managed Certificates]]></title>
            <link>https://medium.com/adobetech/securing-your-campaign-with-adobe-managed-certificates-cacc9626eb89?source=rss-2d54b7d0fedd------2</link>
            <guid isPermaLink="false">https://medium.com/p/cacc9626eb89</guid>
            <category><![CDATA[ssl-certificate]]></category>
            <category><![CDATA[campaign]]></category>
            <category><![CDATA[email-security]]></category>
            <category><![CDATA[email-marketing]]></category>
            <category><![CDATA[adobe-campaign]]></category>
            <dc:creator><![CDATA[Amit Nathani]]></dc:creator>
            <pubDate>Wed, 23 Aug 2023 10:12:19 GMT</pubDate>
            <atom:updated>2023-09-11T19:19:33.802Z</atom:updated>
            <content:encoded><![CDATA[<h4>Try Adobe-Managed Certificates to ensure your online presence is protected</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yNUJzXtIkUwqyRbVJ7Ajgg.jpeg" /><figcaption>The Knights protecting the fortress</figcaption></figure><p>In today’s digital landscape, maintaining a secure online presence is paramount for businesses.</p><p>With cyber threats on the rise, protecting your campaign’s website and data from potential vulnerabilities has become more crucial than ever.</p><p>One effective way to achieve this is through the implementation of SSL (Secure Sockets Layer) certificates.</p><p>In this article, we will delve into the concept of Adobe-Managed Certificates, their significance for campaigns, and the benefits they offer in ensuring a secure online environment.</p><h3><strong>The Importance of SSL in Email Campaigns</strong></h3><p>When a customer sends an email campaign to its users, the static media within the emails is provided by a content delivery server. In addition, any links included in the email are served through a load balancer.</p><p>We also include a <a href="https://experienceleague.adobe.com/docs/campaign/campaign-v8/campaigns/send/emails/mirror-page.html?lang=en">mirror page link</a> in the email, allowing those unable to view the email in their email client to access it in the browser.</p><p>SSL certificates play a vital role in establishing a secure connection between all these links(servers) and their visitors. By encrypting the data transmitted between the user’s browser and the server, SSL certificates provide multiple layers of protection against unauthorized access, data breaches, and other malicious activities.</p><blockquote><strong>Google to Shorten Certificate Validity Period:</strong></blockquote><blockquote>In a recent <a href="https://www.chromium.org/Home/chromium-security/root-ca-policy/moving-forward-together/">update</a>, Google unveiled its plan to significantly shorten the certificate validity period <strong>from 398 days to just 90 days</strong>. This change comes with the key objective of promoting automatic certificate management, aiming to prevent certificate revocation or expiration issues. As this modification requires certificate renewal every 90 days, Adobe-Managed certificate becomes an essential feature for our valued campaign customers, eliminating the hassle of cumbersome certificate renewal processes.</blockquote><h3><strong>Introducing Adobe-Managed Certificates</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*h0OkHFeNtzXhf9SXIFGABA.jpeg" /></figure><p>Adobe-Managed Certificates offer a comprehensive solution for campaigns seeking a streamlined and hassle-free approach to end-to-end SSL certificate management.</p><p>The Adobe-Managed Certificate service alleviates the burden of manual certificate management, ensuring a seamless experience for both businesses and their users.</p><h3><strong>Comparison: Customer-Managed Certificates vs Adobe-Managed Certificates</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x23e0ehmJah8-TryeKTCBg.png" /></figure><h3><strong>Benefits of Adobe-Managed Certificates for Campaigns</strong></h3><p><strong>Enhanced Security:</strong> With Adobe-Managed Certificates, all subdomains associated with your campaign website will be secured by default. This eliminates the risk of unsecured subdomains, ensuring comprehensive protection for your entire online presence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CkjzMI23SZ1mAD8cVZBr-g.jpeg" /></figure><p><strong>Cost Savings: </strong>Unlike customer-managed certificates, Adobe-Managed Certificates are a free service offered to customers. This helps campaigns reduce the expenses associated with purchasing SSL certificates from third-party certificate authorities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6WF6ZOPSn3ld1-rvNEes8g.jpeg" /><figcaption>A panda putting money in the safe</figcaption></figure><p><strong>Streamlined Renewal Process: </strong>Adobe takes care of the certificate renewal process, eliminating the need for campaign managers to manually manage and track expiration dates. This ensures that your campaign’s SSL certificates remain valid and up-to-date without any disruptions or downtime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kod-nxOhfMkGUL2RrdLp6w.jpeg" /></figure><p><strong>Simplified Implementation: </strong>With Adobe-Managed Certificates, the cumbersome manual steps of CSR generation and installation are no longer necessary. Adobe’s automated system seamlessly handles these processes, saving valuable time and effort for campaign administrators.</p><p><strong>Error-Free Management:</strong> By entrusting your certificate management to Adobe, you mitigate the risks of human error associated with manual certificate handling. This significantly reduces the chances of misconfigurations or other certificate-related mistakes that could compromise your campaign’s security.</p><h3><strong>Conclusion</strong></h3><p>Securing your campaign’s website is a crucial step in safeguarding your brand’s reputation, protecting user data, and fostering trust among your audience.</p><p>Adobe-Managed Certificates offer a convenient and reliable solution, eliminating the complexities and potential pitfalls associated with customer-managed certificates.</p><p>With the benefits of enhanced security, cost savings, streamlined renewal processes, and error-free management, Adobe-Managed Certificates empower campaign websites with the highest level of SSL protection.</p><p>Stay one step ahead in the digital world by implementing Adobe-Managed Certificates for your campaign, ensuring a safe and secure online environment for both you and your valued customers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cacc9626eb89" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adobetech/securing-your-campaign-with-adobe-managed-certificates-cacc9626eb89">Securing Your Campaign with Adobe-Managed Certificates</a> was originally published in <a href="https://medium.com/adobetech">Adobe Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crux of the Flux — Dive into the Spring WebFlux]]></title>
            <link>https://medium.com/adobetech/crux-of-the-flux-dive-into-the-spring-webflux-593e0f751135?source=rss-2d54b7d0fedd------2</link>
            <guid isPermaLink="false">https://medium.com/p/593e0f751135</guid>
            <category><![CDATA[webflux]]></category>
            <category><![CDATA[spring-webflux]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[project-loom]]></category>
            <dc:creator><![CDATA[Amit Nathani]]></dc:creator>
            <pubDate>Fri, 18 Aug 2023 12:09:25 GMT</pubDate>
            <atom:updated>2023-08-18T20:34:18.319Z</atom:updated>
            <content:encoded><![CDATA[<h3>Crux of the Flux — Dive into the Spring WebFlux</h3><h4>What is Spring WebFlux, and where does it shine?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cdo9EiLspxdRB1lyOEjrRg.jpeg" /><figcaption>A person diving into the ocean</figcaption></figure><p>In our previous <a href="https://blog.developer.adobe.com/crux-of-the-flux-introduction-to-reactive-spring-1598016b2515">blog post about reactive spring</a>, we discussed the fundamentals of reactive programming.</p><p>If you haven’t read it yet, we encourage you to check it out.</p><p>This post will focus more on Spring WebFlux. Spring WebFlux uses the <a href="https://github.com/reactor/reactor">project reactor</a>, which implements the reactive stream APIs provided by <a href="https://www.reactive-streams.org/">reactive stream org</a>. Reactive stream provides a standard for asynchronous stream processing with non-blocking backpressure.</p><p>Reactive streams mainly provide three simple interfaces.</p><p><strong>Subscriber (with four methods):</strong></p><ol><li>public void onSubscribe(Subscription s);</li><li>public void onNext(T t);</li><li>public void onError(Throwable t);</li><li>public void onComplete();</li></ol><p><strong>Publisher(with only one method):</strong></p><ol><li>public void subscribe(Subscriber&lt;? super T&gt; s);</li></ol><p><strong>Subscription (with two methods):</strong></p><ol><li>public void request(long n);</li><li>public void cancel();</li></ol><p><strong>But what are subscribers and publishers?</strong></p><p><strong>Subscribers</strong> will subscribe to the publisher by calling the publisher’s subscribe method. Subscribers will also use the subscription to signal desired data and to cancel the demand.</p><p>The <strong>publisher</strong> will publish the data to all the subscribers using their onNext() method, and it will call onComplete() and onError() to notify the end of the data and the error, respectively. Project Reactor provides two core publishers, Mono and Flux; Mono represents 0..1 and Flux represents 0..N sequences of data.</p><p><strong>And what is Flux?</strong></p><p>Prior to exploring Flux, let’s first recall the concept of streams in Java. In Java, a stream is a collection of data that enables various operations like filter, map, reduce, and more. For example:</p><pre>List&lt;Integer&gt; squaredList = List.of(1, 2, 3, 4, 5).stream().map(i -&gt; i * i).collect(Collectors.toList());</pre><p>Flux is also a collection of data, which can contain zero or more elements that arrive over time. Flux is quite similar to Java streams, but with an added time component. In Java streams, the data is available immediately, while in Flux, the data can arrive over time. For instance:</p><pre>Flux&lt;Integer&gt; dataStream = Flux.from(dataPublisher).map(i -&gt; i * i).collectList();</pre><p>Here, dataPublisher emits data over time as it becomes available, and Flux processes it accordingly.</p><p>Streams in Java offer similar functionality to Flux but with the additional capability of handling data arriving over time.</p><p><strong>Operators:</strong></p><p>Operators in Reactor are functions that allow us to transform data easily. For instance, the map operator can be used to convert data into a new form. For example:</p><pre>Flux&lt;Integer&gt; squaredFlux = Flux.fromIterable(List.of(1, 2, 3, 4)).map(i -&gt; i * i).collectList();</pre><p>In this example, we use the map operator to transform the data into squares.</p><p>Project Reactor provides a rich set of operators for both Mono and Flux, and you can find them in the official documentation here: (<a href="https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Operators.html">https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Operators.html</a>)</p><p>Here are a few more examples of operators:</p><p><strong>filter</strong>: The filter operator allows us to filter data based on specific conditions. For example:</p><pre>Flux&lt;Integer&gt; evenNumbers = Flux.fromIterable(List.of(1, 2, 3, 4)).filter(i -&gt; i % 2 == 0).collectList();</pre><p>This will filter the even integers from the given list.</p><p><strong>switchIfEmpty</strong>: The switchIfEmpty operator is used when the publisher does not emit any data. For example:</p><pre>Flux&lt;Integer&gt; dataFlux = Flux.fromIterable(List.of()).switchIfEmpty(Mono.just(0)) .collectList();</pre><p>If the initial Flux is empty, the switchIfEmpty will be called, and the provided Mono (in this case, Mono.just(0)) will be used as a fallback.</p><p>Reactor’s extensive collection of operators makes it a powerful library for handling reactive data transformations and stream processing.</p><p><strong>Controllers:</strong></p><p>Spring WebFlux offers two distinct approaches for creating controllers: Annotation-based controllers, similar to Spring Boot, and Functional-style controllers.</p><p>In the Functional-style approach, Spring WebFlux provides two functional interfaces, namely HandlerFunction and RouterFunctions, which handles requests and routes them to appropriate functions.</p><p>For instance, consider the following example:</p><pre>RouterFunction&lt;ServerResponse&gt; route = route()<br>                                      .GET(&quot;/person/{id}&quot;, accept(APPLICATION_JSON), handler::getPerson)<br>                                      .GET(&quot;/person&quot;, accept(APPLICATION_JSON), handler::listPeople)<br>                                      .POST(&quot;/person&quot;, handler::createPerson).build();</pre><p>In this example, we define a RouterFunction to handle various HTTP methods and their respective routes. The request is mapped to the appropriate functions within the PersonHandler class.</p><p>Here’s an excerpt of the PersonHandler class:</p><pre>public class PersonHandler {<br><br>  public Mono&lt;ServerResponse&gt; listPeople(ServerRequest request) {<br>  // ...<br>  }<br><br>  public Mono&lt;ServerResponse&gt; createPerson(ServerRequest request) {<br>  // ...<br>  }<br><br>  public Mono&lt;ServerResponse&gt; getPerson(ServerRequest request) {<br>  // ...<br>  }<br>}</pre><p>The PersonHandler class contains individual functions that handle specific HTTP requests, such as listPeople, createPerson, and getPerson. Each function is responsible for processing the request and returning a Mono&lt;ServerResponse&gt;.</p><p>The functional-style approach provides a more programmatic and functional way to define routes and handlers, offering flexibility and conciseness in designing web endpoints with Spring WebFlux.</p><p><strong>WebClient:</strong></p><p>WebClient is a cutting-edge, non-blocking, and reactive client that facilitates HTTP requests. It is the preferred client introduced by Spring, following the deprecation of RestTemplate.</p><p>WebClient can be utilized both for non-blocking calls and in place of RestTemplate for blocking calls. Spring actively recommends using WebClient as the modern and preferred library for handling HTTP interactions.</p><p><strong>Server:</strong></p><p>In Spring WebFlux, the default server is Netty. However, you have the flexibility to switch to a different web server, such as Tomcat, Undertow, Jetty, or a servlet container. Achieving this is as straightforward as excluding Netty and adding the desired web server’s specific dependency.</p><p>WebFlux offers a straightforward interface called HttpHandler with just one method:</p><pre>Mono&lt;Void&gt; handle(ServerHttpRequest request, ServerHttpResponse response);</pre><p>All runtimes must implement this interface to handle incoming HTTP requests and responses. This simplicity allows for easy integration and customization when using different web servers with Spring WebFlux.</p><p><strong>Backpressure:</strong></p><p>Back pressure is a fundamental concept that governs the rate of data transmission between a producer and a consumer. It allows the consumer to control the pace at which data is delivered to it. In Spring WebFlux, back pressure is supported through Project Reactor.</p><p>With back pressure, the consumer can utilize the request mechanism to indicate its readiness to handle a specific number of requests (n). This way, the producer can adjust its data transmission rate accordingly, ensuring a balanced flow of information between the two components. Spring WebFlux, with the help of Project Reactor, facilitates this back pressure mechanism, enabling efficient and controlled data processing in reactive applications.</p><p>Suppose you have a data source that emits a continuous stream of data at a high rate, and you want to process this data using a reactive flow with back pressure. In this case, you can use Flux to handle the data stream and control back pressure using the limitRate() operator.</p><p>Here’s an example:</p><pre>import reactor.core.publisher.Flux;<br><br>public class BackPressureExample {<br><br>  public static void main(String[] args) {<br>    // Simulate a data source emitting a continuous stream of data at a high rate<br>    Flux&lt;Integer&gt; dataSource = Flux.range(1, Integer.MAX_VALUE);<br>  <br>    // Process the data with back pressure using limitRate operator<br>    dataSource.limitRate(10) // Control the number of elements emitted per request (back pressure)<br>              .doOnNext(data -&gt; { // Simulate processing delay<br>                                  try {<br>                                  Thread.sleep(100);<br>                                  }<br>                                  catch (InterruptedException e) {<br>                                  e.printStackTrace();<br>                                  }<br>                                  System.out.println(&quot;Processed: &quot; + data);<br>                                }<br>                        ).subscribe();<br>  }<br>}</pre><p>In this example, the Flux.range(1, Integer.MAX_VALUE) simulates a continuous stream of data. The limitRate(10) operator specifies that the data processing should be limited to 10 elements per request, effectively controlling the back pressure.</p><p>As a result, you’ll notice that the data processing rate is limited, and the doOnNext method will print &quot;Processed: &lt;data&gt;&quot; with a slight delay between each processed element. This demonstrates how back pressure helps in regulating the rate of data consumption and prevents overwhelming the subscriber with an excessive number of elements to process.</p><p><strong>When to use Spring WebFlux?</strong></p><p>Project suitability is a crucial aspect to consider when choosing Spring WebFlux for your application. While WebFlux excels in non-blocking reactive programming, it may not be the best fit for all requirements.</p><p>If your service involves heavy CPU-bound tasks, Spring WebFlux might not be the optimal choice. In such scenarios, blocking threads could hinder performance, making the non-blocking nature of WebFlux less advantageous.</p><p>On the other hand, if your service mainly deals with IO-intensive operations and requires minimal CPU work, Spring WebFlux can be a lifesaver. By leveraging non-blocking techniques, WebFlux can efficiently handle a large number of concurrent requests without blocking threads, ensuring better scalability and responsiveness.</p><p>Ultimately, the decision to use Spring WebFlux depends on the nature of your application’s workload and the balance between CPU-bound and IO-bound tasks. For IO-intensive workloads, WebFlux can be a powerful and efficient solution. For CPU-intensive tasks, it might be more prudent to explore alternative approaches.</p><p><strong>Project Loom and the Future of Spring web-flux:</strong></p><p>There are mainly two types of threads: user-level threads and kernel-level threads. User-level threads are managed by the user application and run in user space, while kernel-level threads are managed by the operating system and run in kernel space.</p><p>User-level threads are lightweight and easy to create and manage, whereas kernel-level threads are heavyweight and require OS and hardware resources. Typically, one or many user-level threads are mapped to one kernel-level thread for execution.</p><p>In the early days of Java, user-level threads (known as green threads) were used, and several of them were mapped to a single kernel-level thread because multi-core processors were not prevalent. However, as multi-core processors became more popular, Java switched to using one user-level thread mapped to one kernel-level thread.</p><p>Now, with the need for better concurrency in high-throughput concurrent systems, Project Loom is reintroducing green threads. As we know that Kernel threads are heavyweight and not that extensible as per the demand of high throughput concurrent systems.</p><p>In Project Loom, green threads will be managed by Java, and there will be a many-to-many mapping between green threads and kernel threads, with a significantly higher number of green threads compared to kernel threads. Theoretically, the number of green threads can be in millions and all will be mapped with a handful of kernel threads.</p><p>Now, you might be thinking: what if a green thread gets blocked on IO, would not it block the kernel thread and in turn, all other green threads mapped to that kernel thread?</p><p>Here is what Project Loom says:</p><p>To handle the potential blocking of kernel threads due to blocking I/O calls by green threads, Project Loom adapts core-library APIs in the JDK to work with virtual threads. When a synchronous I/O operation is called on a virtual thread, Project Loom performs a non-blocking I/O operation under the covers, allowing the virtual thread to be blocked until the operation completes. So, basically, blocking I/O calls will be transformed into non-blocking I/O calls under the hood.</p><p>Both Project Loom and Reactive Spring can be beneficial for services that make numerous I/O calls, as they handle concurrency more efficiently. However, they may not offer significant improvements for CPU-intensive tasks. Reactive Spring, based on Project Reactor, provides many useful operators and built-in support for back pressure. On the other hand, Project Loom is still in its early stages of development and is available in preview mode.</p><p>References:</p><p><a href="https://docs.spring.io/spring-framework/reference/web/webflux.html">https://docs.spring.io/spring-framework/reference/web/webflux.html</a></p><p><a href="https://github.com/reactor/reactor">https://github.com/reactor/reactor</a></p><p><a href="https://www.reactive-streams.org/">https://www.reactive-streams.org/</a></p><p><a href="https://cr.openjdk.org/~rpressler/loom/loom/sol1_part1.html">https://cr.openjdk.org/~rpressler/loom/loom/sol1_part1.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=593e0f751135" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adobetech/crux-of-the-flux-dive-into-the-spring-webflux-593e0f751135">Crux of the Flux — Dive into the Spring WebFlux</a> was originally published in <a href="https://medium.com/adobetech">Adobe Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crux of the Flux — Introduction to Reactive Spring]]></title>
            <link>https://medium.com/adobetech/crux-of-the-flux-introduction-to-reactive-spring-1598016b2515?source=rss-2d54b7d0fedd------2</link>
            <guid isPermaLink="false">https://medium.com/p/1598016b2515</guid>
            <category><![CDATA[servlet]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[adobe-engineering]]></category>
            <category><![CDATA[webflux]]></category>
            <dc:creator><![CDATA[Amit Nathani]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 15:20:34 GMT</pubDate>
            <atom:updated>2023-08-14T17:34:51.159Z</atom:updated>
            <content:encoded><![CDATA[<h3>Crux of the Flux — Introduction to Reactive Spring</h3><h4>How can reactive spring improve efficiency and performance? Think of it like an efficient grocery store.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3bxgAxpiU9BIDgYFff9TBg.jpeg" /><figcaption>Vegetables in a grocery store.</figcaption></figure><p>According to the Oxford Dictionary, the word ‘Reactive’ means “showing a response to an event”.</p><p>This is what reactive means in programming too: “to react and respond to changes and events in a timely manner”.</p><p>Reactive programs are designed to automatically react to incoming events or data changes, instead of explicitly polling for updates or waiting for specific conditions.</p><h3>So why do we need reactive?</h3><p>Let’s take the example of a grocery store.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*958E_8z9nZ7Ei3qH3yiwVA.jpeg" /><figcaption>A grocery store</figcaption></figure><p>This grocery store has a small team of workers. When a customer arrives and requests specific items, one of the workers takes the order and goes inside the store to fetch the things they asked for.</p><p>If another customer arrives while this worker is busy, a different worker takes the new order and goes inside the store to fulfil it.</p><p>This process continues smoothly until all the workers are occupied inside the store. But what happens when a new customer arrives and there are no available workers outside the store to take their order?</p><p>This situation was similar to how servlets used to handle requests before version 3.0.</p><p>In the older servlet model, each incoming request was assigned a dedicated thread to handle the entire request processing. As the number of incoming requests increased, the threads would also increase, eventually leading to a situation where all the threads (workers) were occupied.</p><p>This caused the servlet container to run out of threads, resulting in potential performance issues and resource limitations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9tLwAyhL-ly85xt51W4Juw.jpeg" /><figcaption>A grocery store with a receptionist</figcaption></figure><p>Now, imagine a scenario where the grocery store has a receptionist to handle customer orders.</p><p>When a customer arrives and asks for specific items, they share their order with the receptionist. The receptionist then passes the order to an available worker, who goes inside the store to fetch the items. This efficient system ensures that no customer has to wait for their order to be received.</p><p>In Servlet version 3.0, a similar approach is adopted. Instead of a single thread handling the entire request processing, there are separate thread pools responsible for performing the heavy work.</p><p>Additionally, there is a separate thread, acting like the receptionist, dedicated to receiving and delegating the orders (requests) to the appropriate worker threads. This design significantly improves the efficiency of the system and ensures smooth handling of multiple requests without leaving customers (clients) waiting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1HjGWoLTB-e_Qv9Ig7WBVA.jpeg" /><figcaption>A grocery store with customer waiting</figcaption></figure><p>Let’s consider a scenario where a customer arrives at the grocery store and speaks very slowly while sharing their order with the receptionist.</p><p>As a result, the receptionist gets blocked and is unable to attend to other customers, causing a queue to form.</p><p>This situation reflects a limitation of Servlet 3.0, which employs blocking I/O. When the incoming data from a client is streamed at a slower pace than the server can read, the server thread becomes blocked.</p><p>Consequently, the server thread is occupied waiting for the slow data transfer to complete, making it unavailable to handle other requests efficiently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bhTk75duVct_29tJnI35VQ.jpeg" /><figcaption>A customer in a grocery store writing order</figcaption></figure><p>But luckily, the receptionist comes up with a clever solution to avoid waiting for slow-speaking customers.</p><p>Instead of directly listening to the order, the receptionist hands over a piece of paper to the customer and asks them to write it down. The customer is instructed to notify the receptionist once they finish writing the order. Now, the receptionist can attend to other customers while they wait.</p><p>Similarly, in Servlet 3.1 NIO, a non-blocking I/O approach is adopted, which works similarly to the receptionist’s paper method.</p><p>The servlet registers listeners for input and output streams. When data becomes available, these listeners have callback methods that are triggered, allowing the servlet to efficiently handle requests without being blocked. The servlet is notified when the content is ready, just like the receptionist is notified when the order is written on the paper.</p><p>With this non-blocking I/O mechanism, Servlet 3.1 NIO can handle multiple requests more efficiently, ensuring that slow data transfers or processing do not cause delays in the system. The servlet can focus on other tasks until it receives notifications from the listeners to take further action when the content becomes available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V9qcNYL2Axcv72G6Vs_Z4Q.jpeg" /><figcaption>A customer in a grocery store holding a coffee cup.</figcaption></figure><p>Let’s revisit our grocery store once more, where they also serve a special hot coffee.</p><p>When a customer orders coffee, a worker is assigned to the task. The worker goes to the coffee machine and initiates the process by clicking a button to prepare the special coffee. However, since this coffee is special and takes some time to make, the worker has to wait until it’s ready before handing it over to the customer.</p><p>Now, if more customers start ordering the special coffee (as it’s quite popular), multiple workers might get blocked, waiting for their respective coffee machines to finish. This situation creates a bottleneck, causing delays not only for the workers but also for other customers who are waiting.</p><p>The solution is simple and effective: while the coffee is being prepared, the workers can take additional orders from other customers instead of waiting idly.</p><p>This way, when the coffee is ready on a machine, an available worker can quickly pick it up and serve it to the respective customer. This approach ensures that no worker is blocked and that the workflow remains smooth and efficient for everyone.</p><p>This is what reactive spring (spring-web flux framework) does. Spring Webflux provides non-blocking reactive programming.</p><p><strong>In the next part of this blog, we will talk about the basics of Spring web-flux.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1598016b2515" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adobetech/crux-of-the-flux-introduction-to-reactive-spring-1598016b2515">Crux of the Flux — Introduction to Reactive Spring</a> was originally published in <a href="https://medium.com/adobetech">Adobe Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>