<?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 Jagnya Datta Panigrahi on Medium]]></title>
        <description><![CDATA[Stories by Jagnya Datta Panigrahi on Medium]]></description>
        <link>https://medium.com/@jai.mail67?source=rss-dfe3bd04bc1d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*V2qK3v5X1mjzb8o9XaDD1w.jpeg</url>
            <title>Stories by Jagnya Datta Panigrahi on Medium</title>
            <link>https://medium.com/@jai.mail67?source=rss-dfe3bd04bc1d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 23:54:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jai.mail67/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[LLMs Talk, Jev Decides: The New Architecture for AI Agents]]></title>
            <link>https://medium.com/@jai.mail67/llms-talk-jev-decides-the-new-architecture-for-ai-agents-2261badc5700?source=rss-dfe3bd04bc1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2261badc5700</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[spring-ai]]></category>
            <category><![CDATA[jevs]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Jagnya Datta Panigrahi]]></dc:creator>
            <pubDate>Wed, 23 Sep 2026 16:01:15 GMT</pubDate>
            <atom:updated>2026-09-23T16:01:15.607Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uiQNz6SWJPljHyoUjJRD9Q.png" /></figure><p><em>Why AI agents need a decision model, not just a chat model</em></p><h3>What is Jev?</h3><p>Jev is an AI model from <strong>TypeSafe AI</strong>, founded by <strong>Diogo Almeida</strong>, one of the researchers behind ChatGPT’s instruction-following at OpenAI. It went into early access on September 15, 2026.</p><p>He built it around one question:</p><blockquote><em>“Models have been superhuman at chat for years, so where is all the automation?”</em></blockquote><p>AI can talk very well, but most business work still isn’t automated. Chat models were built to talk to people, not to make decisions inside software. <strong>Jev is built only to make decisions.</strong></p><h3>Why do we need Jev?</h3><p>In an AI agent, most LLM calls don’t write anything. They make small decisions:</p><ul><li>What does the customer want?</li><li>Is this refund allowed?</li><li>Should this go to a human?</li><li>Is the bot’s reply correct?</li></ul><p>These are really just if conditions, but we use a big chat model to answer them. That causes problems, and Jev solves each one:</p><ul><li><strong>Text output.</strong> LLM: returns text we must parse, and it sometimes breaks. Jev: returns a fixed answer in your format, every time.</li><li><strong>Unknown certainty.</strong> LLM: doesn’t say how sure it is. Jev: every answer has a confidence score.</li><li><strong>Speed.</strong> LLM: takes seconds. Jev: 70–500 ms.</li><li><strong>Cost.</strong> LLM: expensive at high volume. Jev: $0.042 per million input tokens, output free.</li><li><strong>Made-up answers.</strong> LLM: can invent an option that doesn’t exist. Jev: can only pick from your options.</li></ul><p><strong>In short: Jev makes the decisions, and the LLM writes the words.</strong></p><h3>Where should we use Jev?</h3><p>Use Jev wherever your code has to <strong>choose, rate or answer yes/no</strong> about unstructured text or data.</p><ul><li><strong>Customer support chatbot:</strong> customer intent, whether they want a human, how angry they are</li><li><strong>Order fraud check:</strong> risk level of an order</li><li><strong>Product reviews:</strong> spam or not; what the review is about</li><li><strong>Catalog:</strong> which category a supplier product belongs to</li><li><strong>Support tickets:</strong> which team handles it; priority</li><li><strong>Search:</strong> is the user browsing, looking for a product, or needing help?</li><li><strong>Returns:</strong> does the return reason match the policy?</li><li><strong>LLM safety:</strong> does the LLM’s reply match the real facts?</li></ul><p>Use an <strong>LLM</strong> when you need text written, such as a reply, a summary or an email.</p><h3>Architecture: before and after Jev</h3><h3>Before Jev: the LLM does everything</h3><pre>Customer message<br>   ▼<br>[LLM] Find intent             ← slow, costly, text needs parsing<br>   ▼<br>[LLM] Decide route<br>   ▼<br>Tools: Order API, Returns API<br>   ▼<br>[LLM] Write reply<br>   ▼<br>[LLM] Check if the reply is safe<br>   ▼<br>Response</pre><ul><li>3–4 LLM calls for every message</li><li>Several seconds of waiting</li><li>A cost on every step</li><li>No reliable confidence score</li></ul><p>Only one step, <strong>writing the reply</strong>, really needs an LLM.</p><h3>After Jev: Jev decides, the LLM writes</h3><pre>Customer message + order data + customer data<br>   ▼<br>[Jev] Intent? Wants a human? How frustrated?   ← ONE fast call<br>   │<br>   ├── wants human OR very angry ──► human agent<br>   ├── low confidence ─────────────► ask the customer<br>   ▼<br>Tools: Order API, Returns API      (normal application code)<br>   ▼<br>[LLM] Write the reply               ← the ONLY LLM call<br>   ▼<br>[Jev] Does the reply promise anything wrong?<br>   │        └── yes ──► rewrite or send to a human<br>   ▼<br>Response</pre><ul><li><strong>1 LLM call</strong> instead of 3–4</li><li>Decisions arrive in milliseconds</li><li>Every decision has a confidence score</li><li>Your code controls when to trust the AI and when to call a human</li></ul><h3>How Jev works</h3><pre>You send:   STATE      → the facts (message, order, customer)<br>          + QUESTIONS  → what you want to know + allowed answers<br>                 │<br>                 ▼<br>               [Jev]    answers all questions at once<br>                 │<br>                 ▼<br>You get:    ANSWERS    → one typed answer per question + confidence</pre><h3>Jev’s three question types</h3><ul><li><strong>choice — “Which one?”</strong> You give a list of options (up to 255). Jev returns the best option, probabilities and confidence.</li><li><strong>score — “How much?”</strong> You give levels from lowest to highest. Jev returns a number on that scale, probabilities and confidence.</li><li><strong>noul — “Yes or no?”</strong> You give nothing extra. Jev returns the probability of yes, from 0 to 1.</li></ul><h3>How to send a Jev request</h3><h3>Endpoint</h3><pre>POST https://api.typesafe.ai/v1/systemone<br>Authorization: Bearer &lt;YOUR_API_KEY&gt;<br>Content-Type: application/json</pre><p>You get the API key from console.typesafe.ai.</p><h3>Request format</h3><pre>{<br>  &quot;model&quot;: &quot;jev-latest&quot;,<br>  &quot;state&quot;: { ...the facts... },<br>  &quot;questions&quot;: {<br>    &quot;&lt;your_question_name&gt;&quot;: { ...question... },<br>    &quot;&lt;another_question&gt;&quot;:   { ...question... }<br>  }<br>}</pre><ul><li><strong>model:</strong> which Jev version to use. jev-latest means the newest.</li><li><strong>state:</strong> the facts Jev should look at.</li><li><strong>questions:</strong> a map of questions. You choose each name, and the answer comes back under that same name.</li></ul><h3>Format of each question type</h3><p><strong>choice (pick one)</strong></p><pre>&quot;intent&quot;: {<br>  &quot;type&quot;: &quot;choice&quot;,<br>  &quot;instructions&quot;: &quot;What does the customer want?&quot;,<br>  &quot;criteria&quot;: {<br>    &quot;order_status&quot;:    &quot;Where is my order, delivery date, tracking&quot;,<br>    &quot;return_exchange&quot;: &quot;Return or exchange an item, wrong size or colour&quot;,<br>    &quot;refund&quot;:          &quot;Money back, refund status&quot;,<br>    &quot;faq&quot;:             &quot;General questions about policies, stores, offers&quot;,<br>    &quot;other&quot;:           &quot;None of the above&quot;<br>  }<br>}</pre><ul><li>The <strong>key</strong> (return_exchange) is what your code receives.</li><li>The <strong>description</strong> tells Jev what the option means.</li><li>Always add other as a safe fallback.</li></ul><p><strong>score (rate on a scale)</strong></p><pre>&quot;frustration&quot;: {<br>  &quot;type&quot;: &quot;score&quot;,<br>  &quot;instructions&quot;: &quot;How frustrated is the customer?&quot;,<br>  &quot;criteria&quot;: [&quot;Calm&quot;, &quot;Mildly annoyed&quot;, &quot;Very frustrated or angry&quot;]<br>}</pre><ul><li>List the levels in order, <strong>lowest first</strong>.</li><li>Positions become numbers: Calm = 0, Mildly annoyed = 1, Very frustrated = 2.</li></ul><p><strong>noul (yes or no)</strong></p><pre>&quot;wants_human&quot;: {<br>  &quot;type&quot;: &quot;noul&quot;,<br>  &quot;instructions&quot;: &quot;Is the customer asking to talk to a human agent?&quot;<br>}</pre><ul><li>No criteria is needed.</li></ul><h3>Full example</h3><p><strong>The customer writes:</strong></p><blockquote><em>“My shoes came in the wrong size. This is the third time I’m messaging. Can I just talk to someone?”</em></blockquote><h3>Request</h3><pre>{<br>  &quot;model&quot;: &quot;jev-latest&quot;,<br>  &quot;state&quot;: {<br>    &quot;message&quot;: &quot;My shoes came in the wrong size. This is the third time I&#39;m messaging. Can I just talk to someone?&quot;,<br>    &quot;orderId&quot;: &quot;ORD-10492&quot;,<br>    &quot;orderStatus&quot;: &quot;DELIVERED&quot;,<br>    &quot;customerTier&quot;: &quot;GOLD&quot;,<br>    &quot;previousContacts&quot;: 2<br>  },<br>  &quot;questions&quot;: {<br>    &quot;intent&quot;: {<br>      &quot;type&quot;: &quot;choice&quot;,<br>      &quot;instructions&quot;: &quot;What does the customer want?&quot;,<br>      &quot;criteria&quot;: {<br>        &quot;order_status&quot;:    &quot;Where is my order, delivery date, tracking&quot;,<br>        &quot;return_exchange&quot;: &quot;Return or exchange an item, wrong size or colour&quot;,<br>        &quot;refund&quot;:          &quot;Money back, refund status&quot;,<br>        &quot;faq&quot;:             &quot;General questions about policies, stores, offers&quot;,<br>        &quot;other&quot;:           &quot;None of the above&quot;<br>      }<br>    },<br>    &quot;wants_human&quot;: {<br>      &quot;type&quot;: &quot;noul&quot;,<br>      &quot;instructions&quot;: &quot;Is the customer asking to talk to a human agent?&quot;<br>    },<br>    &quot;frustration&quot;: {<br>      &quot;type&quot;: &quot;score&quot;,<br>      &quot;instructions&quot;: &quot;How frustrated is the customer?&quot;,<br>      &quot;criteria&quot;: [&quot;Calm&quot;, &quot;Mildly annoyed&quot;, &quot;Very frustrated or angry&quot;]<br>    }<br>  }<br>}</pre><h3>Response</h3><pre>{<br>  &quot;model&quot;: &quot;jev-1.13.0&quot;,<br>  &quot;answers&quot;: {<br>    &quot;intent&quot;: {<br>      &quot;type&quot;: &quot;choice&quot;,<br>      &quot;choice&quot;: &quot;return_exchange&quot;,<br>      &quot;confidence&quot;: 0.93,<br>      &quot;probabilities&quot;: {<br>        &quot;return_exchange&quot;: 0.95,<br>        &quot;refund&quot;: 0.04,<br>        &quot;order_status&quot;: 0.01,<br>        &quot;faq&quot;: 0.0,<br>        &quot;other&quot;: 0.0<br>      }<br>    },<br>    &quot;wants_human&quot;: {<br>      &quot;type&quot;: &quot;noul&quot;,<br>      &quot;noul&quot;: 0.97<br>    },<br>    &quot;frustration&quot;: {<br>      &quot;type&quot;: &quot;score&quot;,<br>      &quot;score&quot;: 1.62,<br>      &quot;confidence&quot;: 0.58,<br>      &quot;probabilities&quot;: { &quot;0&quot;: 0.0, &quot;1&quot;: 0.38, &quot;2&quot;: 0.62 },<br>      &quot;legend&quot;: {<br>        &quot;0&quot;: &quot;Calm&quot;,<br>        &quot;1&quot;: &quot;Mildly annoyed&quot;,<br>        &quot;2&quot;: &quot;Very frustrated or angry&quot;<br>      }<br>    }<br>  },<br>  &quot;usage&quot;: {<br>    &quot;input_tokens&quot;: 410,<br>    &quot;output_tokens&quot;: 40<br>  }<br>}</pre><h3>Understanding the response</h3><ul><li><strong>model:</strong> the exact Jev version that answered.</li><li><strong>answers:</strong> one answer per question, under the name you gave it.</li><li><strong>usage:</strong> tokens used, which is what you’re billed for.</li></ul><p><strong>Fields inside each answer:</strong></p><ul><li><strong>choice</strong> (choice): the option Jev picked.</li><li><strong>score</strong> (score): position on your scale; can fall between levels, e.g. 1.62.</li><li><strong>noul</strong> (noul): probability that the answer is yes, from 0 to 1.</li><li><strong>confidence</strong> (choice, score): how sure Jev is, from 0 to 1. Low means unsure.</li><li><strong>probabilities</strong> (choice, score): the chance of each option or level.</li><li><strong>legend</strong> (score): maps each level number back to its text.</li></ul><p><strong>What this response says in plain words:</strong></p><ul><li><strong>intent = return_exchange, 93% confident:</strong> the customer wants a size exchange.</li><li><strong>wants_human = 0.97:</strong> they very likely want a real person.</li><li><strong>frustration = 1.62 out of 2:</strong> they’re quite frustrated.</li></ul><h3>How to use the response in your code</h3><p>Jev only gives the answers. <strong>Your code makes the final decision</strong> using simple rules:</p><pre>IF wants_human ≥ 0.85  OR  frustration ≥ 1.5<br>    → send to a human agent</pre><pre>ELSE IF intent.confidence &lt; 0.80<br>    → ask the customer a clarifying question</pre><pre>ELSE<br>    → follow the flow for the intent:<br>        order_status     → call the Order API<br>        return_exchange  → start the exchange flow<br>        refund           → check the refund status<br>        faq              → search the FAQ<br>        other            → ask the customer to clarify</pre><p>For our example, wants_human is 0.97, which is above 0.85, so we <strong>send the customer to a human agent</strong>, with the intent already filled in. No LLM was needed.</p><p><strong>Simple rules for using Jev answers:</strong></p><ol><li><strong>Always check confidence</strong> before acting automatically.</li><li><strong>Set thresholds:</strong> trust high confidence, send low confidence to a human.</li><li><strong>Start strict:</strong> send more to humans at first, then relax once you see accuracy is good.</li><li><strong>Log every answer</strong> with its confidence. This gives you an audit trail and helps you tune thresholds.</li><li><strong>Have a fallback:</strong> if Jev doesn’t respond, send the case to a human. Never block the customer.</li><li><strong>Ask several questions in one request.</strong> It’s faster and cheaper than separate calls.</li></ol><h3>Final thoughts</h3><p>LLMs are great at language, but they shouldn’t answer every if in our code. With Jev, <strong>the decisions become fast, cheap and measurable, and the LLM is used only where words are needed.</strong> For any backend developer, it&#39;s just one REST call.</p><p>Jev is still in early access, so test it on a real workflow before relying on the numbers.</p><h3>Sources</h3><ul><li><a href="https://typesafe.ai/">TypeSafe AI</a></li><li><a href="https://typesafe.ai/blog/introducing-system-one-models-and-jev">Introducing System One Models &amp; Jev</a></li><li><a href="https://www.latent.space/p/jev">Latent Space: Jev with Diogo Almeida</a></li><li><a href="https://docs.typesafe.ai/">TypeSafe docs</a></li><li><a href="https://github.com/danvega/hello-jev-spring">hello-jev-spring by Dan Vega</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2261badc5700" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enterprise AI Architecture: Combining RAG, Tool Calling and MCP]]></title>
            <link>https://medium.com/@jai.mail67/enterprise-ai-architecture-combining-rag-tool-calling-and-mcp-a9591acb465f?source=rss-dfe3bd04bc1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9591acb465f</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Jagnya Datta Panigrahi]]></dc:creator>
            <pubDate>Fri, 19 Jun 2026 09:15:18 GMT</pubDate>
            <atom:updated>2026-06-19T09:24:33.110Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Owgqo74bED7MGfCY1Z6PQ.jpeg" /></figure><h3>Introduction</h3><p>The rise of Generative AI has transformed how enterprises build intelligent applications. Whether it’s customer support, product discovery, order management, or internal knowledge assistants, Large Language Models (LLMs) are becoming a core part of modern software architecture.</p><p>However, many developers struggle to understand three critical concepts:</p><ul><li>Retrieval-Augmented Generation (RAG)</li><li>Tool Calling</li><li>Model Context Protocol (MCP)</li></ul><p>These technologies are often discussed together, but they solve different problems.</p><p>In this article, we’ll explore what each technology does, when to use it, and how they work together to build real-world enterprise AI solutions.</p><h3>The Challenge with Traditional LLMs</h3><p>LLMs such as GPT, Claude, and Gemini are powerful reasoning engines, but they have limitations.</p><h3>1. No Access to Enterprise Data</h3><p>An LLM doesn’t know:</p><ul><li>Customer orders</li><li>Product inventory</li><li>Pricing information</li><li>Internal documentation</li><li>Company policies</li></ul><h3>2. No Access to Real-Time Information</h3><p>An LLM cannot answer:</p><blockquote><em>What is the current status of order #12345?</em></blockquote><p>because that information exists in your business systems, not in the model.</p><h3>3. Cannot Perform Business Actions</h3><p>An LLM cannot:</p><ul><li>Create an order</li><li>Generate a refund</li><li>Send an email</li><li>Update customer information</li></ul><p>without external integrations.</p><p>This is where RAG, Tool Calling, and MCP become essential.</p><h3>Understanding RAG</h3><h3>What is RAG?</h3><p>Retrieval-Augmented Generation (RAG) enhances an LLM by retrieving relevant information from external knowledge sources before generating a response.</p><p>Instead of relying solely on training data, the model receives additional context from your enterprise knowledge base.</p><h3>RAG Workflow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yIqK4pL7Vi2mN2h5Ei-s0A.png" /></figure><p>Example</p><p>Customer asks:</p><blockquote><em>What is your return policy for electronics?</em></blockquote><p>The system:</p><ol><li>Searches company policy documents</li><li>Retrieves relevant sections</li><li>Sends them to the LLM</li><li>Generates an accurate response</li></ol><h3>When to Use RAG</h3><p>Use RAG when information exists in:</p><ul><li>PDFs</li><li>Confluence pages</li><li>Wikis</li><li>Product catalogs</li><li>Knowledge bases</li><li>Documentation repositories</li></ul><h3>Benefits</h3><ul><li>Reduces hallucinations</li><li>Provides up-to-date information</li><li>Avoids model retraining</li><li>Works with private enterprise data</li></ul><h3>Understanding Tool Calling</h3><h3>What is Tool Calling?</h3><p>Tool Calling allows an LLM to invoke APIs, services, or business functions.</p><p>Instead of only generating text, the model can perform actions.</p><h3>Tool Calling Workflow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_WEhN9UmL-6Faf4Pd7M9AA.png" /></figure><h3>Example</h3><p>Customer asks:</p><blockquote><em>Where is my order?</em></blockquote><p>The LLM determines that it needs order information and calls:</p><p>getOrderStatus(orderId)</p><p>The API returns:</p><ul><li>Order Number</li><li>Shipment Status</li><li>Expected Delivery</li></ul><p>The LLM converts this into a natural language response.</p><h3>Spring AI Example</h3><pre>@Tool(description = &quot;Get customer order status&quot;)<br>public OrderStatus getOrderStatus(String orderId) {<br>    return orderService.getStatus(orderId);<br>}</pre><p>The LLM automatically decides when to invoke this tool.</p><h3>Typical Enterprise Tools</h3><ul><li>Order Management APIs</li><li>Inventory Services</li><li>Payment Systems</li><li>Customer Profile Services</li><li>Shipping APIs</li><li>CRM Platforms</li></ul><h3>When to Use Tool Calling</h3><p>Use Tool Calling when:</p><ul><li>Live data is required</li><li>Business actions must be executed</li><li>External APIs must be invoked</li></ul><h3>Understanding MCP</h3><h3>What is MCP?</h3><p>Model Context Protocol (MCP) is an open standard that allows AI applications to communicate with external tools and resources through a common interface.</p><p>Think of MCP as:</p><p>“USB-C for AI Integrations”</p><p>Without MCP, every AI client requires custom integration.</p><p>With MCP, one implementation can be used by multiple AI clients.</p><h3>MCP Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8B5rorvu8KCq6LZaJhDKng.png" /></figure><h3>Why MCP Matters</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pY9XmJooImIB7ASdArECAA.png" /></figure><h3>Benefits</h3><ul><li>Standardized integrations</li><li>Reusable tool ecosystem</li><li>Faster development</li><li>Vendor-neutral architecture</li><li>Easier maintenance</li></ul><h3>RAG vs Tool Calling vs MCP</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LPEb6_ZzHtLp7DveA7Mk-w.png" /></figure><h3>Real-World E-Commerce Example</h3><p>Let’s consider an AI-powered customer support assistant.</p><h3>Scenario 1: Product Information</h3><p>Customer:</p><blockquote><em>Tell me about Samsung Galaxy S25 features.</em></blockquote><p>Best Choice: RAG</p><p>Reason:</p><p>Product descriptions are stored in product catalogs and knowledge repositories.</p><p>The assistant retrieves relevant product information and generates an accurate answer.</p><h3>Scenario 2: Order Tracking</h3><p>Customer:</p><blockquote><em>Where is my order #98765?</em></blockquote><p>Best Choice: Tool Calling</p><p>Reason:</p><p>Order information is real-time transactional data.</p><p>The assistant calls:</p><p>getOrderStatus(“98765”)</p><p>and returns the latest status.</p><h3>Scenario 3: Return Policy</h3><p>Customer:</p><blockquote><em>Can I return a mobile phone after 30 days?</em></blockquote><p>Best Choice: RAG</p><p>Reason:</p><p>The answer exists in policy documents and knowledge repositories.</p><h3>Scenario 4: Create Return Request</h3><p>Customer:</p><blockquote><em>Create a return request for my last order</em></blockquote><p>Best Choice: Tool Calling</p><p>Reason:</p><p>A business action must be performed.</p><p>The assistant invokes:</p><p>createReturnRequest(orderId)</p><p>and confirms the result.</p><h3>Where MCP Fits In</h3><p>Imagine your organization has:</p><ul><li>Product Service</li><li>Inventory Service</li><li>Order Service</li><li>Customer Service</li></ul><p>Instead of exposing separate integrations for every AI client, you expose them through an MCP Server.</p><p>The MCP Server becomes the gateway through which AI systems access enterprise capabilities.</p><p>For example:</p><ul><li>Claude Desktop</li><li>ChatGPT</li><li>Cursor</li><li>VS Code Agents</li></ul><p>can all consume the same tools.</p><p>This significantly reduces integration effort and operational complexity.</p><h3>Combining RAG, Tool Calling, and MCP</h3><p>The most powerful enterprise AI systems use all three technologies together.</p><p>Consider this request:</p><blockquote><em>What is your return policy for electronics and create a return request for my last order?</em></blockquote><p>The system performs:</p><h3>Step 1: RAG</h3><p>Retrieve return policy documentation.</p><h3>Step 2: Tool Calling</h3><p>Fetch customer’s latest order.</p><h3>Step 3: Tool Calling</h3><p>Create a return request.</p><h3>Step 4: MCP</h3><p>Provide standardised access to all business capabilities.</p><p>The customer experiences a single seamless conversation while multiple AI technologies work together behind the scenes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OXj6FTosPU_XdlC41imXIw.png" /></figure><h3>Implementing This with Spring AI</h3><p>Spring AI provides excellent support for enterprise AI applications.</p><h3>RAG</h3><ul><li>Vector Stores</li><li>Retrieval APIs</li><li>Embedding Models</li></ul><h3>Tool Calling</h3><ul><li>@Tool Annotation</li><li>ToolCallbackProvider</li><li>Automatic Function Invocation</li></ul><h3>MCP</h3><ul><li>MCP Server Support</li><li>MCP Client Integration</li><li>Claude Desktop Compatibility</li></ul><p>This makes Spring AI a strong choice for enterprise Java teams building AI-powered applications.</p><h3>Final Thoughts</h3><p>RAG, Tool Calling, and MCP are not competing technologies.</p><p>They solve different challenges:</p><ul><li>RAG provides enterprise knowledge.</li><li>Tool Calling enables business actions.</li><li>MCP standardises AI integrations.</li></ul><p>Organisations that successfully combine these technologies can build intelligent systems capable of understanding business context, accessing real-time information, and performing meaningful actions.</p><p>The future of enterprise AI is not just answering questions.</p><p>It is about creating AI agents that can retrieve knowledge, reason over data, interact with business systems, and execute workflows autonomously.</p><p>And that future is being built today using RAG, Tool Calling, and MCP.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9591acb465f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Part 2 — All Important Eureka Server Endpoints (Complete Deep Dive)]]></title>
            <link>https://medium.com/@jai.mail67/part-2-all-important-eureka-server-endpoints-complete-deep-dive-eabe1af7ca50?source=rss-dfe3bd04bc1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/eabe1af7ca50</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[spring-cloud]]></category>
            <category><![CDATA[microservice-architecture]]></category>
            <category><![CDATA[netflix-eureka]]></category>
            <dc:creator><![CDATA[Jagnya Datta Panigrahi]]></dc:creator>
            <pubDate>Sat, 21 Feb 2026 14:50:09 GMT</pubDate>
            <atom:updated>2026-02-21T15:23:21.405Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Owgqo74bED7MGfCY1Z6PQ.jpeg" /></figure><p>In Part-1, <a href="https://medium.com/@jai.mail67/service-registry-api-gateway-in-spring-boot-from-setup-to-failure-handling-dbe9f2fa18be"><strong>Service Registry &amp; API Gateway in Spring Boot — From Setup to Failure Handling</strong></a>,<strong> </strong>we saw how to configure Eureka Server and how services register themselves. Now let’s go deeper.</p><p>Most developers use Eureka without knowing <strong>what actually happens behind the scenes</strong>.</p><p>Eureka is NOT magic. It exposes a full REST API for:</p><ul><li>Service Registration</li><li>Heartbeat (Lease Renewal)</li><li>Deregistration</li><li>Fetching Registry</li><li>Delta Updates</li><li>Status Updates</li></ul><p>Let’s explore every important endpoint.</p><h3>🌐 Eureka Base URL</h3><pre>http://localhost:8761/eureka/</pre><p>All endpoints start with:</p><pre>/eureka/apps</pre><h3>1️⃣ Register a Service Instance</h3><h3>Endpoint</h3><pre>POST /eureka/apps/{APP_NAME}</pre><p>Example:</p><pre>POST http://localhost:8761/eureka/apps/ORDER-SERVICE</pre><h3>📌 What It Does</h3><p>When a Spring Boot service starts, it automatically calls this API to register itself in the registry.</p><p>Spring Cloud Eureka Client internally builds this request.</p><h3>📦 Sample Request Body</h3><pre>{<br>  &quot;instance&quot;: {<br>    &quot;instanceId&quot;: &quot;order-service:8081&quot;,<br>    &quot;hostName&quot;: &quot;localhost&quot;,<br>    &quot;app&quot;: &quot;ORDER-SERVICE&quot;,<br>    &quot;ipAddr&quot;: &quot;127.0.0.1&quot;,<br>    &quot;status&quot;: &quot;UP&quot;,<br>    &quot;port&quot;: {<br>      &quot;$&quot;: 8081,<br>      &quot;@enabled&quot;: true<br>    },<br>    &quot;healthCheckUrl&quot;: &quot;http://localhost:8081/actuator/health&quot;,<br>    &quot;homePageUrl&quot;: &quot;http://localhost:8081/&quot;,<br>    &quot;vipAddress&quot;: &quot;ORDER-SERVICE&quot;,<br>    &quot;secureVipAddress&quot;: &quot;ORDER-SERVICE&quot;,<br>    &quot;dataCenterInfo&quot;: {<br>      &quot;@class&quot;: &quot;com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo&quot;,<br>      &quot;name&quot;: &quot;MyOwn&quot;<br>    }<br>  }<br>}</pre><h3>📤 Response</h3><pre>HTTP 204 No Content</pre><p>✔ No response body<br> ✔ Registry updated internally</p><h3>2️⃣ Heartbeat (Lease Renewal)</h3><h3>Endpoint</h3><pre>PUT /eureka/apps/{APP_NAME}/{INSTANCE_ID}</pre><p>Example:</p><pre>PUT http://localhost:8761/eureka/apps/ORDER-SERVICE/order-service:8081</pre><h3>📌 What It Does</h3><p>Every 30 seconds (default), the service sends a heartbeat.</p><p>If heartbeats stop, Eureka will remove the instance after lease expiration.</p><p>Default Config:</p><pre>eureka.instance.lease-renewal-interval-in-seconds=30<br>eureka.instance.lease-expiration-duration-in-seconds=90</pre><h3>📤 Response</h3><pre>HTTP 200 OK</pre><h3>3️⃣ Deregister a Service</h3><h3>Endpoint</h3><pre>DELETE /eureka/apps/{APP_NAME}/{INSTANCE_ID}</pre><p>Example:</p><pre>DELETE http://localhost:8761/eureka/apps/ORDER-SERVICE/order-service:8081</pre><h3>📌 What It Does</h3><p>When a service shuts down gracefully, it deregisters itself.</p><p>This prevents stale instances in the registry.</p><h3>📤 Response</h3><pre>HTTP 200 OK</pre><h3>4️⃣ Fetch All Registered Applications</h3><h3>Endpoint</h3><pre>GET /eureka/apps</pre><p>Example:</p><pre>GET http://localhost:8761/eureka/apps</pre><h3>📌 What It Does</h3><p>Returns the full registry.</p><p>Used by:</p><ul><li>API Gateway</li><li>Other microservices</li><li>Discovery Client</li></ul><h3>📦 Sample Response</h3><pre>{<br>  &quot;applications&quot;: {<br>    &quot;versions__delta&quot;: &quot;1&quot;,<br>    &quot;apps__hashcode&quot;: &quot;UP_1_&quot;,<br>    &quot;application&quot;: [<br>      {<br>        &quot;name&quot;: &quot;ORDER-SERVICE&quot;,<br>        &quot;instance&quot;: [<br>          {<br>            &quot;instanceId&quot;: &quot;order-service:8081&quot;,<br>            &quot;hostName&quot;: &quot;localhost&quot;,<br>            &quot;app&quot;: &quot;ORDER-SERVICE&quot;,<br>            &quot;ipAddr&quot;: &quot;127.0.0.1&quot;,<br>            &quot;status&quot;: &quot;UP&quot;,<br>            &quot;port&quot;: {<br>              &quot;$&quot;: 8081,<br>              &quot;@enabled&quot;: true<br>            }<br>          }<br>        ]<br>      }<br>    ]<br>  }<br>}</pre><h3>5️⃣ Fetch Specific Application</h3><h3>Endpoint</h3><pre>GET /eureka/apps/{APP_NAME}</pre><p>Example:</p><pre>GET http://localhost:8761/eureka/apps/ORDER-SERVICE</pre><h3>📌 What It Does</h3><p>Returns all instances of a specific service.</p><p>Used by Gateway for routing.</p><h3>6️⃣ Fetch Single Instance</h3><h3>Endpoint</h3><pre>GET /eureka/apps/{APP_NAME}/{INSTANCE_ID}</pre><p>Example:</p><pre>GET http://localhost:8761/eureka/apps/ORDER-SERVICE/order-service:8081</pre><h3>📌 What It Does</h3><p>Returns detailed metadata of a specific instance.</p><h3>7️⃣ Fetch Registry Delta</h3><h3>Endpoint</h3><pre>GET /eureka/apps/delta</pre><h3>📌 What It Does</h3><p>Returns only changes since last fetch.</p><p>Optimizes network usage.</p><p>Used internally by Eureka clients.</p><h3>Sample Response</h3><pre>{<br>  &quot;applications&quot;: {<br>    &quot;versions__delta&quot;: &quot;2&quot;,<br>    &quot;application&quot;: [<br>      {<br>        &quot;name&quot;: &quot;PAYMENT-SERVICE&quot;,<br>        &quot;instance&quot;: [<br>          {<br>            &quot;instanceId&quot;: &quot;payment-service:8082&quot;,<br>            &quot;status&quot;: &quot;UP&quot;<br>          }<br>        ]<br>      }<br>    ]<br>  }<br>}</pre><h3>8️⃣ Update Instance Status</h3><h3>Endpoint</h3><pre>PUT /eureka/apps/{APP_NAME}/{INSTANCE_ID}/status?value=OUT_OF_SERVICE</pre><p>Example:</p><pre>PUT /eureka/apps/ORDER-SERVICE/order-service:8081/status?value=DOWN</pre><h3>📌 What It Does</h3><p>Allows manual status updates:</p><ul><li>UP</li><li>DOWN</li><li>OUT_OF_SERVICE</li><li>STARTING</li></ul><p>Useful for maintenance or circuit breaking.</p><h3>9️⃣ Cancel Instance Lease (Force Expire)</h3><h3>Endpoint</h3><pre>DELETE /eureka/apps/{APP_NAME}/{INSTANCE_ID}?status=DOWN</pre><p>Forcefully remove instance.</p><h3>🔎 Internal Registry Structure</h3><p>Internally Eureka maintains:</p><pre>ConcurrentHashMap&lt;String, Map&lt;String, Lease&lt;InstanceInfo&gt;&gt;&gt;</pre><p>Which maps:</p><pre>APP_NAME → INSTANCE_ID → Lease → InstanceInfo</pre><p>That’s how fast lookup works.</p><h3>🧠 How API Gateway Uses These Endpoints</h3><p>When API Gateway starts:</p><ol><li>It registers itself → POST /eureka/apps</li><li>It fetches registry → GET /eureka/apps</li><li>It caches results locally</li><li>It refreshes periodically</li><li>It routes using:</li></ol><pre>lb://SERVICE-NAME</pre><p>Spring Cloud LoadBalancer selects an instance (Round Robin).</p><h3>🔁 Complete Flow Summary</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WAfuOeC2prT1gnupYRkKZw.png" /></figure><h3>🚪 How Spring Cloud Gateway (WebMVC) Works Internally</h3><p>In our API Gateway project, we added this dependency:</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;<br>    &lt;artifactId&gt;spring-cloud-starter-gateway-server-webmvc&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><p>Most developers just add this and configure routes.</p><p>But what actually happens internally?</p><p>Let’s break it down step by step.</p><h3>🔎 1️⃣ What Is spring-cloud-starter-gateway-server-webmvc?</h3><p>This is the <strong>Spring MVC-based version</strong> of Spring Cloud Gateway.</p><p>There are two major Gateway stacks:</p><p>TypeBased OnRuntime</p><p>spring-cloud-starter-gatewayWebFluxReactive (Netty)spring-cloud-starter-gateway-server-webmvcSpring MVCServlet (Tomcat/Jetty)</p><p>We are using the <strong>Servlet-based gateway</strong>, which means:</p><p>✔ Runs on embedded Tomcat<br> ✔ Uses DispatcherServlet<br> ✔ Works with traditional Spring MVC stack<br> ✔ Compatible with blocking code</p><p>This is useful when your ecosystem is MVC-based and not reactive.</p><h3>🧠 2️⃣ How Gateway Processes a Request (Internal Flow)</h3><p>Let’s say a client calls:</p><pre>GET http://localhost:8080/api/orders/123</pre><p>Here is what happens internally:</p><h3>Step 1: Request Hits DispatcherServlet</h3><p>Since this is WebMVC-based:</p><pre>DispatcherServlet<br>   ↓<br>HandlerMapping<br>   ↓<br>Route Matching</pre><p>Gateway registers its own <strong>HandlerMapping implementation</strong>:</p><h3>🔹 GatewayMvcHandlerMapping</h3><p>This class:</p><ul><li>Matches incoming request path</li><li>Finds a matching Route</li><li>Creates a handler chain</li></ul><h3>Step 2: Route Matching</h3><p>Routes are defined either in:</p><ul><li>application.yml</li><li>Java config (RouteLocator)</li><li>Discovery-based dynamic routes</li></ul><p>Example:</p><pre>spring:<br>  cloud:<br>    gateway:<br>      mvc:<br>        routes:<br>          - id: order_route<br>            uri: lb://ORDER-SERVICE<br>            predicates:<br>              - Path=/api/orders/**</pre><p>The Path predicate is evaluated by:</p><h3>🔹 PathRoutePredicateFactory</h3><p>This checks:</p><pre>Does request path match /api/orders/** ?</pre><p>If YES → route selected<br> If NO → next route evaluated</p><h3>🛣 3️⃣ How lb://ORDER-SERVICE Works</h3><p>This is where Eureka integration happens.</p><p>When Gateway sees:</p><pre>uri: lb://ORDER-SERVICE</pre><p>It triggers:</p><h3>🔹 LoadBalancerClient</h3><p>Internally it uses:</p><pre>org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier</pre><p>This class:</p><ul><li>Fetches instances from Eureka</li><li>Caches them</li><li>Supplies instance list to LoadBalancer</li></ul><p>Then:</p><h3>🔹 RoundRobinLoadBalancer</h3><p>Select one instance from the available service list.</p><p>Example:</p><p>If the Eureka registry has:</p><pre>ORDER-SERVICE → [8081, 8082]</pre><p>Load balancer selects:</p><ul><li>Request 1 → 8081</li><li>Request 2 → 8082</li><li>Request 3 → 8081</li></ul><h3>🔁 4️⃣ How Gateway Registers Itself in Eureka</h3><p>Because we add:</p><pre>@EnableDiscoveryClient</pre><p>Gateway becomes a Eureka client.</p><p>On startup:</p><ol><li>Registers → POST /eureka/apps/API-GATEWAY</li><li>Sends heartbeats → PUT /eureka/apps/API-GATEWAY/{id}</li><li>Fetches registry → GET /eureka/apps</li></ol><p>Gateway keeps local registry cache updated.</p><h3>🧩 5️⃣ Which Classes Register Endpoints?</h3><p>Here are the key internal classes:</p><p>ResponsibilityClassRoute storageRouteDefinitionRoute locatorRouteDefinitionRouteLocatorMVC handler mappingGatewayMvcHandlerMappingPredicate evaluationRoutePredicateHandlerMappingFilter chainGatewayFilterChainLoad balancingLoadBalancerClientFilter</p><h3>🧱 6️⃣ How Routes Are Built in Java</h3><p>You can also define routes programmatically:</p><pre>@Configuration<br>public class GatewayConfig {<br>@Bean<br>    public RouterFunction&lt;?&gt; gatewayRoutes() {<br>        return route(&quot;order_route&quot;)<br>                .route(RequestPredicates.path(&quot;/api/orders/**&quot;),<br>                        HandlerFunctions.http(&quot;lb://ORDER-SERVICE&quot;))<br>                .build();<br>    }<br>}</pre><p>Behind the scenes:</p><ul><li>Creates RouteDefinition</li><li>Registers it inside RouteLocator</li><li>GatewayMvcHandlerMapping uses it</li></ul><h3>🔐 7️⃣ Filter Chain Execution</h3><p>After route matching:</p><p>Request goes through:</p><pre>GlobalFilters<br>↓<br>Route-specific Filters<br>↓<br>LoadBalancer Filter<br>↓<br>Forward to downstream service</pre><p>Important filter:</p><h3>🔹 LoadBalancerClientFilter</h3><p>Rewrites:</p><pre>lb://ORDER-SERVICE</pre><p>Into:</p><pre>http://localhost:8081</pre><p>Then forwards the request.</p><h3>📦 8️⃣ How Path Rewriting Works</h3><p>Example:</p><pre>/api/orders/123</pre><p>You can rewrite path:</p><pre>filters:<br>  - RewritePath=/api/orders/(?&lt;segment&gt;.*), /$\{segment}</pre><p>Internally handled by:</p><h3>🔹 RewritePathGatewayFilterFactory</h3><h3>🗂 9️⃣ How Gateway Maintains Registry Cache</h3><p>Spring Cloud creates:</p><pre>CachingServiceInstanceListSupplier</pre><p>Which:</p><ul><li>Fetches instance list</li><li>Stores locally</li><li>Refreshes periodically</li><li>Reduces network calls to Eureka</li></ul><h3>🧪 1️⃣0️⃣ Full End-to-End Flow</h3><ol><li>Client → Gateway</li><li>DispatcherServlet</li><li>GatewayMvcHandlerMapping</li><li>Path Predicate match</li><li>Route selected</li><li>LoadBalancerClientFilter</li><li>Fetch instances from Eureka</li><li>RoundRobin selects instance</li><li>Request forwarded</li><li>Response returned</li></ol><h3>🎯 Why This Understanding Is Important</h3><p>Most developers think:</p><blockquote><em>“Gateway automatically routes.”</em></blockquote><p>But internally:</p><ul><li>RouteDefinition stores metadata</li><li>PredicateFactories match paths</li><li>Filters manipulate request/response</li><li>LoadBalancer rewrites URI</li><li>DiscoveryClient pulls registry from Eureka</li></ul><p>When debugging production issues, this knowledge saves hours.</p><h3>🔜 Coming Up Next</h3><p><strong>🔍 Part 3 — Part 3 — Inside API Gateway: Eureka-Based Routing, Filters, Authentication, and Real-World Production Patterns</strong><br> ⚖️ <strong>Part 4</strong> — CAP Theorem, Failures &amp; Why Eureka Chooses Availability<br>Stay tuned 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eabe1af7ca50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Service Registry & API Gateway in Spring Boot — From Setup to Failure Handling]]></title>
            <link>https://medium.com/@jai.mail67/service-registry-api-gateway-in-spring-boot-from-setup-to-failure-handling-dbe9f2fa18be?source=rss-dfe3bd04bc1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbe9f2fa18be</guid>
            <category><![CDATA[eureka]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[spring-cloud]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Jagnya Datta Panigrahi]]></dc:creator>
            <pubDate>Wed, 11 Feb 2026 06:19:17 GMT</pubDate>
            <atom:updated>2026-02-21T15:23:26.685Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Owgqo74bED7MGfCY1Z6PQ.jpeg" /></figure><h3>📌 Series Introduction (Very Important)</h3><blockquote><em>Service discovery is one of the most critical — and most misunderstood — parts of microservices.</em></blockquote><blockquote><em>In this blog series, we’ll build a complete Spring Boot microservices setup using </em><strong><em>Eureka Server</em></strong><em>, </em><strong><em>API Gateway</em></strong><em>, and a sample </em><strong><em>Order Service</em></strong><em>, and then gradually peel back the layers to understand how everything works internally — including failures and CAP theorem trade-offs.</em></blockquote><h3>🧩 Microservices with Eureka &amp; API Gateway — Blog Series</h3><p><strong>🚀 Part 1 — Setup &amp; Run: Eureka Server, API Gateway, and Order Service</strong></p><p><strong>🧠 Part 2 — Important Annotations, Complete Application Code Deep Dive &amp; Internal API Gateway Request Resolution Flow with Eureka</strong></p><p><strong>🔍 Part 3 —Part 3 — Inside API Gateway: Eureka-Based Routing, Filters, Authentication, and Real-World Production Patterns</strong></p><p><strong>⚖️ Part 4 — CAP Theorem, Failures, and Why Eureka Chooses Availability</strong></p><p>👉 <strong>This article focuses on Part 1.</strong></p><h3>📂 Sample Repositories Used in This Series</h3><p>To keep this blog <strong>practical and reproducible</strong>, all examples in this series are based on the following <strong>three independent Spring Boot repositories</strong>.</p><p>Please <strong>clone these repositories before continuing</strong>:</p><ul><li><strong>Eureka Server</strong><br> <a href="https://github.com/jagnyadatta67/spring-cloud-eureka-server.git">https://github.com/jagnyadatta67/spring-cloud-eureka-server.git</a></li><li><strong>Order Service</strong><br> <a href="https://github.com/jagnyadatta67/order-service.git">https://github.com/jagnyadatta67/order-service.git</a></li><li><strong>API Gateway</strong><br> <a href="https://github.com/jagnyadatta67/api-gateway.git">https://github.com/jagnyadatta67/api-gateway.git</a></li></ul><p>Each repository represents <strong>one microservice</strong>, following real-world separation of concerns.</p><blockquote><em>📌 </em><strong><em>Important</em></strong><em><br> Throughout this blog series, </em><strong><em>all code snippets, configuration examples, logs, and behaviors refer strictly to these repositories</em></strong><em>.<br> No pseudo-code, no hidden assumptions</em></blockquote><h3>🤔 Why Do We Need a Service Registry? (A Simple, Real Example)</h3><p>A <strong>microservice</strong> is simply an application split into smaller services, where each service does one job. For example, in an e-commerce system, you might have an <strong>Order Service</strong>, <strong>Payment Service</strong>, and <strong>Inventory Service</strong>, each running as a separate application.</p><p>Now imagine this real situation:<br> Your <strong>Order Service</strong> is running on localhost:8081 today, but tomorrow it crashes and restarts on localhost:8083. Later, during high traffic, you run <strong>two instances</strong> of Order Service on different ports. If other services or the API Gateway are using <strong>hardcoded URLs</strong>, everything breaks immediately.</p><p>This is the core problem with microservices: <strong>services keep changing their location</strong>.</p><p>A <strong>Service Registry</strong> solves this by acting like a live phonebook. When a service starts, it tells the registry, <em>“I am Order Service, and I am running here.”</em> When it stops or crashes, the registry eventually removes it. Other services never call fixed URLs — they simply ask, <em>“Give me an active Order Service.”</em></p><p><strong>Eureka Server</strong> is Spring’s implementation of this idea. It keeps track of all running service instances and their health using heartbeats. <strong>Spring Cloud makes this automatic</strong>, so services register themselves and discover others using only a logical name like ORDER-SERVICE. This allows applications to scale, recover from failures, and route traffic dynamically — without changing any code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N7xj6f4ne7Rbs1-Kp7fQNg.png" /><figcaption>MICROSERVICE ARCHITECTURE</figcaption></figure><h3>📦 Projects in This Setup</h3><p>We will create <strong>three independent Spring Boot applications</strong>:</p><ol><li><strong>Eureka Server</strong> — Service Registry</li><li><strong>Order Service</strong> — Sample business service (run multiple instances)</li><li><strong>API Gateway</strong> — Entry point + load balancer</li></ol><p>Each application has a <strong>single responsibility</strong>.</p><h3><strong>Eureka Server</strong> — Service Registry</h3><p>Since this is your Eureka Server project: <br>✅ Clone the Repository (First Time)</p><p>Open a terminal or command and clone the git repo for practice</p><pre>git clone https://github.com/jagnyadatta67/spring-cloud-eureka-server.git</pre><p>OR</p><h3>✅ 1️⃣ Go to Spring Initializr</h3><p>👉 <a href="https://start.spring.io/">https://start.spring.io</a></p><p>Select:</p><ul><li><strong>Project</strong>: Maven</li><li><strong>Language</strong>: Java</li><li><strong>Spring Boot</strong>: (Use latest stable 3.x — avoid 4.0.2 unless officially supported in your setup)</li><li><strong>Group</strong>: com.self.springcloud.gateway</li><li><strong>Artifact</strong>: springGateWay</li><li><strong>Java</strong>: 21</li></ul><h3>✅ 2️⃣ Add Dependencies</h3><ul><li>✅ <strong>Eureka Server</strong></li><li>✅ (Optional) Spring Web</li></ul><h3>✅ 3️⃣ Download &amp; Open in IntelliJ</h3><ul><li>Extract zip</li><li>Open in IntelliJ</li><li>Let Maven download dependencies</li></ul><h3>✅ 4️⃣ Add Main Annotation</h3><p>In your main class:</p><pre>@SpringBootApplication<br>@EnableEurekaServer<br>public class SpringGateWayApplication {<br><br>public static void main(String[] args) {<br>        SpringApplication.run(SpringGateWayApplication.class, args);<br>    }<br>}</pre><h3>Why @EnableEurekaServer?</h3><p>This tells Spring:</p><blockquote><em>“Turn this application into a Eureka Service Registry and start listening for service registrations.”</em></blockquote><p>Without this, the application will behave like a normal Spring Boot app and <strong>will not act as a Service Registry</strong>.<br> Services will not be able to register, and the Eureka dashboard will not be available.</p><p>Add to the application. property :</p><pre>spring.application.name=eureka-server<br>server.port=8761<br># Don&#39;t register itself as a client<br>eureka.client.register-with-eureka=false<br>eureka.client.fetch-registry=false<br>eureka.server.enable-self-preservation=true<br><br>logging.level.com.netflix.eureka=DEBUG<br>logging.level.com.netflix.discovery=DEBUG<br>logging.level.com.netflix.eureka.registry=DEBUG<br>logging.level.com.netflix.eureka.resources=DEBUG</pre><p>This tells Spring:</p><blockquote><em>“Run this application as a standalone Eureka Server on port 8761, and do not treat it as a discovery client.”</em></blockquote><ul><li>spring.application.name=eureka-server<br> Gives the application a logical name.</li><li>server.port=8761<br> Runs Eureka on the default registry port.</li><li>register-with-eureka=false<br> Prevents the server from registering itself as a client.</li><li>fetch-registry=false<br> Tells the server not to fetch registry data from another Eureka server.</li><li>enable-self-preservation=true<br> Protects the registry from mass eviction during network failures.</li></ul><p>Without these settings, the server may behave like a normal client or attempt unnecessary peer communication.✅ 6️⃣ Run Application <br>mvn spring-boot: run <br>And hit <a href="http://localhost:8761/">http://localhost:8761</a>, and u will see this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nBZYeHd5L81fZrFTLH8isg.png" /></figure><h3>Order Service — Sample Business Service (Run Multiple Instances)</h3><p>This is your actual business service that will:</p><ul><li>Register itself with Eureka</li><li>Expose REST APIs</li><li>Be load-balanced by API Gateway</li><li>Run on multiple ports</li></ul><p>Since this is your Order Service project:</p><h3>✅ Clone the Repository (Recommended)</h3><p>Open a terminal and clone the repo:</p><pre>git clone https://github.com/jagnyadatta67/order-service.git</pre><p>Open the project in IntelliJ.</p><p>OR</p><p>✅ 1️⃣ Go to Spring Initializr (Manual Setup)</p><p>👉 <a href="https://start.spring.io/">https://start.spring.io</a></p><p>Select:</p><ul><li><strong>Project:</strong> Maven</li><li><strong>Language:</strong> Java</li><li><strong>Spring Boot:</strong> Use latest stable 3.x</li><li><strong>Group:</strong> com.self.springcloud.services</li><li><strong>Artifact:</strong> order-service</li><li><strong>Java:</strong> 21</li></ul><h3>✅ 2️⃣ Add Dependencies</h3><p>✅ Spring Web<br> ✅ Eureka Discovery Client</p><h3>✅ 3️⃣ Download &amp; Open in IntelliJ</h3><ul><li>Extract zip</li><li>Open project in IntelliJ</li><li>Let Maven download dependencies</li></ul><h3>✅ 4️⃣ Add Main Class Annotation</h3><pre>@SpringBootApplication<br>@EnableDiscoveryClient<br>public class OrderServiceApplication {<br>public static void main(String[] args) {<br>		SpringApplication.run(OrderServiceApplication.class, args);<br>	}<br>}</pre><h3>Why @EnableDiscoveryClient?</h3><p>This tells Spring:</p><blockquote><em>“Register this service with Eureka when the application starts.”</em></blockquote><p>Without this, the service will not appear in the Eureka dashboard.</p><h3>✅ 5️⃣ Add REST Controller</h3><p>Create OrderController:</p><pre>@RestController<br>@RequestMapping(&quot;/api/orders&quot;)<br>public class OrderController {<br>@Value(&quot;${server.port}&quot;)<br>    private String port;<br> @GetMapping(&quot;/hello&quot;)<br>    public String hello() {<br>        return &quot;Hello from Order Service running on port: &quot; + port;<br>    }<br>@GetMapping(&quot;/{orderId}&quot;)<br>    public String getOrder(@PathVariable String orderId) {<br>        return &quot;Order details for order ID: &quot; + orderId + &quot; from port: &quot; + port;<br>    }<br>}</pre><h3>Why print the port?</h3><p>This helps us visually confirm:</p><ul><li>Which instance handled the request</li><li>That load balancing is actually working</li></ul><h3>✅ 6️⃣ Add application.properties</h3><pre># Service name (must match what Gateway uses)<br>spring.application.name=order-service<br># Port for this instance<br>server.port=8081<br># Eureka Server location<br>eureka.client.service-url.defaultZone=http://localhost:8761/eureka/<br># Register with Eureka<br>eureka.client.register-with-eureka=true<br>eureka.client.fetch-registry=true<br># Prefer IP address in Eureka dashboard<br>eureka.instance.prefer-ip-address=true</pre><h3>🔍 Why Each Property Matters</h3><p>PropertyReasonspring.application.nameThis is the logical name used for service discoveryserver.portEach instance must run on a different portdefaultZoneLocation of Eureka Serverregister-with-eurekaEnables registrationfetch-registryAllows this service to discover othersprefer-ip-addressCleaner registration in dashboard</p><h3>✅ 7️⃣ Run the Application</h3><pre>mvn spring-boot:run</pre><p>Or from IntelliJ → Run main class.</p><h3>✅ 8️⃣ Verify in Eureka Dashboard</h3><p>Open:</p><pre>http://localhost:8761</pre><p>You should see:</p><pre>ORDER-SERVICE<br>Status: UP</pre><h3>🔁 Running Multiple Instances (Important for Load Balancing)</h3><p>To simulate scaling:</p><h3>Run first instance (default 8081)</h3><pre>mvn spring-boot:run</pre><h3>Run the second instance on different port</h3><pre>mvn spring-boot:run -Dspring-boot.run.arguments=--server.port=8082</pre><p>Now check Eureka dashboard again.</p><p>You should see:</p><pre>ORDER-SERVICE<br>  Instance 1 → 8081<br>  Instance 2 → 8082</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tyyY64aSGNjDr8N7x4yiUg.png" /></figure><h3>🎯 What We Achieved</h3><ul><li>Order Service registers automatically</li><li>Multiple instances appear in Eureka</li><li>Each instance exposes REST APIs</li><li>Ready to be load-balanced by API Gateway</li></ul><h3>🚪 API Gateway This is your <strong>Entry Point + Load Balancer</strong> that will:</h3><ul><li>Register itself with Eureka</li><li>Discover services dynamically</li><li>Route incoming requests</li><li>Apply Load Balancing</li><li>Forward traffic to correct service instance</li></ul><p>Since this is your API Gateway project:</p><h3>✅ Clone the Repository (Recommended)</h3><p>Open a terminal and clone the repo:</p><pre>git clone https://github.com/jagnyadatta67/api-gateway.git</pre><p>Open the project in IntelliJ.</p><p>OR</p><h3>✅ 1️⃣ Go to Spring Initializr (Manual Setup)</h3><p>👉 <a href="https://start.spring.io/">https://start.spring.io</a></p><p>Select:</p><p><strong>Project: Maven<br> Language: Java<br> Spring Boot: Use latest stable <br> Group: com.self.springcloud.services<br> Artifact: api-gateway<br> Java: 21</strong></p><h3>✅ 2️⃣ Add Dependencies</h3><p>✅ Spring Cloud Gateway (MVC)<br> ✅ Eureka Discovery Client<br> ✅ Spring AOP (Optional for logging/tracing)</p><h3>✅ 3️⃣ Download &amp; Open in IntelliJ</h3><ul><li>Extract zip</li><li>Open project in IntelliJ</li><li>Let Maven download dependencies</li></ul><h3>✅ 4️⃣ Add Main Class Annotation</h3><pre>@SpringBootApplication<br>@EnableDiscoveryClient<br>@EnableAspectJAutoProxy<br>public class ApiGatewayApplication {<br> public static void main(String[] args) {<br>        SpringApplication.run(ApiGatewayApplication.class, args);<br>    }<br>}</pre><h3>Why @EnableDiscoveryClient?</h3><p>This tells Spring:</p><p>“Register this Gateway with Eureka and fetch service registry.”</p><p>Without this, Gateway cannot discover Order Service.</p><h3>✅ 5️⃣ Add application.yml</h3><pre>spring:<br>  application:<br>    name: api-gateway<br>server:<br>  port: 8080<br>eureka:<br>  client:<br>    service-url:<br>      defaultZone: http://localhost:8761/eureka/<br>    register-with-eureka: true<br>    fetch-registry: true<br>  instance:<br>    prefer-ip-address: true</pre><h3>🔍 Why Each Property Matters</h3><p>PropertyReasonspring.application.nameLogical name for Gatewayserver.portEntry point portdefaultZoneLocation of Eureka Serverregister-with-eurekaRegisters Gatewayfetch-registryFetches service listprefer-ip-addressCleaner dashboard display</p><h3>✅ 6️⃣ Add Gateway Route Configuration</h3><p>Create GatewayConfig:</p><pre>@Configuration<br>public class GatewayConfig {@Bean<br>    public RouterFunction&lt;ServerResponse&gt; orderServiceRoute() {<br>        return route(&quot;order-service&quot;)<br>                .route(path(&quot;/api/orders/**&quot;), http())<br>                .filter(lb(&quot;ORDER-SERVICE&quot;))<br>                .build();<br>    }<br>}</pre><h3>What This Does</h3><ul><li>Matches incoming path /api/orders/**</li><li>Uses LoadBalancer</li><li>Resolves ORDER-SERVICE via Eureka</li><li>Forwards request to selected instance</li></ul><h3>✅ 7️⃣ Optional: Custom Load Balancer (Round Robin)</h3><p>I have implemented custom logging over:</p><h3>✅ 8️⃣ Run the Application</h3><pre>mvn spring-boot:run</pre><p>Or run main class from IntelliJ.</p><h3>✅ 9️⃣ Verify in Eureka Dashboard</h3><p>Open:</p><pre>http://localhost:8761</pre><p>You should see:</p><pre>API-GATEWAY → UP<br>ORDER-SERVICE → UP</pre><h3>🚀 Test Routing</h3><p>Call:</p><pre>http://localhost:8080/api/orders/hello</pre><p>Gateway will:</p><ol><li>Match route</li><li>Trigger LoadBalancer</li><li>Fetch instances from Eureka</li><li>Select instance (Round Robin)</li><li>Forward request</li></ol><h3>🔁 Verify Load Balancing</h3><p>If two Order Service instances running:</p><ul><li>8081</li><li>8082</li></ul><p>Hit the endpoint multiple times.</p><p>You will observe alternating ports in response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5PPwKyk5dUhg3SfZyzahMw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PdAA0mJABd82uflO2g7HOg.png" /></figure><p>From curl:</p><pre>Hello from Order Service running on port: 8082<br>Hello from Order Service running on port: 8081</pre><p>It alternated.</p><p>That means 👉 <strong>Load Balancing is working.</strong></p><p>Now let’s explain it clearly and nicely 👇</p><h3>🌐 How It Works (Gateway + LoadBalancer + Eureka)</h3><h3>🧩 Step 1 — Order Services Register to Eureka</h3><p>You started:</p><ul><li>ORDER-SERVICE → 8081</li><li>ORDER-SERVICE → 8082</li></ul><p>Both register themselves to <strong>Eureka Server (8761)</strong>.</p><p>Eureka now stores:</p><pre>ORDER-SERVICE<br>   → 8081<br>   → 8082</pre><p>Eureka acts like a <strong>phone directory of services</strong>.</p><h3>🚪 Step 2 — Request Hits API Gateway</h3><p>You call:</p><pre>http://localhost:8080/api/orders/hello</pre><p>Request goes to:</p><p>👉 API Gateway (Port 8080)</p><p>Gateway checks route:</p><pre>/api/orders/**  → ORDER-SERVICE</pre><h3>⚖ Step 3 — LoadBalancer Is Triggered</h3><p>Gateway does NOT know which port to call.</p><p>So it asks:</p><blockquote><em>“Hey LoadBalancer, give me one instance of ORDER-SERVICE.”</em></blockquote><p>LoadBalancer:</p><ol><li>Fetches instance list from Eureka</li><li>Picks one using <strong>Round Robin algorithm</strong></li></ol><h3>🔄 Step 4 — Round Robin Selection</h3><p>First request → 8082<br> Second request → 8081<br> Third request → 8082<br> Fourth request → 8081</p><p>Alternating = Round Robin working.</p><p>That’s why your curl shows different ports.</p><h3>🚀 Step 5 — Gateway Forwards Request</h3><p>Gateway replaces:</p><pre>http://ORDER-SERVICE/api/orders/hello</pre><p>With:</p><pre>http://localhost:8081/api/orders/hello</pre><p>or</p><pre>http://localhost:8082/api/orders/hello</pre><p>Then forwards the request.</p><h3>🎯 Final Flow (Simple)</h3><pre>Client<br>   ↓<br>API Gateway (8080)<br>   ↓<br>LoadBalancer<br>   ↓<br>Eureka (Service Registry)<br>   ↓<br>Chosen Order Service (8081 or 8082)</pre><h3>🧠 What We Just Proved</h3><p>✔ Service discovery is working<br> ✔ Gateway routing is working<br> ✔ Load balancing is working<br> ✔ Multiple instances are active<br> ✔ Eureka registry is live</p><h3>💡 One-Line Explanation</h3><blockquote><em>The API Gateway receives the request, uses Spring Cloud LoadBalancer to fetch available instances from Eureka, selects one using Round Robin, and forwards the request to the chosen Order Service instance.</em></blockquote><h3>🎯 Final Conclusion</h3><p>We successfully built a complete microservices architecture using <strong>Eureka Server, API Gateway, and Order Service</strong>.</p><p>Service registration, dynamic discovery, and Round Robin load balancing are all working as expected.</p><p>Now that the foundation is ready, let’s dive deeper.</p><h3>🔜 Coming Up Next</h3><p><strong>Part 2 Important Annotations, Complete Application Code Deep Dive &amp; Internal API Gateway Request Resolution Flow with Eureka</strong></p><p><strong>🔍 Part 3 — Part 3 — Inside API Gateway: Eureka-Based Routing, Filters, Authentication, and Real-World Production Patterns<br> ⚖️ Part 4 — CAP Theorem, Failures &amp; Why Eureka Chooses Availability</strong></p><p>Stay tuned 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbe9f2fa18be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Additional Essential Java Features After Java 8]]></title>
            <link>https://medium.com/@jai.mail67/additional-essential-java-features-after-java-8-435647eeeb3d?source=rss-dfe3bd04bc1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/435647eeeb3d</guid>
            <category><![CDATA[java-17-features]]></category>
            <category><![CDATA[modern-java-features]]></category>
            <category><![CDATA[advanced-java-feature]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java-21-features]]></category>
            <dc:creator><![CDATA[Jagnya Datta Panigrahi]]></dc:creator>
            <pubDate>Thu, 05 Feb 2026 17:16:23 GMT</pubDate>
            <atom:updated>2026-02-06T03:39:48.806Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Owgqo74bED7MGfCY1Z6PQ.jpeg" /></figure><h3>Introduction: Stop Writing Java Like It’s 2014</h3><p>Let me be honest with you. If you’re still writing Java the way you did in 2014, you’re probably writing 2–3x as much code as necessary. I’ve been there. For years, I watched Java evolve, thinking “I’ll upgrade when I have time” or “Java 8 is good enough.”</p><p>Then I spent a weekend exploring the new features added after Java 8, and I saw significant changes in coding patterns and Java’s modern capabilities.</p><p><strong>The results shocked me:</strong></p><ul><li><strong>40% reduction in codebase size</strong> — Less boilerplate, more business logic</li><li><strong>10x improvement in API response times</strong> — Thanks to Virtual Threads</li><li><strong>Bug fixes that took hours now took minutes</strong> — Helpful NPEs pinpoint issues instantly</li><li><strong>Code that was “clever” became simple and readable</strong> — Pattern matching eliminated complex conditionals</li></ul><p>Here’s the truth: <strong>Modern Java (Java 9–21) isn’t just about new syntax.</strong> It’s about writing less code, preventing bugs at compile-time, and unlocking performance you didn’t know was possible.</p><p>In this article, I’ll walk you through <strong>15 essential features</strong> that transformed how I write Java. These aren’t theoretical features from the JEP index — these are battle-tested improvements I use every single day in production systems.</p><h3>1. Stream API Enhancements — takeWhile() &amp; dropWhile()</h3><p><strong>Introduced in:</strong> Java 9</p><p>These methods allow <strong>short-circuiting streams</strong> based on a condition, instead of scanning the entire stream like filter().</p><h3>Why it matters</h3><ul><li>Stops processing as soon as the condition fails</li><li>Faster for large or ordered data sets</li><li>Expresses intent more clearly than filter()</li></ul><h3>Before (using filter() — scans entire stream)</h3><pre>List&lt;Integer&gt; result = numbers.stream()<br>    .filter(n -&gt; n &lt; 5)<br>    .toList();</pre><p>👉 Processes <strong>all elements</strong>, even after the condition fails.</p><p>After (short-circuiting)</p><pre>// Data: [1, 2, 4, 6, 9, 10, 12]<br>numbers.stream()<br>    .takeWhile(n -&gt; n &lt; 5)<br>    .toList();   // [1, 2, 4]<br>numbers.stream()<br>    .dropWhile(n -&gt; n &lt; 5)<br>    .toList();   // [6, 9, 10, 12]<br><br></pre><p>👉 One-line takeaway</p><p><strong>takeWhile and </strong><strong>dropWhile stop early, making streams faster and clearer.</strong></p><h3>2. Stream::toList() — The Modern Stream Finalizer</h3><p><strong>Introduced in:</strong> Java 16</p><p>A concise way to convert a stream into an <strong>unmodifiable List</strong>.</p><h3>Before (verbose)</h3><pre>List&lt;String&gt; names = employees.stream()<br>    .map(Employee::getName)<br>    .collect(Collectors.toList());</pre><h3>After (clean &amp; safe)</h3><pre>List&lt;String&gt; names = employees.stream()<br>    .map(Employee::getName)<br>    .toList();</pre><p>✔ Less code<br> ✔ No Collectors<br> ✔ Immutable result</p><p>One-line takeaway</p><p>👉 <strong>toList() is the simplest and safest way to finish a stream.</strong></p><h3>3. Records — Immutable Data Carriers</h3><p><strong>Introduced in:</strong> Java 16</p><p>Records remove boilerplate for simple data-holding classes.</p><h3>Before (classic POJO)</h3><pre>class User {<br>    private final String name;<br>    private final int age;<br>    // constructor, getters, equals, hashCode, toString<br>}</pre><h3>After (record)</h3><pre>record User(String name, int age) {}</pre><p>✔ Immutable<br> ✔ Auto-generated methods<br> ✔ Perfect for DTOs</p><p>👉 One-line takeaway</p><p><strong>Records give you clean, immutable data classes with almost no code.</strong></p><h3>4. Sequenced Collections — Consistent Collection APIs</h3><p><strong>Introduced in:</strong> Java 21<br> <strong>Why it matters:</strong> Finally, a uniform API for accessing first/last elements across different collection types.</p><h4>The Problem Before Java 21</h4><pre>// Inconsistent APIs across collection types<br>List&lt;String&gt; list = new ArrayList&lt;&gt;();<br>String firstList = list.get(0);                    // get(0)<br>String lastList = list.get(list.size() - 1);       // get(size-1)</pre><pre>Deque&lt;String&gt; deque = new ArrayDeque&lt;&gt;();<br>String firstDeque = deque.getFirst();              // getFirst()<br>String lastDeque = deque.getLast();                // getLast()</pre><pre>SortedSet&lt;String&gt; set = new TreeSet&lt;&gt;();<br>String firstSet = set.first();                     // first()<br>String lastSet = set.last();                       // last()</pre><pre>// No easy way to reverse iterate consistently</pre><h4>The Solution: Sequenced Collections</h4><pre>public class SequencedCollectionExample {<br>    <br>    public static void main(String[] args) {<br>        // All these implement SequencedCollection<br>        SequencedCollection&lt;String&gt; list = new ArrayList&lt;&gt;();<br>        SequencedCollection&lt;String&gt; deque = new ArrayDeque&lt;&gt;();<br>        <br>        // Uniform API across all collection types<br>        list.addFirst(&quot;first&quot;);<br>        list.addLast(&quot;last&quot;);<br>        <br>        String first = list.getFirst();<br>        String last = list.getLast();<br>        <br>        // Easy reversal<br>        SequencedCollection&lt;String&gt; reversed = list.reversed();<br>        <br>        // Works with sets too!<br>        SequencedSet&lt;Integer&gt; sortedSet = new TreeSet&lt;&gt;();<br>        sortedSet.addAll(List.of(5, 2, 8, 1, 9));<br>        <br>        System.out.println(&quot;First: &quot; + sortedSet.getFirst());  // 1<br>        System.out.println(&quot;Last: &quot; + sortedSet.getLast());    // 9<br>        <br>        SequencedSet&lt;Integer&gt; descending = sortedSet.reversed();<br>        System.out.println(&quot;Reversed: &quot; + descending); // [9, 8, 5, 2, 1]<br>    }<br>}</pre><p><strong>New Interfaces:</strong></p><ul><li>SequencedCollection&lt;E&gt; - Ordered collections (List, Deque)</li><li>SequencedSet&lt;E&gt; - Ordered sets (LinkedHashSet, TreeSet)</li><li>SequencedMap&lt;K,V&gt; - Ordered maps (LinkedHashMap, TreeMap)</li></ul><h3>5. Pattern Matching for Switch (with Guards)</h3><p><strong>Introduced in:</strong> Java 21 (Final)<br> <strong>Why it matters:</strong> Eliminates verbose type checking and casting, supports null handling, and enables guard conditions.</p><h4>Evolution of Switch</h4><pre>// Old Way (Java 7) - Only primitives and enums<br>String message;<br>switch (status) {<br>    case SUCCESS:<br>        message = &quot;Operation succeeded&quot;;<br>        break;<br>    case FAILURE:<br>        message = &quot;Operation failed&quot;;<br>        break;<br>    default:<br>        message = &quot;Unknown status&quot;;<br>}<br>// Better (Java 14) - Switch expressions<br>String message = switch (status) {<br>    case SUCCESS -&gt; &quot;Operation succeeded&quot;;<br>    case FAILURE -&gt; &quot;Operation failed&quot;;<br>    default -&gt; &quot;Unknown status&quot;;<br>};<br>// Best (Java 21) - Pattern matching with type patterns<br>String formatted = switch (obj) {<br>    case null -&gt; &quot;null value&quot;;<br>    case Integer i -&gt; String.format(&quot;Integer: %d&quot;, i);<br>    case String s -&gt; String.format(&quot;String: %s&quot;, s);<br>    case List&lt;?&gt; list -&gt; String.format(&quot;List with %d elements&quot;, list.size());<br>    default -&gt; obj.toString();<br>};</pre><h4>Pattern Matching with Guards (When Clauses)</h4><p>Here’s the <strong>short, plain explanation</strong> of what’s happening</p><p>👇What when is doing here when is adding <strong>extra rules</strong> to a pattern match.</p><p>So each case means: <strong><em>“Match this type ONLY IF this condition is true.</em></strong></p><pre>public class PaymentProcessor {<br>    <br>    public double calculateDiscount(Order order) {<br>        return switch (order) {<br>            case null -&gt; 0.0;<br>            <br>            // Guard conditions with &#39;when&#39;<br>            case Order o when o.total() &lt; 50 -&gt; 0.0;<br>            case Order o when o.total() &lt; 100 -&gt; o.total() * 0.05;<br>            case Order o when o.total() &lt; 500 -&gt; o.total() * 0.10;<br>            case Order o when o.isPremiumMember() -&gt; o.total() * 0.20;<br>            case Order o -&gt; o.total() * 0.15;<br>        };<br>    }<br>    <br>   <br>}<br><br><br>record Order(double total, boolean isPremiumMember) {}</pre><h4>In calculateDiscount</h4><ul><li>The switch first checks <strong>null</strong></li><li>Then checks <strong>Order</strong>, but applies rules <strong>in order</strong></li><li>when o.total() &lt; 50 → no discount</li><li>when o.total() &lt; 100 → 5%</li><li>when o.total() &lt; 500 → 10%</li><li>when o.isPremiumMember() → 20%</li><li>Last Order o → default for all remaining orders</li></ul><p>👉 Even though all are Order, <strong>when decides which rule applies</strong>.</p><h4>Real-World Example: JSON Response Handler</h4><pre>public class ApiResponseHandler {<br>    <br>    public String handleResponse(Object response) {<br>        return switch (response) {<br>            case null -&gt; <br>                throw new IllegalArgumentException(&quot;Response cannot be null&quot;);<br>            <br>            case ErrorResponse err when err.code() == 401 -&gt;<br>                &quot;Authentication required. Please log in.&quot;;<br>            <br>            case ErrorResponse err when err.code() &gt;= 500 -&gt;<br>                &quot;Server error: &quot; + err.message();<br>            <br>            case ErrorResponse err -&gt;<br>                &quot;Client error: &quot; + err.message();<br>            <br>            case SuccessResponse&lt;List&lt;?&gt;&gt; success -&gt;<br>                &quot;Received &quot; + success.data().size() + &quot; items&quot;;<br>            <br>            case SuccessResponse&lt;?&gt; success -&gt;<br>                &quot;Success: &quot; + success.data();<br>            <br>            default -&gt;<br>                &quot;Unexpected response type: &quot; + response.getClass().getName();<br>        };<br>    }<br>}<br><br>record ErrorResponse(int code, String message) {}<br>record SuccessResponse&lt;T&gt;(T data) {}</pre><p><strong>Key Benefits:</strong></p><ul><li>Null-safe by default</li><li>Guard conditions eliminate nested if-statements</li><li>Type patterns with variable binding</li><li>Exhaustiveness checking with sealed types</li></ul><h3>6. Collection Factory Methods (Java 9)</h3><p><strong>Introduced in:</strong> Java 9<br> <strong>Why it matters:</strong> Create immutable collections with minimal syntax — no more verbose builder patterns.</p><h4>Before Java 9</h4><pre>// Creating immutable collections was painful<br>List&lt;String&gt; list = new ArrayList&lt;&gt;();<br>list.add(&quot;one&quot;);<br>list.add(&quot;two&quot;);<br>list.add(&quot;three&quot;);<br>List&lt;String&gt; immutableList = Collections.unmodifiableList(list);<br>// Or using Arrays.asList (which is mutable!)<br>List&lt;String&gt; list2 = Arrays.asList(&quot;one&quot;, &quot;two&quot;, &quot;three&quot;);<br>// list2.add(&quot;four&quot;); // UnsupportedOperationException<br>// Maps were even worse<br>Map&lt;String, Integer&gt; map = new HashMap&lt;&gt;();<br>map.put(&quot;one&quot;, 1);<br>map.put(&quot;two&quot;, 2);<br>map.put(&quot;three&quot;, 3);<br>Map&lt;String, Integer&gt; immutableMap = Collections.unmodifiableMap(map);</pre><h4>After Java 9</h4><pre>// Immutable List<br>List&lt;String&gt; list = List.of(&quot;one&quot;, &quot;two&quot;, &quot;three&quot;);<br>// Immutable Set<br>Set&lt;Integer&gt; set = Set.of(1, 2, 3, 4, 5);<br>// Immutable Map (up to 10 entries)<br>Map&lt;String, Integer&gt; map = Map.of(<br>    &quot;one&quot;, 1,<br>    &quot;two&quot;, 2,<br>    &quot;three&quot;, 3<br>);<br>// Immutable Map (more than 10 entries)<br>Map&lt;String, Integer&gt; largeMap = Map.ofEntries(<br>    Map.entry(&quot;one&quot;, 1),<br>    Map.entry(&quot;two&quot;, 2),<br>    Map.entry(&quot;three&quot;, 3),<br>    Map.entry(&quot;four&quot;, 4),<br>    // ... as many as needed<br>    Map.entry(&quot;twenty&quot;, 20)<br>)</pre><p><strong>Important Notes:</strong></p><ul><li>List.of(), Set.of(), Map.of() create <strong>truly immutable</strong> collections</li><li>Any modification attempt throws UnsupportedOperationException</li><li>Null elements are NOT allowed (throws NullPointerException)</li><li>For Sets and Map keys, duplicate elements throw IllegalArgumentException</li></ul><h3>7. Enhanced String Methods (Java 11+) — in short</h3><p>Java 11+ introduced <strong>built-in string utilities</strong> that remove the need for verbose code or external libraries.</p><h4>Why it matters</h4><ul><li>Cleaner and more readable code</li><li>Unicode-safe whitespace handling</li><li>Easier log, file, and text processing</li></ul><h4>Key methods</h4><ul><li><strong>isBlank()</strong> → checks empty <strong>or only whitespace</strong></li><li><strong>strip() / </strong><strong>stripLeading() / </strong><strong>stripTrailing()</strong> → Unicode-aware trimming</li><li><strong>lines()</strong> → converts multi-line text into a stream</li><li><strong>repeat(n)</strong> → repeats a string n times</li><li><strong>indent(n)</strong> → adds/removes indentation for each line</li><li><strong>transform(fn)</strong> → applies a function directly on the string</li></ul><h3>Example (with output)</h3><pre>String log = &quot;&quot;&quot;<br>    ERROR  Database failed<br>       <br>    WARN   Disk almost full<br>    INFO   Server started<br>    &quot;&quot;&quot;;<br>log.lines()<br>   .filter(line -&gt; !line.isBlank())<br>   .filter(line -&gt; line.contains(&quot;ERROR&quot;) || line.contains(&quot;WARN&quot;))<br>   .map(String::strip)<br>   .forEach(System.out::println);<br>System.out.println(&quot;-&quot;.repeat(30));<br>System.out.println(&quot;Hello&quot;.repeat(3));</pre><h4>Output</h4><pre>ERROR  Database failed<br>WARN   Disk almost full<br>------------------------------<br>HelloHelloHello</pre><p><strong>One-line takeaway:</strong><br> 👉 <em>Java 11+ string enhancements make text handling concise, readable, and production-friendly.</em></p><h3>8. Unnamed Patterns and Variables (Java 21) — in short</h3><p>Java 21 allows using <strong>_ (underscore)</strong> to explicitly ignore unused variables and pattern components.</p><h3>Why it matters</h3><ul><li>Reduces boilerplate</li><li>Removes unused-variable clutter</li><li>Makes developer intent clear</li><li>Improves readability in pattern matching, lambdas, and exception handling</li></ul><h3>Before Java 21 (extra noise)</h3><pre>// Pattern matching<br>if (order instanceof Order(String id, double total)) {<br>    System.out.println(total);   // &#39;id&#39; is unused<br>}<br>// Lambda<br>map.forEach((key, value) -&gt; System.out.println(value)); // &#39;key&#39; unused<br>// Try-catch<br>try {<br>    riskyOperation();<br>} catch (Exception e) {          // &#39;e&#39; never used<br>    System.out.println(&quot;Failed&quot;);<br>}</pre><h3>After Java 21 (clean and intentional)</h3><pre>// Pattern matching<br>if (order instanceof Order(_, double total)) {<br>    System.out.println(total);<br>}<br>// Lambda<br>map.forEach((_, value) -&gt; System.out.println(value));<br>// Try-catch<br>try {<br>    riskyOperation();<br>} catch (Exception _) {<br>    System.out.println(&quot;Failed&quot;);<br>}</pre><h3>What changed?</h3><ul><li>_ clearly means <strong>“this value exists, but I don’t need it”</strong></li><li>No unused variables</li><li>Less mental overhead when reading code</li></ul><p>One-line takeaway</p><p>👉 <strong>_ removes noise and makes unused values explicit and intentional in Java 21.</strong></p><h3>9. String Templates (Java 21 — Preview)</h3><p>Java 21 introduces <strong>String Templates</strong>, a safer and more readable way to build strings using <strong>interpolation</strong> instead of concatenation.</p><h3>Why it matters</h3><ul><li>Cleaner and more readable than + or String.format</li><li>Expressions supported inside strings</li><li>Prevents injection attacks (SQL, JSON, etc.)</li><li>Type-safe and compiler-checked</li></ul><h3>Before (String concatenation — hard to read)</h3><pre>String name = &quot;Alice&quot;;<br>int age = 30;<br>String message = &quot;User &quot; + name + &quot; is &quot; + age + &quot; years old&quot;;</pre><h3>After (String Templates — clean &amp; readable)</h3><pre>String name = &quot;Alice&quot;;<br>int age = 30;<br>String message = STR.&quot;User \{name} is \{age} years old&quot;;</pre><h3>Expressions inside templates</h3><pre>String status = STR.&quot;User is \{age &gt;= 18 ? &quot;adult&quot; : &quot;minor&quot;}&quot;;</pre><h3>Multi-line template</h3><pre>String html = STR.&quot;&quot;&quot;<br>    &lt;h1&gt;Welcome \{name}&lt;/h1&gt;<br>    &lt;p&gt;Age: \{age}&lt;/p&gt;<br>    &quot;&quot;&quot;;</pre><h3>SQL Template (Injection-safe)</h3><pre>import static java.lang.StringTemplate.SQL;<br>String userId = getUserInput();<br>StringTemplate query = SQL.&quot;&quot;&quot;<br>    SELECT * FROM users<br>    WHERE id = \{userId}<br>    &quot;&quot;&quot;;</pre><p>✔ Values are <strong>escaped automatically</strong><br> ✔ No SQL injection risk</p><h3>JSON Template (Type-safe JSON)</h3><pre>import static java.lang.StringTemplate.JSON;String json = JSON.&quot;&quot;&quot;<br>    {<br>        &quot;name&quot;: &quot;\{name}&quot;,<br>        &quot;age&quot;: \{age}<br>    }<br>    &quot;&quot;&quot;;</pre><p>✔ Always produces <strong>valid JSON</strong></p><p>One-line takeaway</p><p>👉 <strong>String Templates make string creation safer, cleaner, and more expressive in Java 21+.</strong></p><h3>10 . var — Local Variable Type Inference</h3><p><strong>Introduced in:</strong> Java 10</p><p>Lets the compiler infer local variable types.</p><h3>Before (verbose)</h3><pre>Map&lt;String, List&lt;Integer&gt;&gt; data = new HashMap&lt;String, List&lt;Integer&gt;&gt;();</pre><h3>After (clean)</h3><pre>var data = new HashMap&lt;String, List&lt;Integer&gt;&gt;();</pre><p>✔ Less noise<br> ✔ Same type safety<br> ✔ Better readability</p><p>👉 One-line takeaway</p><p><strong>var reduces clutter without losing type safety.</strong></p><h3>11. Sealed Classes — Controlled Inheritance</h3><p><strong>Introduced in:</strong> Java 17</p><p>Sealed classes restrict <strong>who can extend or implement a type</strong>.</p><h3>Before (unrestricted inheritance)</h3><pre>interface Shape {}</pre><p>Anyone can implement Shape.</p><h3>After (sealed)</h3><pre>sealed interface Shape permits Circle, Rectangle {}<br>record Circle(int radius) implements Shape {}<br>record Rectangle(int w, int h) implements Shape {}</pre><p>✔ Compile-time safety<br> ✔ Better exhaustiveness in switch</p><p>👉 One-line takeaway</p><p><strong>Sealed types give you control over inheritance and safer designs.</strong></p><h3>Conclusion</h3><p>Modern Java (Java 9–21) is not about <em>learning new syntax</em> — it’s about <strong>writing less code, avoiding entire classes of bugs, and unlocking performance and clarity that simply weren’t possible in Java 8</strong>. Features like improved Streams, Records, Sealed types, Pattern Matching, safer Strings, and smarter Collections shift Java from boilerplate-heavy to <strong>intent-driven, production-ready code</strong>.</p><p>If you’re still coding Java like it’s 2014, you’re leaving readability, safety, and performance on the table. <strong>Upgrade your mindset, not just your JDK.</strong></p><p>👉 <strong>Stay tuned for the next blog</strong>, where I’ll dive deeper into real-world performance wins with <strong>Virtual Threads, Structured Concurrency, and modern JVM tuning</strong> 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=435647eeeb3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking Real-Time Updates: The Power of Server-Side Push with SSE]]></title>
            <link>https://medium.com/@jai.mail67/unlocking-real-time-updates-the-power-of-server-side-push-with-sse-a6ae96d71df2?source=rss-dfe3bd04bc1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6ae96d71df2</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[sse-server-side-push-sse]]></category>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[servers]]></category>
            <dc:creator><![CDATA[Jagnya Datta Panigrahi]]></dc:creator>
            <pubDate>Fri, 25 Apr 2025 12:21:17 GMT</pubDate>
            <atom:updated>2025-04-25T12:21:17.804Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Owgqo74bED7MGfCY1Z6PQ.jpeg" /></figure><h3>What is Server-Side Push?</h3><p>Server-side push is a communication model where the server actively sends data to the client without the client requesting it. This method contrasts with the traditional client-side pull, where the client repeatedly requests data from the server at intervals. Server-side push allows for real-time communication, making it suitable for applications like live notifications, stock market updates, social media feeds, and more.</p><p><strong>Key Characteristics:</strong></p><ul><li>The server sends updates to the client in real time.</li><li>Clients don’t need to request updates (no polling) repeatedly.</li><li>A persistent connection is maintained for ongoing communication.</li></ul><h3>How It Helps in Real-Time Communication</h3><p>Server-side push enables real-time updates, reducing latency and the need for constant polling. With technologies like <strong>SSE</strong>, <strong>WebSockets</strong>, or <strong>Long Polling</strong>, server-side push improves the user experience by delivering updates the moment they happen. This is especially useful in applications like:</p><ul><li><strong>Live dashboards</strong> for tracking performance or metrics.</li><li><strong>Real-time notifications</strong> for users on apps or websites.</li><li><strong>Collaboration tools</strong> that require instant feedback.</li></ul><h3>Working Principle of Server-Side Push</h3><p>Server-side push relies on a persistent connection between the client and the server. An event on the server immediately pushes the data to the client through this open connection.</p><ol><li><strong>Client Initiates Connection</strong>: The client (typically a browser) sends a request to the server to open a communication channel (such as an EventSource in case of SSE).</li><li><strong>Server Keeps Connection Open</strong>: The server holds the connection open and sends updates whenever necessary (without the client needing to request them).</li><li><strong>Client Receives Data</strong>: The client listens to the incoming data stream and updates the UI or performs other actions based on the received data.</li></ol><h3>What Are the Protocols Available for Server-Side Push?</h3><p>Several protocols support server-side push, each with its use cases:</p><ol><li><strong>Server-Sent Events (SSE)</strong>:</li></ol><ul><li>Built into the HTTP protocol.</li><li>One-way communication from the server to the client.</li><li>Supported natively by most modern browsers via the EventSource API.</li><li>Ideal for simple applications requiring only updates from the server to the client.</li></ul><p><strong>2. WebSockets</strong>:</p><ul><li>Provides full-duplex communication (both server and client can send messages).</li><li>Establishes a persistent TCP connection</li><li>Suitable for applications like chat systems, multiplayer games, or real-time collaboration tools.</li></ul><p><strong>3. Long Polling</strong>:</p><ul><li>A technique where the client sends a request to the server and waits for a response. The server holds the request until new data is available, at which point the response is sent.</li><li>This method mimics real-time communication but requires more overhead compared to SSE or WebSockets.</li></ul><p><strong>4. HTTP/2 Push</strong>:</p><ul><li>Part of the HTTP/2 protocol, allows the server to push resources (like images or JavaScript files) to the client before the client requests them.</li><li>More efficient than traditional methods but still not commonly used for real-time communication.</li></ul><h3>What is SSE (Server-Sent Events)?</h3><p>SSE is a simple and efficient protocol for pushing real-time updates from the server to the client over a single, long-lived HTTP connection. It’s part of the HTML5 specification and is widely supported in modern browsers. With SSE, the server can send updates to the client automatically as soon as an event occurs, without the client needing to poll for updates.</p><p><strong>Key Features of SSE:</strong></p><ul><li>One-way communication: Server sends data to the client.</li><li>Text-based format (usually JSON or plain text).</li><li>Automatic reconnection by the client if the connection drops.</li><li>Simple to implement and well-suited for live notifications, status updates, or feeds.</li></ul><h3>Example in Spring with Real-Time Data</h3><h4>Backend (Spring Boot): Used SseEmitter to send events to the client.</h4><p>Add this dependency to the pom</p><pre>  &lt;dependency&gt;<br>   &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>   &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;<br>  &lt;/dependency&gt;</pre><pre><br>import org.springframework.web.bind.annotation.GetMapping;<br>import org.springframework.web.bind.annotation.RestController;<br>import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;<br><br>import java.io.IOException;<br>import java.util.Random;<br>@RestController<br>public class SSEDashboardController {<br>    @GetMapping(&quot;/sse/dashboard&quot;)<br>    public SseEmitter streamDashboardData() {<br>        //0l no time limit<br>        SseEmitter emitter = new SseEmitter(0L);<br><br>        // Start a new thread to send updates every 5 seconds<br>        new Thread(() -&gt; {<br>            try {<br>                while (true) {<br>                    int usersOnline = new Random().nextInt(100);<br>                    int activeCarts = new Random().nextInt(20);<br>                    int ordersPlaced = new Random().nextInt(10);<br>                    String jsonData = String.format(&quot;{\&quot;usersOnline\&quot;: %d, \&quot;activeCarts\&quot;: %d, \&quot;ordersPlaced\&quot;: %d}&quot;,<br>                            usersOnline, activeCarts, ordersPlaced);<br>                    emitter.send(SseEmitter.event()<br>                            .name(&quot;dashboard-update&quot;)<br>                            .data(jsonData)<br>                            .id(String.valueOf(System.currentTimeMillis())));<br><br>                    Thread.sleep(5000);<br>                }<br>            } catch (IOException | InterruptedException e) {<br>                emitter.completeWithError(e);<br>            }<br>        }).start();<br><br>        return emitter;<br>    }<br>}</pre><h3>3. Frontend: HTML + JS Dashboard</h3><h3>src/main/resources/static/index.html</h3><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;title&gt;Admin Live Dashboard&lt;/title&gt;<br>    &lt;style&gt;<br>        body {<br>            font-family: sans-serif;<br>            margin: 40px;<br>            background: #f7f7f7;<br>        }<br>        h2 { margin-bottom: 20px; }<br>        .card {<br>            background: white;<br>            padding: 20px;<br>            border-radius: 12px;<br>            box-shadow: 0 4px 10px rgba(0,0,0,0.1);<br>            margin-bottom: 15px;<br>            width: 300px;<br>        }<br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;h2&gt;🧠 Admin Live Dashboard&lt;/h2&gt;<br>&lt;div class=&quot;card&quot;&gt;Users Online: &lt;strong id=&quot;usersOnline&quot;&gt;--&lt;/strong&gt;&lt;/div&gt;<br>&lt;div class=&quot;card&quot;&gt;Active Carts: &lt;strong id=&quot;activeCarts&quot;&gt;--&lt;/strong&gt;&lt;/div&gt;<br>&lt;div class=&quot;card&quot;&gt;Orders Placed: &lt;strong id=&quot;ordersPlaced&quot;&gt;--&lt;/strong&gt;&lt;/div&gt;<br><br>&lt;script&gt;<br>        const usersOnlineEl = document.getElementById(&quot;usersOnline&quot;);<br>        const activeCartsEl = document.getElementById(&quot;activeCarts&quot;);<br>        const ordersPlacedEl = document.getElementById(&quot;ordersPlaced&quot;);<br><br>        const source = new EventSource(&quot;/sse/dashboard&quot;);<br><br>source.addEventListener(&quot;dashboard-update&quot;, function (event) {<br>    const data = JSON.parse(event.data);<br>    usersOnlineEl.innerText = data.usersOnline;<br>    activeCartsEl.innerText = data.activeCarts;<br>    ordersPlacedEl.innerText = data.ordersPlaced;<br>});<br><br>        source.onerror = function () {<br>            console.error(&quot;SSE connection error. Retrying...&quot;);<br>            source.close();<br>        };<br>    &lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Folder structure of Spring boot application</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qsnv8YEfDpcgrAZjUeM0Jw.png" /></figure><h3>🚀 How to Run</h3><ol><li>Create Spring Boot app with the code above.</li><li>Run the app.</li><li>Open <a href="http://localhost:8080/dashboard.html.">http://localhost:8080/index.html.</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qE_6n_tyk-DvkyWv_2AKwQ.png" /></figure><h3>This image shows the <strong>EventStream</strong> tab in Chrome DevTools (or similar browser tools), and it’s directly related to how <strong>Server-Sent Events (SSE)</strong> work on the <strong>client side</strong>.</h3><p>Let me break it down for you:</p><p>🔄 What This Is</p><ul><li>This is a real-time <strong>stream of events</strong> coming from the server to the browser.</li><li>The stream URL is /sse/dashboard or similar.</li><li>Each row is a new event sent from the server using <strong>SSE</strong>, visible under the EventStream tab.</li><li>🧩 What the Columns Mean</li></ul><p>ColumnMeaning<strong>Id</strong>A</p><p><strong>unique ID</strong> : for each SSE message, typically a timestamp or incremented number. Helps in reconnect scenarios.</p><p><strong>Type :</strong> The custom event type. Here, it is dashboard-update, matching what the client JS listens for using source.addEventListener(&quot;dashboard-update&quot;, ...).</p><p><strong>Data</strong> The actual <strong>JSON payload</strong> sent by the server. It contains real-time data like usersOnline, activeCarts, and ordersPlaced.</p><h3>⚙️ How It Works on Client Side</h3><p>In your JavaScript, you probably have something like:</p><pre>const source = new EventSource(&quot;/sse/dashboard&quot;);<br><br>source.addEventListener(&quot;dashboard-update&quot;, function (event) {<br>    const data = JSON.parse(event.data);<br>    usersOnlineEl.innerText = data.usersOnline;<br>    activeCartsEl.innerText = data.activeCarts;<br>    ordersPlacedEl.innerText = data.ordersPlaced;<br>});</pre><ul><li>The browser <strong>automatically listens</strong> for incoming events from the server.</li><li>When a message with event: dashboard-update is received, it triggers your JS handler.</li><li>The JSON data is parsed and used to <strong>update the UI in real time</strong> without page reload.</li></ul><h3>🚀 Why It’s Cool</h3><ul><li>You get <strong>live, real-time updates</strong>.</li><li>No need to poll the server.</li><li>Lightweight and <strong>native browser support</strong>.</li><li>Perfect for dashboards, monitoring systems, or notification feeds.</li></ul><p>Thanks for reading! Hope you enjoyed learning about <strong>Server-Side Push</strong> and <strong>SSE</strong>.</p><p>👉 <strong>Up Next:</strong> We’ll dive into <strong>WebSocket</strong> — how it differs from SSE, its real-time capabilities, and when to use it. Stay tuned for the next blog!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6ae96d71df2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Meet uv: A Rust-Powered, Ultra-Fast Alternative to pip]]></title>
            <link>https://medium.com/@jai.mail67/meet-uv-a-rust-powered-ultra-fast-alternative-to-pip-fa7c89c4b808?source=rss-dfe3bd04bc1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa7c89c4b808</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[pip]]></category>
            <dc:creator><![CDATA[Jagnya Datta Panigrahi]]></dc:creator>
            <pubDate>Fri, 18 Apr 2025 05:33:40 GMT</pubDate>
            <atom:updated>2025-04-18T05:33:40.297Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Owgqo74bED7MGfCY1Z6PQ.jpeg" /></figure><ol><li><strong>Before </strong><strong>uv : The State of Python Package Management</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g1qsbGRXFZhEJMguQDmTTQ.png" /><figcaption>source : (<a href="https://docs.astral.sh/uv/">https://docs.astral.sh/</a>)</figcaption></figure><ul><li><strong>pip</strong>: Python’s default package manager, widely used with virtualenv.</li><li><strong>pyenv</strong>: Used to manage multiple Python versions (not a package manager per se, but part of the ecosystem).</li><li><strong>venv / virtualenv</strong>: For isolated environments.</li><li><strong>pip-tools, pipenv, poetry</strong>: Higher-level tools for dependency resolution and management.</li></ul><h3>2. What’s Good About pip Compared to Other Languages</h3><ul><li>Integrated with Python standard library.</li><li>Easy-to-use and widely supported.</li><li>Works well with PyPI, the central Python package index.</li><li>Can install from GitHub repos, local files, URLs.</li><li>Compared to Node.js (npm), Rust (cargo), or Java (maven), pip is simple and flexible.</li></ul><h3>3. Where pip Falls Short</h3><ul><li><strong>Dependency resolution</strong>: pip used to install conflicting versions until the resolver was improved (in pip 20.3).</li><li><strong>Performance</strong>: Slower installs and environment creation.</li><li><strong>Reproducibility</strong>: No built-in support for lockfiles.</li><li><strong>UX</strong>: No built-in support for managing virtual environments or multi-platform constraints.</li></ul><h3>4. Alternatives to pip</h3><ul><li><strong>Poetry</strong>: Modern CLI with built-in dependency resolution and lockfiles.</li><li><strong>Pipenv</strong>: Integrates pip and virtualenv with lockfile support.</li><li><strong>conda</strong>: For data science, includes binaries and Python interpreter.</li><li><strong>pipx</strong>: For installing CLI apps globally in isolated environments.</li></ul><h3>5. Enter uv: Why the Hype?</h3><ul><li>uv is a <strong>fast, drop-in replacement for pip and pip-tools</strong>.</li><li>Handles dependency resolution, environment management, and installation — all in one.</li><li>Created by the team at <strong>Astral</strong> (also known for rye).</li><li>Great performance — significantly faster than pip and poetry.</li></ul><h3>6. uv Under the Hood</h3><ul><li><strong>Written in Rust</strong> 🦀</li><li><strong>Interoperability</strong>: Uses pyo3 for Python bindings.</li></ul><p><strong>Architecture</strong>:</p><ul><li>Uses <strong>libsolv</strong> for dependency resolution (also used by conda).</li><li>Fully compatible with pip requirements.txt files.</li><li>Designed to be a standalone binary — no Python interpreter needed to run uv itself.</li></ul><h3>7. Why Rust?</h3><ul><li>Memory safety without garbage collection.</li><li>Zero-cost abstractions.</li><li>High concurrency and performance.</li><li>Compilation to a static binary that works across platforms.</li></ul><h3>🚀 Installing uv and Prerequisites</h3><p>Unlike traditional Python tools like pip, uv is <strong>not a Python package</strong>. It’s a <strong>standalone binary</strong> written in <strong>Rust</strong>, designed for performance and cross-platform compatibility.</p><h3>✅ Prerequisites</h3><p>Before installing uvMake sure you have:</p><ul><li><strong>Python 3.7+</strong> installed (e.g., Python 3.13.x is fully supported)</li><li><strong>macos, Linux, or WSL (Windows Subsystem for Linux)</strong></li><li>Native Windows support is still evolving; WSL is recommended for now.</li><li><strong>Internet access</strong> to download the prebuilt binary</li></ul><p>You <strong>do not</strong> need</p><ul><li>Rust (unless building from source)</li><li>pip, pyenv, poetry, etc.</li></ul><h4>Install via Shell Script (Recommended)</h4><pre>curl -Ls https://astral.sh/uv/install.sh | bash</pre><h3>📦 Verify Installation</h3><p>Once installed, verify</p><pre>uv --version</pre><p>uv manages project dependencies and environments, with support for lockfiles, workspaces, and more, similar to rye or poetry:</p><pre>uv init &lt;project-name&gt;<br><br># uv init, it initializes a minimal Python project by generating the following:<br>#.   1. .gitignore<br>#.   2. main.py<br>#.   3. pyproject.toml [This is the main configuration file used by modern Python tooling. It includes metadata and dependency info.]<br>#.   4. README.md</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O-KfNLOIj83ieXU3zvp9vw.png" /></figure><h3>🚀 uv Command Cheat Sheet</h3><ol><li><strong>uv init</strong> – Initialize a Python project with a pyproject.toml.</li><li><strong>uv venv .venv</strong> – Create a virtual environment in .venv folder.</li><li><strong>uv pip install &lt;pkg&gt;</strong> – Install a package (does <strong>not</strong> update pyproject.toml).</li><li><strong>uv pip uninstall &lt;pkg&gt;</strong> – Uninstall a package from the current environment.</li><li><strong>uv pip list</strong> – Show all installed packages.</li><li><strong>uv pip compile &lt;input.in&gt;</strong> – Generate a lock file with exact versions from a source file.</li><li><strong>uv pip sync</strong> – Install packages exactly as pinned in the lock file.</li><li><strong>uv cache dir</strong> – Show location of uv&#39;s package cache.</li><li><strong>uv cache clean</strong> – Clear all cached packages.</li><li><strong>uv --help</strong> – Show help and list of available uv commands.</li><li><strong>uv pip --help</strong> – Show help for pip-related subcommands.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa7c89c4b808" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving LLM Integration Challenges with Model Context Protocol (MCP) and Spring AI]]></title>
            <link>https://medium.com/@jai.mail67/solving-llm-integration-challenges-with-model-context-protocol-mcp-and-spring-ai-883a5275b3cb?source=rss-dfe3bd04bc1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/883a5275b3cb</guid>
            <category><![CDATA[mcps]]></category>
            <category><![CDATA[spring-ai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[claude-ai]]></category>
            <category><![CDATA[mcp-server]]></category>
            <dc:creator><![CDATA[Jagnya Datta Panigrahi]]></dc:creator>
            <pubDate>Fri, 11 Apr 2025 09:21:27 GMT</pubDate>
            <atom:updated>2025-04-11T11:10:20.997Z</atom:updated>
            <content:encoded><![CDATA[<p>As large language models (LLMs) continue to reshape enterprise application development, developers are rapidly integrating them into modern solutions. However, this rapid adoption has highlighted a major challenge: <strong>a lack of standardized protocols for LLM communication and context handling</strong>. In this post, I’ll introduce the <strong>Model Context Protocol (MCP)</strong> and how it addresses these challenges, especially when integrated with <strong>Spring AI</strong>.</p><h3>🚧 The Problem: Integrating LLMs Without Specification</h3><p>Most developers today interact with LLMs using vendor-specific APIs (like OpenAI, Anthropic, or Azure OpenAI). While these APIs are powerful, integrating them without a standard interface leads to:</p><ul><li><strong>Vendor lock-in</strong>: Swapping LLM providers requires rewriting core logic.</li><li><strong>Inconsistent context handling</strong>: Managing long-term memory, knowledge, or tool access differs across providers.</li><li><strong>Unclear system behavior</strong>: There’s no formal spec to define what models expect or how they interact with external tools and functions.</li></ul><p>This is where <strong>MCP</strong> steps in.</p><h3>🧠 What Is MCP and Who Designed It?</h3><p><strong>Model Context Protocol (MCP)</strong> is a vendor-neutral protocol designed to enable <strong>interoperability between LLMs, agents, tools, memory systems, and external services</strong>.</p><p>The Model Context Protocol (MCP) is an open standard developed by <strong>Anthropic</strong> and has now become an <strong>open protocol</strong>, supported by multiple communities and tools including LangChain, LangGraph, and now even <strong>Spring AI</strong>.</p><blockquote><em>Think of MCP like REST for LLMs: a clean, extensible contract that defines how to structure inputs, outputs, tools, memory, and context.</em></blockquote><h3>🌐 A Unified Standard for AI: Write Once, Use Everywhere</h3><p>One of the biggest strengths of MCP is its potential to <strong>unify how AI agents communicate across platforms</strong>. With major players like <strong>OpenAI and Anthropic</strong> embracing MCP.</p><p>Instead of building custom integrations for each LLM provider or assistant app, developers can simply <strong>implement MCP once</strong>. That same implementation can then be reused across a wide range of host applications — whether it’s <strong>Claude, ChatGPT, Cline, Gemini</strong>, or any future AI client that supports the protocol.</p><h3>🏗️ How MCP Works: A Simple Client-Server Architecture</h3><p>At its foundation, <strong>MCP operates on a clean and modular client-server architecture</strong>. Think of it like a hub-and-spoke model where <strong>host applications (clients)</strong> talk to <strong>multiple specialized MCP servers</strong> to get things done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oEifQDmTeg7v1xVkBopF-g.png" /><figcaption><a href="https://modelcontextprotocol.io/introduction">source</a> (<a href="https://modelcontextprotocol.io/introduction">https://modelcontextprotocol.io/introduction</a>)</figcaption></figure><p>Here’s a breakdown:</p><ul><li><strong>🔌 MCP Hosts</strong>: These are the front-end tools or applications — like <strong>Claude Desktop, code editors, or AI agents</strong> — that want to interact with your data, tools, or logic.</li><li><strong>🧠 MCP Clients</strong>: Each host app maintains a <strong>dedicated connection to one or more MCP servers</strong> via the protocol. This allows the client to send requests, receive responses, and even trigger tools.</li><li><strong>🖥️ MCP Servers</strong>: These are lightweight backend programs that expose certain capabilities — such as accessing local files, triggering APIs, or running workflows — through the <strong>Model Context Protocol</strong>. Each server can be purpose-built and self-contained.</li><li><strong>📁 Local Data Sources</strong>: Your own machine’s files, databases, or microservices — securely accessed by MCP servers.</li><li><strong>🌐 Remote Services</strong>: APIs or cloud platforms that your MCP server can connect to, extending the server’s reach beyond your local environment.</li></ul><p>MCP allows developers to structure LLM interactions around a <strong>formal schema</strong> called JsonRpcMessage.</p><h3>🤖 Integrating MCP with Spring AI</h3><p>Spring AI makes it easy to integrate the <strong>Model Context Protocol (MCP)</strong> into your applications by offering ready-to-use Spring Boot starters. These starters cover both <strong>client-side</strong> and <strong>server-side</strong> setups, and support various communication transports like <strong>STDIO</strong> and <strong>Server-Sent Events (SSE)</strong>.</p><h4>🧩 Client Starters</h4><p>These starters help applications connect to MCP servers:</p><ul><li>spring-ai-starter-mcp-client: The core MCP client with built-in support for both STDIO and HTTP-based SSE communication.</li><li>spring-ai-starter-mcp-client-webflux: Adds reactive support using WebFlux for SSE transport.</li></ul><h4>🖥️ Server Starters</h4><p>These are used to build your own MCP servers using Spring Boot:</p><ul><li>spring-ai-starter-mcp-server: Basic server setup using STDIO transport—ideal for process-based communication.</li><li>spring-ai-starter-mcp-server-webmvc: Provides SSE server support using Spring MVC—great for servlet-based environments.</li><li>spring-ai-starter-mcp-server-webflux: Reactive version of the SSE server for applications using Spring WebFlux.<br>Lets</li><li>Supports STDIO, Servlet SSE, WebFlux, and WebMVC transports</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*I1ZnF9MIFc-4Ry5r.jpg" /></figure><h3><strong><em>Booting Up Your Spring AI MCP Server with </em></strong>STDIO transport<strong><em>!</em></strong></h3><p><a href="https://github.com/jagnyadatta67/MCP-Spring-AI/tree/main/spring-mcp">MCP-Spring-AI/spring-mcp at main · jagnyadatta67/MCP-Spring-AI</a></p><p>Here’s a complete example of how to set up an <strong>MCP Server using Spring AI</strong> — fully functional and cleanly organized using Spring Boot. This example uses the spring-ai-starter-mcp-server and optionally supports STDIO and/or HTTP-based SSE transport.</p><p>The official documentation provides detailed guidance:<br> 👉 <a href="https://docs.spring.io/spring-ai/reference/api/mcp/mcp-server-boot-starter-docs.html">Spring AI MCP Boot Starter Docs</a></p><p>🧱 1. <strong>Maven Dependencies</strong></p><pre><br>  &lt;dependency&gt;<br>   &lt;groupId&gt;org.springframework.ai&lt;/groupId&gt;<br>   &lt;artifactId&gt;spring-ai-mcp-server-spring-boot-starter&lt;/artifactId&gt;<br>  &lt;/dependency&gt;<br><br> &lt;dependencyManagement&gt;<br>  &lt;dependencies&gt;<br>   &lt;dependency&gt;<br>    &lt;groupId&gt;org.springframework.ai&lt;/groupId&gt;<br>    &lt;artifactId&gt;spring-ai-bom&lt;/artifactId&gt;<br>    &lt;version&gt;${spring-ai.version}&lt;/version&gt;<br>    &lt;type&gt;pom&lt;/type&gt;<br>    &lt;scope&gt;import&lt;/scope&gt;<br>   &lt;/dependency&gt;<br>  &lt;/dependencies&gt;<br> &lt;/dependencyManagement&gt;<br></pre><pre><br>@SpringBootApplication<br>public class SpringMcpApplication {<br> private static final Logger log = LoggerFactory.getLogger(SpringMcpApplication.class);<br><br> public static void main(String[] args) {<br>  SpringApplication.run(SpringMcpApplication.class, args);<br> }<br> @Bean<br> public List&lt;ToolCallback&gt; danTools(SpringMCPServerService courseService) {<br>  log.info(Arrays.toString(Thread.currentThread().getStackTrace()).replace( &#39;,&#39;, &#39;\n&#39; ));<br><br>  return Arrays.asList(ToolCallbacks.from(courseService));<br> }<br>}</pre><pre>@Service<br>public class SpringMCPServerService {<br>     @Tool(name = &quot;get_system_information&quot;, description = &quot;Gathers detailed system-level diagnostics including directory info, OS and architecture details, JVM configuration, memory stats, CPU load, and installed software versions.&quot;)<br>    public static SystemInfo getSystemInfo() {<br>        SystemInfo info = new SystemInfo();<br>      Properties props = System.getProperties();<br>        info.osName = props.getProperty(&quot;os.name&quot;);<br> ......<br>}</pre><pre>spring.application.name=courses<br>spring.main.web-application-type=none<br>spring.ai.mcp.server.name=jagnya-selflearn-mcp<br>spring.ai.mcp.server.version=0.0.1<br>spring.main.banner-mode=off<br>logging.pattern.console=<br><br></pre><h3>Key Configuration Notes</h3><p>STDIO Mode Requirements</p><ul><li>Disable web application type (spring.main.web-application-type=none)</li><li>Disable Spring banner (spring.main.banner-mode=off)</li><li>Clear console logging pattern (logging.pattern.console=)</li></ul><h3>✅ MCP Server Integration with Claude (Anthropic) as Client</h3><p>Now that we’ve implemented our <strong>MCP Server</strong>, it’s time to <strong>integrate it with Claude AI from Anthropic</strong>. This allows us to verify that the server is up and running, and capable of serving contextual data to an MCP-compliant client like Claude.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/0*olE4IiTVYG2zclkW" /></figure><h3>🚀 MCP Server Integration with Claude Desktop: Step-by-Step</h3><p>Here’s how you can integrate your <strong>Spring-based MCP Server</strong> with <strong>Claude Desktop</strong> (Anthropic) to verify everything is working as expected:</p><p>If you haven’t already, download and install Claude Desktop from the <a href="https://www.anthropic.com/">Anthropic website</a>.</p><p>Launch the Claude Desktop application. Claude is designed to support the <strong>Model Context Protocol (MCP)</strong> in communicating with custom AI model servers.</p><ul><li>Go to <strong>Settings</strong> in Claude.</li><li>Navigate to the <strong>Developer</strong> section.</li><li>Click on <strong>Edit Config</strong> to open claude_desktop_config.json.</li><li>Update the claude_desktop_config.json with your custom MCP server configuration. For example:</li></ul><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;jagnya-spring-mcp&quot;: {<br>      &quot;command&quot;: &quot;/Users/user/Library/Java/JavaVirtualMachines/sapmachine-21.0.6/Contents/Home/bin/java&quot;,<br>      &quot;args&quot;: [<br>        &quot;-jar&quot;,<br>        &quot;/Users/&lt;add ur path to jar&gt;/spring-mcp/target/spring-mcp-0.0.1-SNAPSHOT.jar&quot;<br>      ]<br>    }<br>  }<br>}</pre><p>Once the configuration is saved, <strong>restart Claude Desktop</strong>.<br> If everything is correctly configured, you’ll see:</p><ul><li>A <strong>hammer icon</strong> 🛠️ for developer tools</li><li>A <strong>plugin icon</strong> 🔌 for custom integrations</li><li>Click the <strong>hammer icon</strong> to open the <strong>MCP Tools</strong>.</li><li>Type the following into Claude:</li></ul><blockquote>Hi, get my system details with the Java version installed.</blockquote><ul><li>Claude will prompt a dialog for permission — <strong>click “Allow”</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FiORFCaAuzs0G4vd" /></figure><h3>✨ Happy Coding!</h3><p>That’s all for now on integrating Claude Desktop with a Spring AI MCP Server.<br> Stay tuned — in the next blog, I’ll walk you through:</p><blockquote><em>🚀 </em><strong><em>How to create an MCP Client using Spring AI</em></strong></blockquote><p>Until then, keep experimenting, stay curious, and happy coding! 💻🧠🎉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=883a5275b3cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Quarkus: A Guide to Application Creation]]></title>
            <link>https://towardsdev.com/getting-started-with-quarkus-a-guide-to-application-creation-bb3e35f608a9?source=rss-dfe3bd04bc1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb3e35f608a9</guid>
            <category><![CDATA[quarkus]]></category>
            <category><![CDATA[quarkus-framework]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Jagnya Datta Panigrahi]]></dc:creator>
            <pubDate>Thu, 28 Nov 2024 12:51:34 GMT</pubDate>
            <atom:updated>2024-12-04T14:09:45.917Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Owgqo74bED7MGfCY1Z6PQ.jpeg" /></figure><p><strong>Before You Begin</strong><br>To fully understand and appreciate Quarkus, I recommend reading the blog <a href="https://medium.com/@jai.mail67/java-in-the-age-of-microservices-and-containers-e589de9246a0"><em>Java in the Age of Microservices and Containers</em></a>. This article provides valuable insights into how Quarkus revolutionizes Java development in the modern era of microservices and containers.</p><p>Quarkus is a very developer-focused framework. It tries to give developers several options to generate a starting application depending on user preference. In this section, we explore different choices available for developing a new Quarkus application. You can easily apply these options to start building your business<br><br>We can create Quarkus applications in three distinctive ways:<br>1. Quarkus Maven plugin<br>2. Quarkus CLI (Command Line Interface)<br>3. The website’s graphical starter interface</p><h3>1.1 Quarkus Maven plugin</h3><p>To create a Quarkus application using Apache Maven, you can leverage the <strong>Quarkus Maven plugin</strong> (io.quarkus:quarkus-maven-plugin) and its create goal. By running the following command, you can quickly generate a new Quarkus project or</p><p>u can clone this project to test</p><p><a href="https://github.com/jagnyadatta67/Quarkus.git">GitHub - jagnyadatta67/Quarkus</a></p><pre> mvn io.quarkus.platform:quarkus-maven-plugin:create \<br>    -DprojectGroupId=com.example \<br>    -DprojectArtifactId=quarkus \<br>    -DclassName=&quot;com._15minuteconcept.HelloResource&quot; \<br>    -Dpath=&quot;/hello&quot;</pre><p>This command sets up a new Quarkus project with:</p><ul><li><strong>Group ID:</strong> com.self</li><li><strong>Artifact ID:</strong> quarkus-in-action</li><li><strong>Extension:</strong> resteasy (for building RESTful web services).</li></ul><p>You can customize the parameters to match your project needs, such as changing the group ID or artefact ID or adding additional extensions.</p><blockquote>Quarkus uses the latest available Quarkus platform version. So we need to explicitly set older version used in this book declared by the <strong>-DplatformVersion</strong> system property.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c-3fUmQOzTe_vKZ1CbFrvQ.png" /></figure><p>To start your <strong>Quarkus application</strong> in development mode, you can use either of the following commands:</p><ol><li>Using the Wrapper Script</li></ol><p>If your project includes the Maven wrapper (mvnw), you can start the application wih</p><pre>./mvnw quarkus:dev</pre><p>This runs the Quarkus application in <strong>development mode</strong> with hot-reload functionality.2. Using Maven Directly</p><p>If Maven is installed on your system</p><pre>mvn quarkus:dev</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aNhmBzFImlMLT9YrK6o3Pg.png" /></figure><h3>Outcome</h3><ul><li>Your application will start in <strong>development mode</strong>, listening on the default port (http://localhost:8080).</li><li>Any changes in your code will automatically reload without restarting the application.</li></ul><p><strong>Accessing Your Application</strong></p><p>If your Quarkus application has a REST endpoint (e.g., /hello), you can access it at:<br>http://localhost:8080/hello</p><p>Enjoy coding with <strong>Quarkus!</strong> 🚀</p><h3><strong>2. The Quarkus Command Line Interface (CLI)</strong></h3><p>simplifies tasks like generating application code, managing extensions, and launching Quarkus. While its installation is optional, it’s recommended for convenience and is covered in Appendix B or at Quarkus CLI Tooling Guide.</p><p>To generate a Quarkus application with the same setup as the Maven plugin, use:</p><pre>quarkus create app com.self:quarkus-in-action --extensions=&quot;resteasy&quot;</pre><h3><strong>3 Generating Quarkus Applications from code.quarkus.io</strong></h3><p>The <strong>Quarkus application generator</strong> at <a href="https://code.quarkus.io/">code.quarkus.io</a> offers a user-friendly graphical interface for configuring and creating Quarkus projects. Users can set all application parameters through a visual form, making it ideal for those who prefer a click-and-configure approach.</p><p>Additionally, the tool provides a REST API to programmatically generate a ZIP file of the configured Quarkus application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hy4ZAz_9miioRInYfU18Ug.png" /></figure><p><strong>Project Structure of a Generated Quarkus Application</strong></p><p>When you generate a Quarkus project using <strong>Maven</strong>, <strong>CLI</strong>, or the <strong>Web UI</strong>, the resulting structure will look like this</p><pre>quarkus-in-action/<br>├── src<br>│   ├── main<br>│   │   ├── java<br>│   │   │   └── com<br>│   │   │       └── self<br>│   │   │           └── ExampleResource.java<br>│   │   └── resources<br>│   │       ├── application.properties<br>│   │       └── META-INF<br>│   │           └── resources<br>│   │               └── index.html<br>│   └── test<br>│       ├── java<br>│       │   └── com<br>│       │       └── self<br>│       │           └── ExampleResourceTest.java<br>│       └── resources<br>├── .gitignore<br>├── mvnw<br>├── mvnw.cmd<br>├── pom.xml<br>└── README.md</pre><h3>Key Directories and Files</h3><ol><li><strong>src/main/java</strong><br>Contains the main application code, including REST resources and business logic.</li></ol><p><strong>application.properties</strong>: Configuration file for the application.</p><p><strong>META-INF/resources/index.html</strong>: Static resource example.<strong>src/test/java</strong><br>Contains test classes, such as unit or integration tests</p><p>2.<strong>pom.xml</strong><br>Maven build configuration file, including dependencies and extensions.</p><p>3.<strong>gitignore</strong><br>Specifies files and directories to be ignored by Git.</p><p>4.<strong>mvnw &amp; </strong><strong>mvnw.cmd</strong><br>Wrapper scripts to ensure Maven is available in the correct version.</p><p>This modular structure is optimized for developing, testing, and deploying Quarkus applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*S8_bRzmhb0fhsfoIZkMwOQ.png" /></figure><h3>Maven Plugins</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mOCwRoNW8PNBBwOVYaEcrQ.png" /></figure><p>The quarkus-maven-plugin manages packaging and Dev mode lifecycle for Quarkus applications. It is included in the pom.xml and aligns with the project’s Quarkus platform version. Additional plugins like maven-compiler-plugin, maven-surefire-plugin, and maven-failsafe-plugin configure Java compilation and testing. These plugins enhance functionality, and more details can be found in Maven&#39;s official documentation at <a href="https://maven.apache.org/">maven.apache.org</a>.</p><p><strong>Goals</strong>:</p><p>build (#1): Packages the application.</p><p>generate-code (#2): Generates application-specific code.</p><p>generate-code-tests: Generates test-specific code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pMx5OkVjnMyVDTbW0yn_KQ.png" /></figure><p>The Maven profile in the pom.xml customizes the Quarkus build process to generate a native GraalVM executable. Key configuration details include:</p><ul><li><strong>quarkus.package.type=native</strong>: Directs the Quarkus Maven plugin to package the application into a native executable file, enabling faster startup times and lower memory usage.</li><li><strong>skipITs</strong>: This property is used to skip the execution of integration tests during the build process. Instead, native integration tests run separately. These tests involve starting the native executable independently and invoking exposed APIs for validation.</li></ul><p>This profile simplifies native application builds and testing workflows, making it essential for optimizing Quarkus applications for production deployment.</p><p>That’s it for now! In the next blog, we’ll explore how to generate a native JAR and build a Docker image. Stay tuned as we dive deeper into Quarkus, covering additional topics such as:</p><ul><li>Customizing the application.properties file.</li><li>Modifying Quarkus applications with custom code.</li><li>Exploring more features and configurations.</li></ul><p>Keep practicing, and see you in the next post! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb3e35f608a9" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/getting-started-with-quarkus-a-guide-to-application-creation-bb3e35f608a9">Getting Started with Quarkus: A Guide to Application Creation</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java in the Age of Microservices and Containers]]></title>
            <link>https://medium.com/@jai.mail67/java-in-the-age-of-microservices-and-containers-e589de9246a0?source=rss-dfe3bd04bc1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e589de9246a0</guid>
            <category><![CDATA[quarkus-framework]]></category>
            <category><![CDATA[15minuteconcept]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[quarkus]]></category>
            <dc:creator><![CDATA[Jagnya Datta Panigrahi]]></dc:creator>
            <pubDate>Thu, 21 Nov 2024 14:05:07 GMT</pubDate>
            <atom:updated>2024-11-21T14:05:07.200Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Owgqo74bED7MGfCY1Z6PQ.jpeg" /></figure><p>As the shift to microservices and containerized architectures accelerates, Java developers face the challenge of making applications <strong>smaller</strong>, <strong>faster</strong>, and more efficient to meet the demands of modern computing. Applications today must:</p><ul><li><strong>Respond quickly</strong> to user and system requests.</li><li><strong>Adapt seamlessly</strong> to dynamic environments like virtual machines, containers, or serverless platforms.</li><li><strong>Support rapid development</strong> to keep pace with evolving requirements.</li></ul><p>For years, Java and its traditional runtime models were often seen as lagging behind newer languages like <strong>Node.js</strong> (favoured for rapid development) and <strong>Go</strong> (celebrated for performance). However, with significant advancements in Java frameworks, the language again proves why it’s the <strong>go-to choice for enterprise applications</strong>.</p><h3><strong>Introducing Quarkus: Java’s Revolutionary Framework</strong></h3><p>Among the most innovative frameworks transforming Java development is <strong>Quarkus</strong>, an open-source project introduced by <strong>Red Hat</strong>. This cutting-edge framework has gained widespread adoption for its ability to combine:</p><ul><li><strong>Developer productivity and simplicity</strong>, akin to Node.js.</li><li><strong>Unmatched speed and performance</strong>, rivaling Go.</li></ul><p>Quarkus empowers Java developers to create lightweight, efficient solutions optimized for <strong>cloud-native platforms</strong> and <strong>modern architectures</strong>.</p><h3>Exploring the Alternatives: Frameworks Competing with Quarkus</h3><p>Modern Java frameworks aim to optimize resource efficiency, startup time, and cloud readiness. Here’s a quick look at the alternatives to Quarkus and why Quarkus stands out:</p><h4>1. Spring Boot</h4><ul><li>A mature framework with a large community, designed for creating standalone Java applications.</li><li>Focuses on convention over configuration, simplifying development.</li><li>Supports native images since Spring Boot 3, but native compilation remains challenging compared to Quarkus due to reliance on reflection and runtime configuration.</li><li>Quarkus provides Spring API extensions to ease migration from Spring Boot.</li></ul><h4>2. Micronaut</h4><ul><li>Built for microservices and serverless architectures with ahead-of-time (AOT) compilation to reduce memory and improve startup time.</li><li>Decent native image support, but lacks guaranteed compatibility for third-party libraries, unlike Quarkus.</li></ul><h4>3. Helidon</h4><ul><li>A library-like framework offering two flavours: <strong>SE</strong> (lightweight library) and <strong>MP</strong> (MicroProfile-focused framework).</li><li>Supports native image creation, but third-party library integration depends on Helidon-provided configurations.</li></ul><h3>Why Quarkus Stands Out</h3><p>Quarkus redefines what Java can do in a microservices and containerized world by focusing on:</p><ul><li><strong>Build-Time Optimization</strong>: Shifting heavy lifting like configuration and dependency resolution to build time, reducing runtime overhead.</li><li><strong>Native Image Support</strong>: Leveraging <strong>GraalVM</strong> to generate ultra-fast, resource-efficient executables.</li><li><strong>Developer-Friendly Features</strong>: Offering a live coding experience that accelerates iteration and debugging.</li><li><strong>Seamless Cloud Integration</strong>: Supporting Kubernetes, Docker, and serverless architectures right out of the box.</li></ul><p>Quarkus brings together the best of both worlds the robust ecosystem of Java and the performance developers expect in the modern era.</p><h3><strong>The Quarkus architecture</strong></h3><p>Quarkus optimizes performance by shifting most framework processing to <strong>build-time</strong> during application packaging. This approach reduces runtime overhead, enabling faster startup and smaller application size, as unnecessary initialization code is excluded from the final artefact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*np0HyUpNK4Aa2SwoTNXIVw.png" /><figcaption><strong>Credit:</strong> This content is inspired by the article <a href="https://dev.to/pierregmn/quarkus-fundamentals-n77">Quarkus Fundamentals</a> by Pierre G. on Dev.to</figcaption></figure><p>To create native Java applications with GraalVM, the Substrate VM adds essential components like memory management and thread handling. Using <strong>Ahead-of-Time (AOT)</strong> compilation, GraalVM analyzes the code to find only the necessary parts (reachable classes) for your application. Unused code is removed (dead code elimination), and the remaining code is compiled into a small, fast native executable tailored for your platform (e.g., macOS, Linux).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Km5AXN64WsQCOn88SbmKIQ.png" /></figure><p>Quarkus also exposes all these integration features, making it popular among library developers. With its over 670 extensions (pluggable pieces of functionalities) that integrate different popular libraries (e.g., Hibernate, Jackson, or LangChain4j), Quarkus proves that it stands out as a framework where the Java ecosystem wants to be.</p><p>In my upcoming blogs, I plan to create Quarkus examples and set up a GitHub repository to share sample projects and real-time use cases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e589de9246a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>