<?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 Swaroop Reddy on Medium]]></title>
        <description><![CDATA[Stories by Swaroop Reddy on Medium]]></description>
        <link>https://medium.com/@swaroop1232010?source=rss-95bdc513a8ae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MbakrTTuEhhHK9EZyhQRRQ.png</url>
            <title>Stories by Swaroop Reddy on Medium</title>
            <link>https://medium.com/@swaroop1232010?source=rss-95bdc513a8ae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 02:06:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@swaroop1232010/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[I Tested Spring AI 2.1’s New Reranker Locally. The Small Model Made My RAG Worse.]]></title>
            <link>https://medium.com/@swaroop1232010/i-tested-spring-ai-2-1s-new-reranker-locally-the-small-model-made-my-rag-worse-ff970ce0de65?source=rss-95bdc513a8ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff970ce0de65</guid>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-ai]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Swaroop Reddy]]></dc:creator>
            <pubDate>Mon, 23 Nov 2026 07:44:04 GMT</pubDate>
            <atom:updated>2026-11-23T07:44:04.555Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b1OK-oTkPGSFCrR9amwbqQ.png" /><figcaption>Cover image created with AI.</figcaption></figure><p>I asked my little help-centre bot a simple question:</p><blockquote>“When will I get the cash my customers paid the delivery boy?”</blockquote><p>It answered, confidently:</p><blockquote>“Cash on Delivery is available for parcels with a declared value up to ₹20,000. The receiver can pay in cash or by UPI to the delivery partner. Therefore, the customers will get the cash they paid…”</blockquote><p>Wrong. The question is about <strong>COD payouts to the seller</strong>, and the knowledge base has a passage that answers it exactly: <em>transferred every Tuesday and Friday, minus a 1.5% handling charge.</em> Vector search just never showed that passage to the LLM. It found “COD limits” instead — same words, different question — and the LLM made the rest up.</p><p>This is how most RAG bots fail: not by hallucinating from nothing, but by answering from the <em>almost-right</em> passage.</p><p>So when a new reranker landed in Spring AI, I didn’t want another feature tour. I wanted to know one thing: does it actually fix this on my own data — not on a vendor benchmark?</p><p><strong>Spring AI 2.1.0 went GA on November 20, 2026</strong> with a new <strong>Decision Model</strong> API and a ready-made DecisionDocumentReranker for exactly this problem. I wired it into a small RAG app, labelled 20 test questions, and measured it — fully local with Ollama, no API key.</p><p><strong>Stack:</strong> Spring Boot 4.2 · Spring AI 2.1.0 · Java 17 · PostgreSQL 17 + pgvector · Ollama. Full code at the end.</p><h3>The short version</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tg_I3fPGIUSPctBD8wTHBQ.png" /></figure><ul><li><strong>Vector search only:</strong> right passage first in 14/20 (70%), in the top 3 in 18/20 (90%), ~0.2 s per question</li><li><strong>+ reranker with </strong><strong>d1-omni:600m (the default):</strong> first in <strong>5/20 (25%)</strong>, top 3 in <strong>10/20 (50%)</strong>, 9.2 s per question</li><li><strong>+ reranker with </strong><strong>d1 (2.7B):</strong> first in <strong>20/20 (100%)</strong>, top 3 in <strong>20/20 (100%)</strong>, 56 s per question</li></ul><p><em>CPU only — Intel i7–12700H, 40 GB RAM, no discrete GPU.</em></p><ul><li>With the <strong>default small model</strong>, reranking made retrieval much <strong>worse</strong>.</li><li>With a <strong>bigger decision model</strong>, it was <strong>perfect</strong> on every question — but painfully slow on a laptop CPU.</li></ul><p>The rest of this post is how it works, how to set it up, and what I’d actually do in production.</p><h3>Why vector search picks the wrong passage</h3><p>Vector search compares the embedding of the question with the embedding of each passage. Embeddings capture <em>what a text is about</em> — good for finding the right neighbourhood, weak at fine distinctions. My test data (a fictional courier help centre, “QuickParcel”) is full of near-neighbours on purpose:</p><ul><li><strong>COD limits</strong> vs <strong>COD payouts</strong></li><li><strong>refund for damaged parcels</strong> vs <strong>compensation for late parcels</strong></li><li><strong>insurance</strong> vs <strong>refund for lost parcels</strong></li></ul><p>A <strong>reranker</strong> adds a second pass: fetch a wider set of candidates, then ask a model, for each one, <em>“does this passage actually answer the question?”</em> — and reorder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*29SdJYsKll9mG8LwATjapw.png" /></figure><h3>What’s a Decision Model?</h3><p>Spring AI 2.1 adds DecisionModel, an API for <strong>typed decisions</strong> — yes/no, multiple choice, scores — each returned with a <strong>probability</strong>:</p><pre>DecisionResponse response = decisionModel.call(DecisionPrompt.builder()<br>        .text(&quot;When will I get the cash my customers paid the delivery boy?&quot;)<br>        .question(&quot;topic&quot;, ChoiceQuestion.of(&quot;What is the message about?&quot;,<br>                &quot;delivery&quot;, &quot;payment&quot;, &quot;account&quot;, &quot;other&quot;))<br>        .build());</pre><pre>String topic = response.getChoice(&quot;topic&quot;).getValue();</pre><p>The reranker builds on this: for every candidate it asks a yes/no relevance question and sorts by the <strong>probability of “yes”</strong>. A probability ranks far better than an LLM replying “Yes.” in free text.</p><p>Providers in 2.1: OpenAI, Ollama and System One. I used <strong>Ollama</strong>, so embeddings, reranking and answers all run on a laptop — no API key, no bill.</p><h3>The setup</h3><pre>dependencyManagement {<br>    imports { mavenBom &#39;org.springframework.ai:spring-ai-bom:2.1.0&#39; }<br>}</pre><pre>dependencies {<br>    implementation &#39;org.springframework.boot:spring-boot-starter-web&#39;<br>    implementation &#39;org.springframework.ai:spring-ai-starter-model-ollama&#39;<br>    implementation &#39;org.springframework.ai:spring-ai-starter-vector-store-pgvector&#39;<br>    implementation &#39;org.springframework.ai:spring-ai-rag&#39;<br>}</pre><p>Spring AI 2.1 needs <strong>Spring Boot 4.2</strong> and Java 17+. Ollama decision models need <strong>Ollama 0.40.4 or newer</strong> — I had 0.34 and had to upgrade first.</p><p>application.yml — three local models, one per job:</p><pre>spring:<br>  datasource:<br>    url: jdbc:postgresql://localhost:5433/rag<br>    username: postgres<br>    password: postgres<br>  ai:<br>    model:<br>      chat: ollama<br>      embedding: ollama<br>      decision: ollama<br>    ollama:<br>      chat:<br>        model: qwen2.5:3b          # answers the user<br>      embedding:<br>        model: nomic-embed-text    # 768-dim embeddings<br>      decision:<br>        model: d1                  # the reranker&#39;s model — see results for why not the default<br>      init:<br>        pull-model-strategy: when_missing<br>    vectorstore:<br>      pgvector:<br>        initialize-schema: true<br>        dimensions: 768<br>        index-type: HNSW<br>        distance-type: COSINE_DISTANCE</pre><p>Things that bit me on the first run:</p><ul><li><strong>initialize-schema is off by default.</strong> Without it: &quot;relation vector_store does not exist&quot;.</li><li><strong>dimensions must match the embedding model</strong> — 768 for nomic-embed-text.</li><li><strong>Port 5432 was taken</strong> by a PostgreSQL already installed on my machine, so the app connected to the wrong database and failed with “password authentication failed”. I mapped the pgvector container to <strong>5433</strong> instead.</li><li><strong>d1-omni:2b needs Apple&#39;s MLX runtime</strong>, so on Windows it simply won&#39;t pull. On a Windows/Linux machine your options are d1-omni:600m or d1.</li></ul><h3>Wiring the reranker</h3><p>Two retrievers — a narrow one for the baseline, a wide one that feeds the reranker:</p><pre>public static final int FINAL_K = 3;       // passages the LLM finally sees<br>public static final int CANDIDATE_K = 15;  // candidates fetched before reranking</pre><pre>@Bean<br>VectorStoreDocumentRetriever baselineRetriever(VectorStore vectorStore) {<br>    return VectorStoreDocumentRetriever.builder()<br>            .vectorStore(vectorStore)<br>            .topK(FINAL_K)<br>            .build();<br>}</pre><pre>@Bean<br>VectorStoreDocumentRetriever candidateRetriever(VectorStore vectorStore) {<br>    return VectorStoreDocumentRetriever.builder()<br>            .vectorStore(vectorStore)<br>            .topK(CANDIDATE_K)<br>            .build();<br>}</pre><p>The reranker:</p><pre>@Bean<br>DecisionDocumentReranker reranker(DecisionModel decisionModel) {<br>    return DecisionDocumentReranker.builder(decisionModel)<br>            .topK(FINAL_K)<br>            .concurrency(8)        // one model call per candidate passage<br>            .build();<br>}</pre><p>It plugs into the standard RetrievalAugmentationAdvisor as a <strong>document post-processor</strong>:</p><pre>@Bean<br>ChatClient rerankedChat(ChatModel chatModel,<br>                        VectorStoreDocumentRetriever candidateRetriever,<br>                        DecisionDocumentReranker reranker) {<br>    return ChatClient.builder(chatModel)<br>            .defaultAdvisors(RetrievalAugmentationAdvisor.builder()<br>                    .documentRetriever(candidateRetriever)<br>                    .documentPostProcessors(reranker)<br>                    .build())<br>            .build();<br>}</pre><p>That’s the whole change. To see which passages the LLM got — and their scores — read them back from the response context:</p><pre>ChatClientResponse response = client.prompt().user(q).call().chatClientResponse();</pre><pre>List&lt;Document&gt; used = (List&lt;Document&gt;) response.context()<br>        .getOrDefault(RetrievalAugmentationAdvisor.DOCUMENT_CONTEXT, List.of());</pre><pre>Object score = used.get(0).getMetadata().get(DecisionDocumentReranker.SCORE_METADATA_KEY);</pre><h3>How I measured it</h3><p>The demo has an /eval endpoint that checks <strong>retrieval only</strong> — no LLM judge. Each of the 20 questions is labelled with the passage that holds the answer, and I check whether that passage is ranked first (top-1) or anywhere in the 3 the LLM sees (top-3):</p><pre>Query query = new Query(q.question());</pre><pre>List&lt;String&gt; base = ids(baselineRetriever.retrieve(query));<br>List&lt;String&gt; rr   = ids(reranker.process(query, candidateRetriever.retrieve(query)));</pre><p>The questions are written the way customers write — <em>“Can I send a spare power bank by itself?”</em>, not <em>“lithium battery policy”</em> — because that wording gap is exactly where embeddings struggle.</p><p>The raw output of every run (both eval runs and the side-by-side answers) is in the repo’s proofs/ folder, so you can check every number below.</p><h3>Results, in detail</h3><h3>1. The default model made things worse</h3><p>With d1-omni:600m — the default in Spring AI&#39;s Ollama config — top-1 accuracy <strong>dropped from 70% to 25%</strong>. Its relevance scores were low and close together, so it reordered passages almost at random. For the question about a late Express parcel, the right passage still came first, but with a score of only <strong>0.19</strong>, and the next two picks were unrelated passages (online-store returns, weight disputes).</p><p>Spring’s own docs hint at this: small decision models <em>“depend a lot on the descriptions of the options.”</em> A generic “is this passage relevant?” question is hard for a 600M model.</p><h3>2. The bigger model was perfect</h3><p>With d1 (2.7B parameters), <strong>all 20 questions</strong> had the right passage ranked first — including the 6 that vector search got wrong. The COD-payout question from the intro:</p><p><strong>Vector search only</strong> — passages the LLM saw: cod-limits, compensation-late, refund-damaged. Answer:</p><blockquote>“…the customers will get the cash they paid to the delivery boy if they choose to pay in cash upon receiving the parcel.”<em> ❌</em></blockquote><p><strong>With the reranker (d1)</strong> — passages: <strong>cod-remittance (score 0.76)</strong>, pickup-schedule (0.13), refund-damaged (0.07). Answer:</p><blockquote>“COD amounts collected from receivers are transferred to the sender’s bank account every Tuesday and Friday, minus a 1.5% handling charge.”<em> ✅</em></blockquote><p>Notice the score gap: 0.76 for the right passage, 0.13 for the next. That’s what a confident reranker looks like — and it’s also a signal you can use (more on that below).</p><h3>3. The catch: time</h3><p>On my laptop CPU, reranking with d1 took <strong>56 seconds per question</strong> — 15 model calls, one per candidate. The whole 20-question eval took <strong>19 minutes</strong>. The small model took 9 seconds per question and gave worse results.</p><p>For a live support chat, 56 seconds on a laptop CPU is a non-starter. But the accuracy jump is real — every one of the six questions vector search got wrong came back right. So my verdict: not something to run on CPU, but absolutely worth testing on a GPU box or a hosted decision model, where the same 15 calls take a fraction of the time.</p><h3>What I’d do in production</h3><ul><li><strong>Don’t trust the default model blindly — measure.</strong> A 20-question labelled set took me 15 minutes to write and immediately showed the default model was hurting.</li><li><strong>Run the decision model on a GPU, or use a hosted provider.</strong> The same 15 calls per question that take ~56 s on a laptop CPU are a very different story on a GPU or OpenAI’s decision endpoint — but then it costs money per call, so measure that too.</li><li><strong>Fetch fewer candidates.</strong> 15 is generous. Vector search already had the right passage in its top 3 for 18/20 questions, so 5–8 candidates would cut the work roughly in half. Re-run the eval to confirm.</li><li><strong>Use </strong><strong>minimumScore.</strong> With d1, right answers scored high and wrong ones low. Dropping passages below a threshold sends the LLM less noise — and if <em>nothing</em> passes, say &quot;I don&#39;t know&quot; instead of guessing.</li><li><strong>Filter first, then rank.</strong> Spring AI 2.1 also ships DecisionDocumentFilter (relevance, contradiction and prompt-injection checks). The Spring docs recommend running it before the reranker so fewer passages need scoring.</li><li><strong>Watch for “fails open”.</strong> If a decision call times out, the reranker keeps the passage unscored and logs a warning. Good for uptime — but alert on it, or an outage quietly turns your reranker back into plain vector search.</li></ul><h3>Takeaways</h3><ul><li>Spring AI 2.1 makes reranking a <strong>three-line change</strong> in a Spring Boot RAG app.</li><li><strong>The model behind it decides everything:</strong> on my data the default small model cut accuracy from 70% to 25%; a 2.7B model took it to 100%.</li><li><strong>Reranking trades time for accuracy.</strong> On a laptop CPU it’s far too slow for live chat; on proper hardware or a hosted API it’s worth testing seriously.</li><li><strong>Measure on your own data.</strong> Twenty labelled questions were enough to show a big swing in both directions.</li></ul><p>Next in this series: exposing this help-centre bot to AI assistants as an <strong>MCP server</strong> with Spring AI 2.1.</p><p>Full code and raw results: <a href="https://github.com/swaroop1232010/spring-ai-reranker-demo">https://github.com/swaroop1232010/spring-ai-reranker-demo</a></p><p>Sources: <a href="https://spring.io/blog/2026/11/20/spring-ai-2-1-0-GA-available-now/">Spring AI 2.1.0 GA announcement</a> · <a href="https://docs.spring.io/spring-ai/reference/2.1-SNAPSHOT/models/decision.html">Spring AI Decision Model docs</a> · <a href="https://docs.spring.io/spring-ai/reference/2.1-SNAPSHOT/integrations/models/ollama/decision.html">Ollama decision models in Spring AI</a> · <a href="https://docs.spring.io/spring-ai/reference/2.1-SNAPSHOT/rag/modules.html">Spring AI modular RAG docs</a> · <a href="https://ollama.com/library/d1-omni">d1-omni on Ollama</a></p><p><em>Every experiment here ran on my own laptop, and the raw results are in the repo’s </em><em>proofs/ folder. This article was written with substantial help from AI tools (research, code and drafting) and reviewed by me. Cover image created with AI.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff970ce0de65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Real-Time Delivery Tracking System Using Kafka with Spring Boot and React JS]]></title>
            <link>https://medium.com/@swaroop1232010/building-a-real-time-delivery-tracking-system-using-kafka-with-spring-boot-and-react-js-6aa2779081f6?source=rss-95bdc513a8ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/6aa2779081f6</guid>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[kafka-producer]]></category>
            <category><![CDATA[spring-kafka]]></category>
            <category><![CDATA[kafka-consumer]]></category>
            <dc:creator><![CDATA[Swaroop Reddy]]></dc:creator>
            <pubDate>Tue, 24 Sep 2024 05:50:22 GMT</pubDate>
            <atom:updated>2024-09-24T05:50:22.345Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NF94Szwma_F9y9p05vW15g.png" /></figure><h3>Introduction to Real-Time Delivery Tracking with Kafka, Spring Boot, and React JS</h3><p>In today’s fast-paced world, real-time data processing is a critical component for many applications, from ride-hailing services to food delivery platforms. One of the key challenges is efficiently managing and tracking events, such as updating and displaying the real-time location of a delivery driver. This is where Apache Kafka, a powerful event streaming platform, shines.</p><p>In this article, we will explore how to build a <strong>sample real-time delivery tracking system by integrating Apache Kafka with Spring Boot and React JS</strong>. Kafka will serve as the backbone for sending real-time location data between two microservices: one representing the driver, who shares their location, and the other for the user, who tracks it. The frontend, built with React, will display these real-time location updates on a Google Map, providing an interactive experience for users.</p><p>We will guide you through setting up <strong>Kafka and zookeeper </strong>with <strong>Docker</strong>, creating <strong>two Spring Boot microservices </strong>that produce and consume location events, and building a React-based frontend that visualizes the driver’s real-time location on a map. By the end of this tutorial, you’ll have a fully functioning delivery tracking system and a deeper understanding of how Kafka can be used to build scalable, real-time applications.</p><p><strong>Step 1: Setting Up Kafka with Docker Compose</strong></p><p>Before integrating Kafka into Spring Boot, you need to set up Kafka and Zookeeper locally. The easiest way to do this is by using Docker Compose. Here’s the docker-compose.yml file that you can use:</p><pre>version: &quot;3&quot;<br>services:<br>  zookeeper:<br>    image: &#39;bitnami/zookeeper:latest&#39;<br>    container_name: zookeeper<br>    ports:<br>      - &#39;2181:2181&#39;<br>    environment:<br>      - ALLOW_ANONYMOUS_LOGIN=yes<br><br>  kafka:<br>    image: &#39;bitnami/kafka:latest&#39;<br>    container_name: kafka<br>    ports:<br>      - &#39;9092:9092&#39;<br>    environment:<br>      - KAFKA_BROKER_ID=1<br>      - KAFKA_LISTENERS=PLAINTEXT://:9092<br>      - KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092<br>      - KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181<br>      - ALLOW_PLAINTEXT_LISTENER=yes<br>    depends_on:<br>      - zookeeper</pre><p>To start Kafka and Zookeeper, run the following command:</p><pre>docker-compose -f docker-compose.yml up -d</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0tteyJjrnoimvDnrjgabhg.png" /></figure><p>This will launch both Kafka and Zookeeper in the background. Now, Kafka is ready to process events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W6Ym240yMOA1OKDYjCCDtQ.png" /></figure><p><strong>Step 2: Creating Two Spring Boot Projects for Driver and User</strong></p><p>We will create two Spring Boot applications:</p><ol><li><strong>Driver Application</strong>: Simulates the driver’s location updates.</li><li><strong>User Application</strong>: Tracks the driver’s location in real time.</li></ol><p>Both applications will have Kafka integration to send and receive events.</p><h4>Generate Spring Boot Projects</h4><ul><li>Go to <a href="https://start.spring.io/">Spring Initializr</a>.</li><li>For <strong>both projects</strong>, select the following dependencies: Spring Web and Spring for Apache Kafka.</li><li>Download both projects and import them into Eclipse.</li><li>Your both build.gradle files looks like:</li></ul><pre>plugins {<br> id &#39;java&#39;<br> id &#39;org.springframework.boot&#39; version &#39;3.3.4&#39;<br> id &#39;io.spring.dependency-management&#39; version &#39;1.1.6&#39;<br>}<br><br>group = &#39;com.swaroop&#39;<br>version = &#39;0.0.1-SNAPSHOT&#39;<br><br>java {<br> toolchain {<br>  languageVersion = JavaLanguageVersion.of(17)<br> }<br>}<br><br>repositories {<br> mavenCentral()<br>}<br><br>dependencies {<br> implementation &#39;org.springframework.boot:spring-boot-starter-web&#39;<br> implementation &#39;org.springframework.kafka:spring-kafka&#39;<br> testImplementation &#39;org.springframework.boot:spring-boot-starter-test&#39;<br> testImplementation &#39;org.springframework.kafka:spring-kafka-test&#39;<br> testRuntimeOnly &#39;org.junit.platform:junit-platform-launcher&#39;<br>}<br><br>tasks.named(&#39;test&#39;) {<br> useJUnitPlatform()<br>}</pre><p><strong>Step 3: Writing the Driver Application Code</strong></p><p>In the <strong>Driver </strong>project, we’ll create a Kafka topic for the driver’s location updates. The driver will periodically send its location to this topic.</p><p><strong>Project Structure</strong></p><ul><li>Create the following packages: controller, service, config, and constant.</li></ul><p><strong>1. Configuration: Create Kafka Topic</strong></p><p>First, we need to configure Kafka to create a topic. Add the following code to the KafkaConfig class inside the config package:</p><pre>package com.swaroop.springboot_kafka_delivery_driver.config;<br><br>import org.apache.kafka.clients.admin.NewTopic;<br>import org.springframework.context.annotation.Bean;<br>import org.springframework.context.annotation.Configuration;<br>import org.springframework.kafka.config.TopicBuilder;<br><br>import com.swaroop.springboot_kafka_delivery_driver.constant.AppConstant;<br><br>@Configuration<br>public class KafkaConfig {<br><br> @Bean<br> public NewTopic topic() {<br>  return TopicBuilder.name(AppConstant.DELIVERY_LOCATION).build();<br> }<br>}</pre><p>We define the topic name in a constants file</p><p>Add the following code to the AppConstant class inside constant package:</p><pre>package com.swaroop.springboot_kafka_delivery_driver.constant;<br><br>public class AppConstant {<br> public static final String DELIVERY_LOCATION = &quot;delivery-location&quot;;<br>}</pre><p><strong>2. Delivery Location Service: Sending Location Updates</strong></p><p>Next, implement the service that sends the driver’s location updates to Kafka. Add the following code in the DeliveryLocationService class under the service package:</p><pre>package com.swaroop.springboot_kafka_delivery_driver.service;<br><br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.kafka.core.KafkaTemplate;<br>import org.springframework.stereotype.Service;<br><br>import com.swaroop.springboot_kafka_delivery_driver.constant.AppConstant;<br><br>@Service<br>public class DeliveryLocationService {<br><br> @Autowired<br> private KafkaTemplate&lt;String, Object&gt; kafkaTemplate;<br><br> public boolean updateLocation(String location) {<br>  kafkaTemplate.send(AppConstant.DELIVERY_LOCATION, location);<br>  return true;<br> }<br>}</pre><p><strong>3. Controller: Exposing APIs to Update and Fetch Location</strong></p><p>In the controller package, create a DeliveryLocationController class that simulates the driver’s location updates:</p><pre>package com.swaroop.springboot_kafka_delivery_driver.controller;<br><br>import java.util.Map;<br><br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.http.HttpStatus;<br>import org.springframework.http.ResponseEntity;<br>import org.springframework.web.bind.annotation.CrossOrigin;<br>import org.springframework.web.bind.annotation.GetMapping;<br>import org.springframework.web.bind.annotation.PutMapping;<br>import org.springframework.web.bind.annotation.RequestMapping;<br>import org.springframework.web.bind.annotation.RestController;<br><br>import com.swaroop.springboot_kafka_delivery_driver.service.DeliveryLocationService;<br><br>@RestController<br>@RequestMapping(&quot;/location&quot;)<br>@CrossOrigin(origins = &quot;http://localhost:3000&quot;)<br>public class DeliveryLocationController {<br><br> @Autowired<br> private DeliveryLocationService deliveryLocationService;<br><br> @GetMapping<br> public ResponseEntity&lt;Map&lt;String, String&gt;&gt; getCurrentLocation() {<br>  // Simulating a location between New York and New Jersey<br>  double nycLat = 40.7128;<br>  double nycLon = -74.0060;<br>  double njLat = 40.7357;<br>  double njLon = -74.1724;<br><br>  double randomLat = nycLat + Math.random() * (njLat - nycLat);<br>  double randomLon = nycLon + Math.random() * (njLon - nycLon);<br><br>  String location = randomLat + &quot; , &quot; + randomLon;<br><br>  return new ResponseEntity&lt;&gt;(Map.of(&quot;location&quot;, location), HttpStatus.OK);<br> }<br><br> @PutMapping<br> public ResponseEntity updateLocation() throws InterruptedException {<br><br>  double nycLat = 40.7128;<br>  double nycLon = -74.0060;<br>  double njLat = 40.7357;<br>  double njLon = -74.1724;<br><br>  int range = 100;<br>  while (range &gt; 0) {<br>   // Generate random location between New York City and New Jersey<br>   double randomLat = nycLat + Math.random() * (njLat - nycLat);<br>   double randomLon = nycLon + Math.random() * (njLon - nycLon);<br><br>   String location = randomLat + &quot; , &quot; + randomLon;<br>   deliveryLocationService.updateLocation(location);<br><br>   Thread.sleep(1000); // Sleep for 1 second<br>   range--;<br>  }<br><br>  return new ResponseEntity&lt;&gt;(Map.of(&quot;message&quot;, &quot;Location Updated&quot;), HttpStatus.OK);<br> }<br><br>}</pre><p><strong>4. Application Properties</strong></p><p>Configure the Kafka producer in the application.properties:</p><pre>server.port=8082<br>spring.kafka.producer.bootstrap-servers=localhost:9092<br>spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer<br>spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer</pre><p><strong>Step 4: Now, write the User Project Code</strong></p><p>The <strong>User Project</strong> will consume the location data sent by the driver project.</p><p><strong>Project Structure</strong></p><ul><li>Create a service package.</li></ul><ol><li><strong>Location Service: Consuming Location Data</strong></li></ol><p>In the LocationService class under the service package, add the following code to consume messages from Kafka:</p><pre>package com.swaroop.springboot_kafka_delivery_user.service;<br><br>import org.springframework.kafka.annotation.KafkaListener;<br>import org.springframework.stereotype.Service;<br><br>@Service<br>public class LocationService {<br><br> @KafkaListener(topics = &quot;delivery-location&quot;, groupId = &quot;user-group&quot;)<br> public void deliveryLocation(String location) {<br>  System.out.println(location);<br> }<br>}</pre><p>This service listens to the delivery-location topic and prints the location to the console.</p><p><strong>2. Application Properties</strong></p><p>Configure the Kafka consumer in the application.properties:</p><pre>server.port=8081<br>spring.kafka.consumer.bootstrap-servers=localhost:9092<br>spring.kafka.consumer.key-serializer=org.apache.kafka.common.serialization.StringSerializer<br>spring.kafka.consumer.value-serializer=org.apache.kafka.common.serialization.StringSerializer<br>spring.kafka.consumer.group-id=user-group<br># spring.kafka.consumer.auto-offset-reset=earliest # Uncomment to consume from the beginning</pre><p><strong>Step 5: Running the Application</strong></p><p>Now that both services are ready, you can start both Spring Boot applications.</p><ol><li><strong>Start Kafka</strong>: Ensure that Kafka and Zookeeper are running using Docker.</li><li><strong>Run the Driver Project</strong>: Start the springboot_kafka_delivery_driver application. It will generate random locations and send them to Kafka.</li><li><strong>Run the User Project</strong>: Start the springboot_kafka_delivery_user application. It will consume and print the location data sent by the driver service.</li></ol><p>You can view the location updates in the console output of the User Project in ecllipse.</p><p><strong>Optional:</strong> Also, test the location API in postman with PutMappingn</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*13IvgXQ5J8TXYrvsYSUoPA.png" /></figure><p><strong>Step 6: Displaying Real-Time Delivery Location in React</strong></p><p>Now that we have the backend set up with Spring Boot and Kafka, it’s time to create a frontend using React to display the real-time location of the driver on a Google Map.</p><ol><li><strong>Create a New React App</strong></li></ol><p>Run the following command to create a new React app:</p><pre>npx create-react-app real-time-location<br>cd real-time-location</pre><p><strong>2. Install Dependencies</strong></p><p>First, install the required dependencies for Google Maps in your React application:</p><pre>npm install @react-google-maps/api</pre><p><strong>3. MapComponent: Displaying Driver’s Location</strong></p><p>Create a MapComponent under src/components that will render the map and display the driver’s location using Google Maps. This component will fetch the location from the driver service at regular intervals to simulate real-time movement.</p><pre>import React, { useEffect, useState } from &quot;react&quot;;<br>import { GoogleMap, Marker, LoadScript } from &quot;@react-google-maps/api&quot;;<br>import vehicleIcon from &quot;../assets/vehicle-icon.png&quot;; // Custom vehicle icon<br><br>const containerStyle = {<br>  width: &quot;100%&quot;,<br>  height: &quot;400px&quot;,<br>};<br><br>// Center of the map, somewhere between New York and New Jersey<br>const center = {<br>  lat: 40.71836,<br>  lng: -74.1040,<br>};<br><br>const MapComponent = () =&gt; {<br>  const [currentLocation, setCurrentLocation] = useState(null);<br><br>  // Function to fetch current location from the backend<br>  const fetchLocation = () =&gt; {<br>    fetch(&quot;http://localhost:8082/location&quot;)<br>      .then((response) =&gt; response.json())<br>      .then((data) =&gt; {<br>        const [lat, lng] = data.location.split(&quot;,&quot;).map(Number);<br>        setCurrentLocation({ lat, lng });<br>      })<br>      .catch((error) =&gt; console.error(&quot;Error fetching location:&quot;, error));<br>  };<br><br>  useEffect(() =&gt; {<br>    // Fetch the location every second to simulate real-time movement<br>    const interval = setInterval(fetchLocation, 1000);<br>    return () =&gt; clearInterval(interval);<br>  }, []);<br><br>  return (<br>    &lt;LoadScript googleMapsApiKey=&quot;YOUR_GOOGLE_MAPS_API_KEY&quot;&gt;<br>      &lt;GoogleMap mapContainerStyle={containerStyle} center={center} zoom={10}&gt;<br>        {currentLocation &amp;&amp; (<br>          &lt;Marker<br>            position={currentLocation}<br>            icon={{<br>              url: vehicleIcon,<br>              scaledSize: new window.google.maps.Size(50, 50),<br>            }}<br>          /&gt;<br>        )}<br>      &lt;/GoogleMap&gt;<br>    &lt;/LoadScript&gt;<br>  );<br>};<br><br>export default MapComponent;</pre><ul><li>The fetchLocation function makes an HTTP call to the driver service (http://localhost:8082/location) every second to get the driver’s updated location.</li><li>The location is then rendered on the map using a Marker icon, which represents the vehicle.</li></ul><p>Make sure to replace &quot;YOUR_GOOGLE_MAPS_API_KEY&quot; with your actual Google Maps API key.</p><p><strong>4. App Component: Rendering the Map</strong></p><p>In your App.js, import the MapComponent and render it:</p><pre>import React from &quot;react&quot;;<br>import &quot;./App.css&quot;;<br>import MapComponent from &quot;./components/MapComponent&quot;;<br><br>function App() {<br>  return (<br>    &lt;div className=&quot;App&quot;&gt;<br>      &lt;h1&gt;Real-Time Delivery Location&lt;/h1&gt;<br>      &lt;MapComponent /&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;</pre><p><strong>5. Styling the App</strong></p><p>To make the map and UI look neat, add some basic styles in App.css:</p><pre>.App {<br>  font-family: Arial, sans-serif;<br>  text-align: center;<br>  padding: 20px;<br>}<br><br>h1 {<br>  margin-bottom: 20px;<br>}<br><br>#map {<br>  height: 400px;<br>  width: 100%;<br>}</pre><p><strong>Step 7: Running the Application</strong></p><ol><li><strong>Start the Backend Services</strong>: Ensure that Kafka, Zookeeper, and the Spring Boot Driver Service (springboot_kafka_delivery_driver) are running.</li><li><strong>Start the React Application</strong>: Run the following command to start the React app:</li></ol><pre>npm start</pre><p><strong>3. View the Application</strong>: Open your browser and navigate to http://localhost:3000. You will see the real-time location of the delivery driver displayed on the map.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FYeyQFA0V2um017Ku-ASYw.png" /></figure><p>Finally, to stop / remove the Kafka and ZooKeeper Docker containers, run the following command:</p><pre>docker-compose down</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6aa2779081f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Redis Caching in Spring Boot with Gradle: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@swaroop1232010/implementing-redis-caching-in-spring-boot-with-gradle-a-step-by-step-guide-876884df0bb6?source=rss-95bdc513a8ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/876884df0bb6</guid>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[redis-cache]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Swaroop Reddy]]></dc:creator>
            <pubDate>Wed, 04 Sep 2024 06:51:29 GMT</pubDate>
            <atom:updated>2024-09-04T06:51:29.744Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hFocV5hJha3DA-kiNNkmlg.jpeg" /></figure><p>In the fast-paced world of software development, performance is key. One way to optimize the performance of your Spring Boot application is by introducing caching, and Redis is an ideal choice for this. Redis is an in-memory data store that allows you to cache frequently accessed data and improve the overall efficiency of your APIs.</p><p>In this article, I will walk you through how to set up Redis caching in a Spring Boot application using <strong>Gradle</strong> for dependency management. We’ll implement a simple API for managing users, integrate Redis caching, and configure it for optimal performance.</p><h3><strong>Why Redis Caching?</strong></h3><p>Redis caching offers several benefits:</p><ul><li><strong>Performance</strong>: Data retrieval from memory is much faster than querying the database.</li><li><strong>Scalability</strong>: Redis can handle a large number of reads and writes with low latency.</li><li><strong>Persistence</strong>: Although it’s an in-memory store, Redis can persist data to disk for recovery after crashes.</li></ul><p>Let’s dive into the implementation.</p><h3><strong>Project Setup</strong></h3><p><strong>Step 1: Create a Spring Boot Application with Gradle</strong></p><p>Let’s start by creating a new Spring Boot application. You can use <strong>Spring Initializer</strong> or create it manually with the following build.gradle file:</p><pre>plugins {<br>    id &#39;java&#39;<br>    id &#39;org.springframework.boot&#39; version &#39;3.3.3&#39;<br>    id &#39;io.spring.dependency-management&#39; version &#39;1.1.6&#39;<br>}<br><br>group = &#39;com.swaroop&#39;<br>version = &#39;0.0.1-SNAPSHOT&#39;<br><br>java {<br>    toolchain {<br>        languageVersion = JavaLanguageVersion.of(17)<br>    }<br>}<br><br>repositories {<br>    mavenCentral()<br>}<br><br>dependencies {<br>    implementation &#39;org.springframework.boot:spring-boot-starter-data-jpa&#39;<br>    implementation &#39;org.springframework.boot:spring-boot-starter-data-redis&#39;<br>    implementation &#39;org.springframework.boot:spring-boot-starter-web&#39;<br>    implementation &#39;org.springframework.boot:spring-boot-starter-cache&#39;<br><br>    compileOnly &#39;org.projectlombok:lombok&#39;<br>    annotationProcessor &#39;org.projectlombok:lombok&#39;<br><br>    runtimeOnly &#39;com.mysql:mysql-connector-j&#39;<br><br>    // Embedded Redis for testing<br>    testImplementation &#39;it.ozimov:embedded-redis:0.7.3&#39;<br>    <br>    testImplementation &#39;org.springframework.boot:spring-boot-starter-test&#39;<br>}<br><br>tasks.named(&#39;test&#39;) {<br>    useJUnitPlatform()<br>}</pre><p>This build.gradle file sets up:</p><ul><li><strong>Spring Boot dependencies</strong> for web, data JPA, Redis, and caching.</li><li><strong>Lombok</strong> for boilerplate code reduction.</li><li><strong>MySQL</strong> as our relational database.</li><li><strong>JUnit</strong> for testing.</li></ul><p><strong>Step 2: Redis and MySQL Configuration</strong></p><p>To configure MySQL and Redis, add the following properties to your application.properties:</p><pre># Spring Application Name and Server Port<br>spring.application.name=your_project_name<br>server.port=your_port<br><br># MySQL configuration<br>spring.datasource.url=jdbc:mysql://localhost:3306/db_name<br>spring.datasource.username=db_username<br>spring.datasource.password=db_password<br>spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver<br><br># Hibernate configuration<br><br>spring.jpa.hibernate.ddl-auto=update<br>spring.jpa.show-sql=true<br><br># Redis configuration<br>spring.redis.host=localhost<br>spring.redis.port=6379<br><br># Enable caching<br>spring.cache.type=redis</pre><p>These configurations:</p><ul><li>Set up a MySQL database.</li><li>Enable Redis as the caching solution.</li><li>Configure Hibernate to handle database interactions.</li></ul><p><strong>Entity and Repository</strong></p><p>Let’s create a simple User entity and a repository to handle CRUD operations.</p><p><strong>Step 3: User Entity</strong></p><pre>package com.swaroop.entity;<br><br>import jakarta.persistence.Entity;<br>import jakarta.persistence.GeneratedValue;<br>import jakarta.persistence.GenerationType;<br>import jakarta.persistence.Id;<br>import jakarta.persistence.Table;<br>import lombok.AllArgsConstructor;<br>import lombok.Data;<br>import lombok.NoArgsConstructor;<br><br>@Data<br>@AllArgsConstructor<br>@NoArgsConstructor<br>@Entity<br>@Table(name = &quot;users&quot;)<br>public class User {<br>    @Id<br>    @GeneratedValue(strategy = GenerationType.IDENTITY)<br>    private Long id;<br><br>    private String name;<br>    private String email;<br>}</pre><p>Here we define the User entity with id, name, and email fields, and use Lombok to reduce boilerplate code like getters, setters, constructors, etc.</p><p><strong>Step 4: UserRepository Interface</strong></p><pre>package com.swaroop.repository;<br><br>import org.springframework.data.jpa.repository.JpaRepository;<br>import com.swaroop.entity.User;<br><br>public interface UserRepository extends JpaRepository&lt;User, Long&gt; {<br>}</pre><p>The UserRepository extends JpaRepository to provide built-in CRUD functionality.</p><p><strong>Implementing Redis Caching</strong></p><p><strong>Step 5: Service Layer with Redis Caching</strong></p><p>The service layer is where we implement the caching logic. We’ll use Spring’s caching annotations (<strong>@Cacheable, </strong><strong>@CachePut, </strong><strong>@CacheEvict</strong>) to control how data is cached, updated, and evicted.</p><pre>package com.swaroop.service;<br><br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.cache.annotation.CacheEvict;<br>import org.springframework.cache.annotation.CachePut;<br>import org.springframework.cache.annotation.Cacheable;<br>import org.springframework.stereotype.Service;<br><br>import com.swaroop.entity.User;<br>import com.swaroop.repository.UserRepository;<br><br>import java.util.List;<br><br>@Service<br>public class UserService {<br><br>    @Autowired<br>    private UserRepository userRepository;<br><br>    @Cacheable(value = &quot;users&quot;, key = &quot;&#39;allUsers&#39;&quot;)<br>    public List&lt;User&gt; findAllUsers() {<br>        return userRepository.findAll();<br>    }<br><br>    @Cacheable(value = &quot;users&quot;, key = &quot;#id&quot;)<br>    public User getUserById(Long id) {<br>        return userRepository.findById(id).orElseThrow(() -&gt; new RuntimeException(&quot;User not found with id: &quot; + id));<br>    }<br><br>    @CachePut(value = &quot;users&quot;, key = &quot;#result.id&quot;)<br>    public User saveUser(User user) {<br>        return userRepository.save(user);<br>    }<br><br>    @CacheEvict(value = &quot;users&quot;, key = &quot;#id&quot;)<br>    public void deleteUser(Long id) {<br>        userRepository.deleteById(id);<br>    }<br>}</pre><ul><li><strong>@Cacheable</strong>: Caches the result of a method so that future calls return the cached data without querying the database.</li><li><strong>@CachePut</strong>: Updates the cache after modifying the data (e.g., saving a user).</li><li><strong>@CacheEvict</strong>: Evicts cache entries when data is deleted.</li></ul><p><strong>Step 6: REST Controller for API Endpoints</strong></p><p>Finally, let’s expose these services via a REST controller.</p><pre>package com.swaroop.controller;<br><br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.http.HttpStatus;<br>import org.springframework.http.ResponseEntity;<br>import org.springframework.web.bind.annotation.*;<br><br>import com.swaroop.entity.User;<br>import com.swaroop.service.UserService;<br><br>import java.util.List;<br><br>@RestController<br>@RequestMapping(&quot;/users&quot;)<br>public class UserController {<br><br>    @Autowired<br>    private UserService userService;<br><br>    @GetMapping<br>    public ResponseEntity&lt;List&lt;User&gt;&gt; getAllUsers() {<br>        List&lt;User&gt; users = userService.findAllUsers();<br>        return ResponseEntity.ok(users);<br>    }<br><br>    @GetMapping(&quot;/{id}&quot;)<br>    public ResponseEntity&lt;User&gt; getUserById(@PathVariable Long id) {<br>        User user = userService.getUserById(id);<br>        return user != null ? ResponseEntity.ok(user) : ResponseEntity.notFound().build();<br>    }<br><br>    @PostMapping<br>    public ResponseEntity&lt;User&gt; createUser(@RequestBody User user) {<br>        User savedUser = userService.saveUser(user);<br>        return ResponseEntity.status(HttpStatus.CREATED).body(savedUser);<br>    }<br><br>    @DeleteMapping(&quot;/{id}&quot;)<br>    public ResponseEntity&lt;Void&gt; deleteUser(@PathVariable Long id) {<br>        userService.deleteUser(id);<br>        return ResponseEntity.noContent().build();<br>    }<br>}</pre><p>This controller provides RESTful endpoints to:</p><ul><li>Retrieve all users (GET /users)</li><li>Retrieve a user by ID (GET /users/{id})</li><li>Create a new user (POST /users)</li><li>Delete a user (DELETE /users/{id})</li></ul><p><strong>Monitoring and Testing Redis</strong></p><p><strong>Step 7: Monitoring Redis with </strong><strong>redis-cli</strong></p><ul><li>Visit to the link to install <a href="https://github.com/tporadowski/redis/releases">Redis</a></li></ul><p>To monitor Redis operations, you can install <strong>Redis server</strong> and start running redis-server first. Once it&#39;s running, and run redis-cli to access the Redis command-line interface. To monitor real-time Redis operations, type in redis-cli:</p><pre>MONITOR</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*92xfVg-_onkGfMWEEoQh7g.png" /></figure><p>When you call the APIs, you’ll see GET, GET-BY-ID, SET, and DEL operations happening in Redis, confirming that caching is working.</p><p><strong>Step 8: Testing the API</strong></p><p>You can test the API using tools like <strong>Postman</strong> or <strong>curl</strong> to make requests and validate that Redis caching is functioning as expected.</p><ul><li><strong>GET /users</strong> will return all users and cache the result under the key allUsers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7a23TSW38CY2IzK2a2tyHg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jf1EKfUfvy2eZsUnpHxhYA.png" /></figure><ul><li><strong>GET /users/{id}</strong> will cache individual user data under a key based on the user’s ID.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JaH3R3qwlinRpPv3MVsVOQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*THnB_pS4y8MlCrwGX7Bfbg.png" /></figure><ul><li><strong>POST /users</strong> will save a user and update the cache.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wC73yBrBKVfMmaCJLsOCaA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ay2dd7BsmNSwKfaAm-PnAA.png" /></figure><ul><li><strong>DELETE /users/{id}</strong> will remove the user from the cache.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yiDr7-PlbPfH5tjG5S0Grw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0-es1t8xyEdjV0QWvvuzUg.png" /></figure><h3><strong>Solving Common Issues</strong></h3><h4>Issue: java.lang.IllegalArgumentException: Name for argument of type [java.lang.Long] not specified</h4><p>This issue occurs when the -parameters flag is not enabled in your project. In order to resolve this, ensure that the -parameters flag is added to your Java compiler options in your IDE (e.g., Eclipse).</p><p>In this case the solution is just to tick this option at the Java Compiler settings</p><p>In <strong>Eclipse</strong>, follow these steps:</p><ol><li>Right-click on your project and go to <strong>Properties</strong>.</li><li>Navigate to <strong>Java Compiler</strong> &gt; <strong>Compiler Options</strong>.</li><li>Add the -parameters flag in the <strong>Additional command line parameters</strong> box.</li><li>Rebuild your project.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WpF_9RwyOp07IPlm38wtiQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=876884df0bb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step-by-Step Guide to Setting Up SonarQube for Your Java Spring Boot Project on Windows.]]></title>
            <link>https://medium.com/@swaroop1232010/step-by-step-guide-to-setting-up-sonarqube-for-your-java-spring-boot-project-on-windows-8f062498751a?source=rss-95bdc513a8ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f062498751a</guid>
            <category><![CDATA[sonarqube]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Swaroop Reddy]]></dc:creator>
            <pubDate>Sat, 31 Aug 2024 07:04:22 GMT</pubDate>
            <atom:updated>2024-08-31T18:12:18.148Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bvo0Ry9Orby74yZotu4GBg.png" /></figure><p><strong>Introduction</strong></p><p>SonarQube is an open-source platform that helps you maintain high code quality by detecting bugs, code smells, and security vulnerabilities. Integrating SonarQube into your Java Spring Boot project ensures continuous monitoring and improvement of your code. This guide will show you how to set up SonarQube, whether you’re using Gradle or Maven, on a Windows machine.</p><p><strong>What is SonarQube?</strong></p><p>SonarQube performs automatic code reviews and provides detailed reports on various aspects of your codebase. It supports multiple languages and integrates with CI/CD pipelines to help you catch and fix issues early.</p><p><strong>Why Use SonarQube?</strong></p><ul><li>Continuous Inspection: Automates code reviews and integrates with your build process.</li><li>Multi-language Support: Works with many programming languages.</li><li>Quality Gates: Enforces code quality standards.</li><li>Security: Identifies potential security issues in your code.</li></ul><p><strong>Prerequisites</strong><br>Before getting started, make sure you have:</p><ul><li>Java 11 or higher installed.</li><li>Gradle or Maven installed and configured in your project.</li><li>A Java Spring Boot project ready to be analyzed.</li></ul><p><strong>Database Requirement</strong>: SonarQube requires a database (e.g., PostgreSQL, MySQL, or SQL Server). By default, SonarQube uses an embedded H2 database for testing purposes, but it’s recommended to use a production-grade database for larger projects or CI/CD integration.</p><p><strong>SonarQube Token Creation</strong>: Before configuring the SonarQube properties in your Gradle or Maven build files, you should generate a SonarQube token:</p><ul><li>Go to <strong>My Account</strong> in the SonarQube dashboard.</li><li>Click on <strong>Security</strong>.</li><li>Generate a new token and use this token in your project’s configuration.</li></ul><p><strong>Step 1: Download and Install SonarQube</strong></p><p><strong>Download SonarQube:</strong></p><ul><li>Go to the <a href="https://www.sonarqube.org/downloads/">SonarQube website</a> and download the latest version for Windows.</li></ul><p><strong>Extract and Install:</strong></p><ul><li>Unzip the downloaded file to a location like <strong>C:\SonarQube</strong>.</li><li>Navigate to <strong>C:\SonarQube\bin\windows-x86–64</strong> if you are using windows.</li><li>Open Command Prompt and navigate to <strong>C:\SonarQube\bin\windows-x86–64</strong>.</li></ul><p><strong>Database Configuration</strong>: If using an external database, you need to configure the sonar.properties file located in the C:\SonarQube\conf directory to connect to your database. For example:</p><pre>sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube<br>sonar.jdbc.username=sonarqube<br>sonar.jdbc.password=yourpassword</pre><p><strong>Increase JVM Memory</strong>: SonarQube can be memory-intensive, so it might be necessary to allocate more memory by editing the wrapper.conf file located in C:\SonarQube\conf\:</p><pre>wrapper.java.maxmemory=2048</pre><ul><li>Run the following command to start SonarQube:</li></ul><pre> StartSonar.bat</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-49IGjy5E7cGDBXIQ_Vyjg.png" /></figure><ul><li>SonarQube will be available at `<a href="http://localhost:9000`">http://localhost:9000`</a>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZIKH-PWV4xguR45LALlXCQ.png" /></figure><p><strong>Step 2: Access the SonarQube Dashboard:</strong></p><ul><li>Open your web browser and go to `<a href="http://localhost:9000`">http://localhost:9000`</a>.</li><li>Log in with: Username: <strong>admin</strong> and Password: <strong>admin</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*pvG2DsleRfnUa_KhuIK5-g.png" /></figure><ul><li>Change the password after your first login for security reasons.</li></ul><p><strong>Step 3: Create a New Project in Sonarqube</strong></p><ul><li>After adding the dependencies install the gradle / maven dependencies in your application.</li><li>Now we will create a new project in Sonarqube.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J0BtTYSpcCR31z6x5hf52w.png" /></figure><p><strong>Step 4: Configure SonarQube in Your Project</strong></p><p><strong>For Gradle Users:</strong></p><ul><li>Add the SonarQube Plugin in your build.gradle file:</li></ul><pre><br> plugins {<br>    id &quot;org.sonarqube&quot; version &quot;4.2.1.3168&quot;<br>}</pre><ul><li>Configure SonarQube, Add these properties to your build.gradle:</li></ul><pre><br>   sonarqube {<br>    properties {<br>        property &quot;sonar.projectKey&quot;, &quot;your-project-key&quot;<br>        property &quot;sonar.host.url&quot;, &quot;http://localhost:9000&quot;<br>        property &quot;sonar.login&quot;, &quot;your-sonarqube-token&quot;<br>    }<br>}</pre><ul><li>Replace `”your-project-key”` with a unique key for your project.</li></ul><p><strong>For Maven Users:</strong></p><p><strong>Add the SonarQube Plugin:</strong></p><ul><li>In your `pom.xml`, add:</li></ul><pre>&lt;plugin&gt;<br>    &lt;groupId&gt;org.sonarsource.scanner.maven&lt;/groupId&gt;<br>    &lt;artifactId&gt;sonar-maven-plugin&lt;/artifactId&gt;<br>    &lt;version&gt;4.2.0.1873&lt;/version&gt;<br>&lt;/plugin&gt;</pre><ul><li>Configure SonarQube, Add these properties to your `pom.xml`:</li></ul><pre>&lt;properties&gt;<br>    &lt;sonar.projectKey&gt;your-project-key&lt;/sonar.projectKey&gt;<br>    &lt;sonar.host.url&gt;http://localhost:9000&lt;/sonar.host.url&gt;<br>    &lt;sonar.login&gt;your-sonarqube-token&lt;/sonar.login&gt;<br>&lt;/properties&gt;</pre><ul><li>Replace `”your-project-key”` with a unique key for your project.</li></ul><p><strong>Step 5: Run SonarQube Analysis</strong></p><p><strong>For Gradle Users:</strong></p><ul><li>In your project root directory, run:</li></ul><pre> gradle sonarqube</pre><p><strong>For Maven Users:</strong></p><ul><li>In your project root directory, run:</li></ul><pre> mvn sonar:sonar</pre><ul><li>These commands will analyze your code and send the results to SonarQube.</li></ul><p><strong>Step 6: Review the Results</strong></p><p><strong>View the Dashboard:</strong></p><ul><li>After analysis, go to the SonarQube dashboard at `<a href="http://localhost:9000`">http://localhost:9000`</a>.</li><li>Click on your project to see the analysis report.</li></ul><p><strong>Setting Up Quality Gates</strong>: Mention that users can configure quality gates to automatically enforce code quality standards. A quality gate is a set of conditions a project must meet before it is considered to have passed the quality check.</p><ul><li>Go to <strong>Quality Gates</strong> in the SonarQube dashboard and configure the conditions, such as setting a threshold for code coverage, bug count, etc.</li></ul><p><strong>Analyze the Report:</strong></p><ul><li>The dashboard shows code quality, vulnerabilities, bugs, and code smells.</li><li>SonarQube provides a quality gate status (Pass/Fail) based on predefined criteria.</li></ul><p><strong>Step 7: Fix Issues:</strong></p><ul><li>Address any issues reported by SonarQube in your code.</li><li>Re-run the analysis to verify that issues are resolved.</li></ul><p><strong>Re-run Analysis in CI/CD Pipeline</strong>: For teams using CI/CD pipelines, it’s essential to integrate SonarQube into the pipeline to automatically analyze code quality on each build. This might involve additional steps depending on the CI/CD tool in use (e.g., Jenkins, GitLab CI, GitHub Actions).</p><p><strong>Additional Tools</strong>: You may want to mention other tools like <strong>SonarLint</strong> for real-time code analysis in IDEs like IntelliJ, Eclipse, or Visual Studio.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f062498751a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why every coder and reader should have a cup of coffee in hand.]]></title>
            <link>https://medium.com/@swaroop1232010/why-every-coder-and-reader-should-have-a-cup-of-coffee-in-hand-e0a2535e40c5?source=rss-95bdc513a8ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0a2535e40c5</guid>
            <category><![CDATA[coffeecode]]></category>
            <category><![CDATA[coffee-benefits]]></category>
            <category><![CDATA[buy-coffee-online]]></category>
            <category><![CDATA[coffee-reduce-cancer]]></category>
            <category><![CDATA[coffee]]></category>
            <dc:creator><![CDATA[Swaroop Reddy]]></dc:creator>
            <pubDate>Sun, 09 Apr 2023 01:17:18 GMT</pubDate>
            <atom:updated>2023-04-09T08:20:38.079Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yxuBqcxEwDaFaw3YI65ILw.jpeg" /></figure><p><strong>I. Fueling Your Code and Knowledge: The Power of Coffee for Coders and Compendiums</strong></p><p>Coffee has come an integral part of numerous people’s diurnal routines, including coders and compendiums. The fashionable of coffee among these groups can be attributed to the numerous benefits it offers, including increased energy and focus. In this blog post, we will explore why having a mug of coffee in hand can significantly profit both coders and compendiums. By the end of this post, you will have a better understanding of why coffee is such an essential part of the lives of coders and compendiums and how it can help them achieve their pretensions. So, snare a mug of coffee, and let’s dive in!</p><p><a href="https://amzn.to/40R590t"><em>Bru Instant Coffee</em></a><em> is my go-to choice for a daily caffeine fix while reading and coding. I prefer its convenient and flavorful instant formula, which is easy to prepare even on busy mornings. The rich and smooth taste of Bru Instant Coffee is perfectly balanced and mild, making it a reliable choice for anyone who loves coffee. If you’re looking for a quick and tasty way to fuel your day, I highly recommend trying Bru Instant Coffee.</em></p><p><strong>II. The Benefits of Coffee for Coders</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*f3lcW2eQ6rogNyaA_r0XqQ.png" /></figure><p>A. Improved Focus and Concentration Coding requires violent attention and focus, and occasionally, that is easier said than done. still, exploration has shown that coffee can ameliorate cognitive function, which includes focus and attention. The caffeine in coffee stimulates the central nervous system and increases the product of neurotransmitters similar as dopamine and norepinephrine, which help ameliorate cognitive function. This means that having a mug of coffee in hand while rendering can help you stay focused and engaged for longer ages.</p><p>B. Enhanced Cognitive Performance and Creativity The caffeine in coffee not only helps ameliorate focus and attention but also enhances cognitive performance and creativity. Caffeine has been shown to ameliorate short- term memory, internal alertness, and cognitive inflexibility. These benefits are essential for coders who need to break complex problems and suppose creatively. Coffee can also increase the speed of information processing, which is another critical skill for coders.</p><p>C. exemplifications of Successful Coders who Swear by Coffee It’s no secret that numerous successful coders calculate on coffee to help them get through long coding sessions. For case, Jack Dorsey, the author of Twitter and Square, is known for drinking a lot of coffee during the day. also, Linus Torvalds, the creator of Linux, is also a coffee nut, and he has mentioned several times how coffee helps him concentrate and get through long coding sessions.</p><p>In conclusion, coffee has numerous benefits for coders, including bettered focus and attention, enhanced cognitive performance, and increased creativity. However, you might want to consider having a mug of coffee in hand while you work, If you are a coder looking to boost productivity.</p><p><strong>III. The Benefits of Coffee for Readers</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*iFM5idNBf9DoIy6V3OReBw.jpeg" /></figure><p>Reading is a pivotal exertion that requires a lot of focus and attention. Coffee can help compendiums maintain that focus and attention, making it an ideal libation to have while reading.</p><p>A. Improved Focus and Concentration Just like in rendering, coffee can help ameliorate focus and attention while reading. The caffeine in coffee helps stimulate the brain, which can help keep compendiums alert and focused. This means that having a mug of coffee in hand while reading can help compendiums stay engaged and retain information better.</p><p>B. Enhanced Memory Retention and Comprehension Coffee has been shown to enhance memory retention and appreciation, which are critical chops for compendiums. Studies have shown that caffeine can ameliorate long- term memory retention, making it easier for compendiums to flash back what they have read. also, coffee has been shown to enhance appreciation, making it easier for compendiums to understand and retain complex information.</p><p>C. Exemplifications of Successful pens who Swear by Coffee numerous successful pens have touted the benefits of coffee for abetting in the jotting process. For illustration, Stephen King, one of the most successful pens of all time, has mentioned in several interviews that he starts his day with a mug of coffee and that it’s an essential part of his jotting routine. also, J.K. Rowling, the author of the Harry Potter series, has mentioned that she drinks a lot of coffee while writing and that it helps her stay focused and engaged.</p><p>In conclusion, coffee can significantly profit compendiums by perfecting focus and attention, enhancing memory retention and appreciation, and abetting in the jotting process. So, the coming time you pick up a book, consider having a mug of coffee in hand to help you get the most out of your reading experience.</p><p><strong>IV. The Science Behind Coffee’s Benefits</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lIuxxbYn9BHcEPuVvfBiyg.jpeg" /></figure><p>While coffee’s benefits for coders and compendiums are well- known, the wisdom behind these benefits isn’t as extensively understood. In this section, we will bandy the wisdom behind coffee’s goods on the brain and how it enhances cognitive performance.</p><p>A. Coffee’s goods on the Brain The caffeine in coffee is the main emulsion responsible for its stimulating goods on the brain. When caffeine enters the bloodstream, it blocks the neurotransmitter adenosine, which is responsible for promoting sleep and suppressing thrill. This, in turn, increases the exertion of other neurotransmitters like dopamine and norepinephrine, which are responsible for promoting alertness and perfecting cognitive performance.</p><p>B. The part of Caffeine and Other Compounds Caffeine isn’t the only emulsion in coffee that can enhance brain function. Coffee also contains antioxidants and other composites that can help cover the brain from oxidative stress and inflammation. These composites have been shown to have neuroprotective goods and can help cognitive decline associated with aging.</p><p>In conclusion, the wisdom behind coffee’s benefits for coders and compendiums is embedded in its goods on the brain. Caffeine and other composites in coffee work together to ameliorate cognitive performance and cover the brain from damage. So, the coming time you enjoy a mug of coffee, flash back that you are not just satisfying your caffeine pining; you are also boosting your headpiece.</p><p><strong>V. Tips for Maximizing Coffee’s Benefits</strong></p><p>While coffee can be a helpful tool for coders and compendiums, it’s important to use it wisely to maximize its benefits. In this section, we will give some tips for getting the most out of your coffee consumption.</p><p>A. Timing and Lozenge Recommendations To maximize coffee’s benefits, it’s important to consume it at the right time and in the right quantities. For coders and compendiums, the ideal time to consume coffee is generally at the morning of a long coding or reading session. This allows the caffeine to take effect when it’s demanded most, helping to ameliorate focus and attention. As for lozenge, exploration suggests that consuming 200- 400 mg of caffeine (roughly 1- 2 mugs of coffee) per day is safe and effective for perfecting cognitive performance.</p><p>B. The significance of Avoiding Overconsumption While coffee can be a helpful tool, overconsumption can have negative goods. Consuming too important caffeine can lead to anxiety, restlessness, and disintegrated sleep patterns, which can eventually hamper cognitive performance. also, consuming too important caffeine can lead to dependence, which can be delicate to break.</p><p>In conclusion, maximizing coffee’s benefits requires careful consideration of timing and lozenge, as well as avoiding overconsumption. By using coffee as, a tool in temperance, coders and compendiums can take advantage of its benefits without passing negative goods.</p><p><strong>VI. Conclusion</strong></p><p>In conclusion, coffee can be a precious tool for both coders and compendiums looking to ameliorate their productivity and focus. By enhancing cognitive performance, perfecting memory retention, and adding attention, coffee can be a useful addition to any coding or reading routine. still, it’s important to use coffee in temperance and to avoid overconsumption, as this can lead to negative goods similar as anxiety and disintegrated sleep patterns.</p><p>Overall, the benefits of having a mug of coffee in hand during coding and reading sessions are multitudinous, and it’s a habit that numerous successful professionals swear by. So, if you have not formerly, give it a pass and see how it affects your own productivity and focus. Just flash back to use it wisely, and you will be well on your way to rendering or reading success!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0a2535e40c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Every Developer Should Know 3 New API’s In React 18]]></title>
            <link>https://medium.com/@swaroop1232010/every-developer-should-know-3-new-apis-in-react-18-a8fd2f622643?source=rss-95bdc513a8ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8fd2f622643</guid>
            <category><![CDATA[react18]]></category>
            <category><![CDATA[react-developer]]></category>
            <category><![CDATA[react-18-new-features]]></category>
            <category><![CDATA[benefits-of-reactjs]]></category>
            <category><![CDATA[react-api]]></category>
            <dc:creator><![CDATA[Swaroop Reddy]]></dc:creator>
            <pubDate>Fri, 07 Apr 2023 18:38:23 GMT</pubDate>
            <atom:updated>2023-04-07T18:38:23.135Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*WWw6IGLwLSUaCtqe4B15lw.jpeg" /></figure><p><strong>I. Introduction</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*FzzxhCapx7H7jUrMgyfAtg.png" /></figure><p>A. <strong>Explanation of React 18 and its significance</strong></p><p><a href="https://react.dev/blog/2022/03/29/react-v18">React 18’s</a> release marks a significant corner in the elaboration of React. This new interpretation includes several advancements and new features that make it easier for inventors to make ultramodern web operations.</p><p>B. <strong>Importance of staying up to date with new APIs in React</strong></p><p>To remain competitive in the ever- changing tech assiduity, inventors must stay over- to- date with new APIs and features. This blog post will bandy three new APIs in React 18 that every inventor should know.</p><p><strong>II. API 1 startTransition()</strong></p><p><strong>A. Explanation of startTransition() API</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*w2n5qJaVUuvh20ydFeugLQ.png" /></figure><p>It can lead to a smoother and more responsive stoner experience. It can also help to reduce the workload of the main thread and help the UI from indurating during picture.</p><p><strong>B. Benefits of using startTransition()</strong></p><p>Using <a href="https://react.dev/reference/react/startTransition">startTransition()</a> can lead to a smoother and more responsive user experience. It can also help to reduce the workload of the main thread and prevent the UI from freezing during rendering.</p><p><strong>C. Code examples demonstrating the use of startTransition()</strong></p><p>Exemplifications of how to use startTransition() will be handed to illustrate how this API can be enforced in law.</p><p><strong>III. API 2: useDeferredValue()</strong></p><p><strong>A. Explanation of useDeferredValue() API</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*KOZbTgsv3jZ1Ve5Ue_iygA.png" /></figure><p>The <a href="https://react.dev/reference/react/useDeferredValue">useDeferredValue()</a> API is used to postpone the value of a state update until after the coming render cycle. This can be useful in situations where a state update would spark a precious calculation or beget the UI to indurate.</p><p><strong>B. Benefits of using useDeferredValue()</strong></p><p>Using useDeferredValue() can ameliorate the performance of an operation by postponing pprecious calculationsand reducing the workload of the main thread.</p><p><strong>C. Code examples demonstrating the use of useDeferredValue()</strong></p><p>Exemplifications of how to use useDeferredValue() will be handed to illustrate how this API can be enforced in law.</p><p><strong>IV. API 3: useTransition()</strong></p><p><strong>A. Explanation of useTransition() API</strong></p><p>The <a href="https://react.dev/reference/react/useTransition">useTransition()</a> API is used to produce transitions between different countries of an element. This can be useful for creating robustness and other visual goods.</p><p><strong>B. Benefits of using useTransition()</strong></p><p>Using useTransition() can add visual polish and interactivity to an operation, making it more engaging and immersive for druggies.</p><p><strong>C. Code examples demonstrating the use of useTransition()</strong></p><p>Exemplifications of how to use useTransition() will be handed to illustrate how this API can be enforced in law.</p><p><strong>V. How these APIs benefit developers</strong></p><p><strong>A. Improved performance and user experience</strong></p><p>The use of these new APIs can lead to better performance and a better stoner experience.</p><p><strong>B. Increased flexibility and control over rendering</strong></p><p>inventors can exercise further control over the picture process with these new APIs, allowing them to fine- tune the performance of their operations.</p><p><strong>C. Simplified code and reduced complexity</strong></p><p>The use of these new APIs can simplify law and reduce complexity, making it easier to develop and maintain complex operations.</p><p><strong>VI. Resources for learning about new APIs in React 18</strong></p><p>A. Official React attestation and coffers</p><p>B. Online courses and tutorials</p><p>C. Community forums and support networks</p><p><strong>VII. Conclusion</strong></p><p>A. Recap of crucial points</p><p>B. Final studies on the significance of staying over- to- date with new APIs in React</p><p>C. stimulant to take action and start enforcing these new APIs in <a href="https://react.dev/blog/2022/03/08/react-18-upgrade-guide">React 18</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8fd2f622643" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon Affiliate Marketing vs. Other Affiliate Programs: Which is Better?]]></title>
            <link>https://medium.com/@swaroop1232010/amazon-affiliate-marketing-vs-other-affiliate-programs-which-is-better-a4b60f626258?source=rss-95bdc513a8ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4b60f626258</guid>
            <category><![CDATA[affiliate-marketing]]></category>
            <category><![CDATA[amazon-affiliate-tutorial]]></category>
            <category><![CDATA[amazon-associates]]></category>
            <category><![CDATA[amazon-affiliate-program]]></category>
            <category><![CDATA[how-to-make-money-online]]></category>
            <dc:creator><![CDATA[Swaroop Reddy]]></dc:creator>
            <pubDate>Fri, 07 Apr 2023 03:15:43 GMT</pubDate>
            <atom:updated>2023-04-07T03:15:43.566Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wCGytZmseWvcK8ZfsPvAiA.png" /></figure><p><strong>Preface:</strong></p><p>Chapter marketing has become a popular way for individuals to earn a passive income online. It involves promoting a company’s products or services and earning a commission for each sale made through an affiliate link. The benefits of affiliate marketing include the ability to work from anywhere, flexible hours, and the potential for high earnings.</p><p>One of the most well-known affiliate programs is Amazon Affiliate Marketing. Amazon’s program is easy to use, offers a wide variety of products, and pays a decent commission rate. As an Amazon affiliate, you can promote anything from books to electronics, and you can earn up to 10% in commissions on each sale.</p><p><a href="https://www.shopify.com/blog/53669701-how-to-set-up-an-affiliate-program-for-your-shopify-store"><strong>Discover how to start a successful affiliate marketing</strong></a>!!!</p><p><strong>Chapter 1: Amazon Affiliate Marketing Pros and Cons</strong></p><p>Advantages of Amazon <a href="https://www.youtube.com/watch?v=PYoVPfsP-ng">Affiliate Marketing</a>:</p><p>Amazon Affiliate Marketing has several advantages. Firstly, Amazon is a well-established and reputable company with a global presence. Secondly, they offer a vast selection of products to promote, which means that you can find products that are applicable to your niche. Additionally, Amazon provides a user-friendly interface and offers various tools to help you optimize your deals, including product links, banners, and widgets.</p><p>Limitations of Amazon Affiliate Marketing:</p><p>Still, there are also limitations to Amazon Affiliate Marketing. One of the major downsides is the low commission rates, particularly for low-priced products. Additionally, Amazon has strict policies and rules that you must adhere to, which can be challenging for newcomers. Initially, Amazon’s cookie duration is only 24 hours, which means that you’ll only receive a commission if a customer makes a purchase within 24 hours of clicking your affiliate link.</p><p><strong>Chapter 2: Other Affiliate Programs Pros and Cons</strong></p><p>Types of affiliate programs available:</p><p>There are numerous non-Amazon affiliate programs available, including those offered by companies such as ClickBank, Commission Junction, and ShareASale. These affiliate programs offer a wide range of products and services, frequently with higher commission rates than Amazon.</p><p>Advantages and disadvantages of non-Amazon affiliate programs:</p><p>The advantages of non-Amazon affiliate programs include higher commission rates, longer cookie durations, and less strict policies. However, some of the disadvantages of non-Amazon affiliate programs include the difficulty of finding applicable products, as well as the potential for fraudulent activity or unreliable tracking.</p><p><strong>Chapter 3: Comparison of Amazon Affiliate Marketing and Other Affiliate Programs</strong></p><p>Crucial parallels and differences:</p><p>Amazon Affiliate Marketing and other affiliate programs share some similarities, such as the ability to promote products and earn commissions. However, there are also some crucial differences between them, including the commission rates, cookie duration, product selection, and policies.</p><p>For example, Amazon Affiliate Marketing has a lower commission rate but offers a broader range of products to promote. In contrast, other affiliate programs may have higher commission rates, but they may have more limited product offerings. Additionally, Amazon has strict policies and rules that affiliates must follow, while other affiliate programs may be more lenient.</p><p><strong>Chapter 4: Factors to Consider When Choosing an Affiliate Program</strong></p><p>Niche applicability, commission rates, cookie duration, payment options:</p><p>When choosing an affiliate program, several factors should be considered, such as the applicability of the products to your niche, the commission rates, cookie duration, and payment options. It’s essential to find an affiliate program that aligns with your interests and has products that your audience is interested in. Additionally, it’s important to consider the commission rates and cookie duration, as they can affect your earnings potential.</p><p><strong>Chapter 5: Which is Better Amazon Affiliate Marketing or Other Affiliate Programs?</strong></p><p>Summary of the pros and cons of both options, conclusion and recommendation:</p><p>In conclusion, whether Amazon Affiliate Marketing or other chapter programs are better depends on several factors, including your niche, the products you want to promote, and your cult. Amazon Affiliate Marketing has several advantages, similar as a wide selection of products and a stoner-friendly interface. On the other hand, other chapter programs may offer advanced features.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4b60f626258" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>