<?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 Pavan b on Medium]]></title>
        <description><![CDATA[Stories by Pavan b on Medium]]></description>
        <link>https://medium.com/@pavankumar0b?source=rss-b749da3db4fb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3AN0wuceX8GohoYb</url>
            <title>Stories by Pavan b on Medium</title>
            <link>https://medium.com/@pavankumar0b?source=rss-b749da3db4fb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 22:52:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pavankumar0b/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[Parallelism vs Concurrency in Java :Understanding the Key Differences]]></title>
            <link>https://medium.com/@pavankumar0b/parallelism-vs-concurrency-in-java-understanding-the-key-differences-39f5329c33bc?source=rss-b749da3db4fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/39f5329c33bc</guid>
            <category><![CDATA[threads]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[parallelism]]></category>
            <dc:creator><![CDATA[Pavan b]]></dc:creator>
            <pubDate>Mon, 06 Jul 2026 11:45:52 GMT</pubDate>
            <atom:updated>2026-07-06T11:45:52.477Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>When working with modern Java applications, especially high-performance systems, you will often hear the terms <strong>Concurrency</strong> and <strong>Parallelism</strong>. Many developers use these terms interchangeably, but they represent different concepts.</p><p>Understanding the distinction is essential for designing scalable, responsive, and efficient applications.</p><p>In this blog, we’ll explore what concurrency and parallelism mean, how Java supports them, and when to use each approach.</p><h3>What is Concurrency?</h3><p><strong>Concurrency</strong> is about dealing with multiple tasks at the same time.</p><p>It does not necessarily mean that tasks are executed simultaneously. Instead, the system progresses multiple tasks by switching between them.</p><p>Think of it as a chef preparing several dishes:</p><ul><li>Chop vegetables</li><li>Boil pasta</li><li>Prepare sauce</li></ul><p>The chef switches between tasks, ensuring all dishes progress without completing one before starting another.</p><h3>In Java</h3><p>Concurrency is typically achieved using:</p><ul><li>Threads</li><li>Executor Framework</li><li>CompletableFuture</li><li>Reactive Programming</li></ul><h3>What is Parallelism?</h3><p><strong>Parallelism</strong> means multiple tasks are executed literally at the same moment using multiple CPU cores.</p><p>If concurrency is about managing many tasks, parallelism is about executing many tasks simultaneously.</p><h3>Real-Life Example</h3><p>Imagine having four chefs instead of one.</p><p>Each chef prepares a different dish at the same time.</p><p>Result:</p><ul><li>Faster completion</li><li>Better CPU utilization</li><li>Improved throughput</li></ul><h3>In Java</h3><p>Parallelism is commonly achieved using:</p><ul><li>Parallel Streams</li><li>Fork/Join Framework</li><li>ExecutorService with multiple threads</li><li>Virtual Threads (for concurrency, not necessarily parallelism)</li><li>Structured Concurrency (Java 21+)</li></ul><p><strong>Key Differences Between Concurrency and Parallelism</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C2BxjDYRD9A-iceg1hvXng.png" /></figure><h3>When to Use Concurrency</h3><p>Use concurrency when:</p><p>✅ Handling multiple user requests</p><p>✅ Web applications</p><p>✅ Network communication</p><p>✅ Database operations</p><p>✅ Asynchronous APIs</p><h3>Example</h3><p>A banking application processing:</p><ul><li>User login</li><li>Account summary</li><li>Notifications</li></ul><p>These tasks can progress concurrently.</p><h3>When to Use Parallelism</h3><p>Use parallelism when:</p><p>✅ Processing large datasets</p><p>✅ Image processing</p><p>✅ Data analytics</p><p>✅ Machine learning workloads</p><p>✅ Complex calculations</p><h3>Example</h3><p>Generating reports for one million records where work can be split across multiple CPU cores.</p><h3>Common Misconception</h3><p>Many developers assume:</p><blockquote><em>“If I create multiple threads, I am doing parallel programming.”</em></blockquote><p>Not necessarily.</p><p>If your machine has only one CPU core, multiple threads may simply be scheduled concurrently rather than executed in parallel.</p><p><strong>Concurrency is about structure. Parallelism is about execution.</strong></p><h3>Conclusion</h3><p>Both concurrency and parallelism are critical concepts in modern Java development.</p><ul><li><strong>Concurrency</strong> improves responsiveness and resource utilization.</li><li><strong>Parallelism</strong> improves performance by leveraging multiple processors.</li><li>Java provides rich support through Threads, Executors, CompletableFuture, Fork/Join Framework, Parallel Streams, and Virtual Threads.</li></ul><p>The best Java applications often use both:</p><p>✅ Concurrency for handling many requests efficiently<br> ✅ Parallelism for accelerating CPU-intensive workloads</p><p>Understanding when to use each will help you design scalable, high-performing, and maintainable Java applications.</p><p><strong>Final Takeaway:</strong></p><blockquote>Concurrency is about managing multiple tasks efficiently. Parallelism is about executing multiple tasks simultaneously. Concurrency improves responsiveness; parallelism improves speed.<em> 🚀</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39f5329c33bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scaling Java 21 Microservices with Virtual Threads: A Smarter Alternative to Adding More Servers]]></title>
            <link>https://medium.com/@pavankumar0b/scaling-java-21-microservices-with-virtual-threads-a-smarter-alternative-to-adding-more-servers-88133055b2a3?source=rss-b749da3db4fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/88133055b2a3</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[virtual-threads]]></category>
            <category><![CDATA[java-virtual-threads]]></category>
            <category><![CDATA[scalability]]></category>
            <dc:creator><![CDATA[Pavan b]]></dc:creator>
            <pubDate>Mon, 06 Jul 2026 10:48:50 GMT</pubDate>
            <atom:updated>2026-07-06T10:48:50.227Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>As traffic grows, one of the first reactions is often to add more application servers. While horizontal scaling is a proven strategy, it also increases infrastructure costs, operational overhead, monitoring complexity, and deployment management efforts.</p><p>Recently, while evaluating a Java 21 microservice deployed across six servers, we explored a different approach: <strong>leveraging Virtual Threads (Project Loom)</strong> to improve concurrency and throughput before adding additional servers.</p><p>In this blog, I’ll discuss what Virtual Threads are, when they help, their limitations, and how organizations can evaluate them as a cost-effective scaling strategy.</p><h3>The Challenge</h3><p>Consider a typical microservice architecture:</p><p>Client</p><p>|</p><p>V</p><p>Java Microservice</p><p>|</p><p>+ → Database</p><p>+ → External REST APIs</p><p>+ → Redis</p><p>+ → Kafka</p><p>Most enterprise applications spend a significant amount of time:</p><ul><li>Waiting for database responses</li><li>Waiting for external API calls</li><li>Waiting for cache lookups</li><li>Waiting for message processing</li></ul><p>During these waiting periods, traditional platform threads remain occupied, consuming valuable resources.</p><p>As traffic increases, applications often experience:</p><ul><li>Thread pool exhaustion</li><li>Increased request latency</li><li>More memory consumption</li><li>Reduced throughput</li></ul><p>The traditional solution is:</p><p>More Traffic</p><p>↓</p><p>Add More Servers</p><p>↓</p><p>Higher Cost</p><p>But Java 21 offers another option.</p><h3>What Are Virtual Threads?</h3><p>Virtual Threads are a lightweight implementation of threads introduced as a production feature in Java 21.</p><p>Unlike traditional platform threads that map directly to operating system threads, virtual threads are managed by the JVM.</p><p>This allows applications to create:</p><p>Hundreds</p><p>Thousands</p><p>Even millions</p><p>of concurrent virtual threads with significantly lower overhead compared to traditional threads.</p><p><strong>Traditional Thread Model:</strong></p><p>Request 1 → Platform Thread 1</p><p>Request 2 → Platform Thread 2</p><p>Request 3 → Platform Thread 3</p><p>…</p><p>Each thread consumes memory and OS resources.</p><p><strong>Virtual Thread Model</strong></p><p>Request 1 → Virtual Thread</p><p>Request 2 → Virtual Thread</p><p>Request 3 → Virtual Thread</p><p>…</p><p>10,000 Requests → 10,000 Virtual Threads</p><p>The JVM efficiently schedules these virtual threads onto a smaller set of carrier threads.</p><h3>When Virtual Threads Deliver Huge Benefits</h3><p>Virtual Threads shine in <strong>I/O-bound applications</strong>.</p><h3>Ideal Use Cases</h3><p>✅ Database operations</p><p>jdbcTemplate.query(…)</p><p>✅ REST API calls</p><p>restClient.get(…)</p><p>✅ Redis operations</p><p>redisTemplate.opsForValue()</p><p>redisTemplate.opsForValue()</p><p>Show more lines</p><p>✅ Kafka consumers</p><p>✅ File operations</p><p>✅ Network communication</p><p>When requests spend most of their time waiting for responses rather than consuming CPU cycles, Virtual Threads can dramatically increase concurrency.</p><h3>Example Scenario</h3><p>Suppose an API request performs:</p><p>Database Query : 50 ms</p><p>External API : 100 ms</p><p>CPU Processing : 5 ms</p><p>— — — — — — — — — — — -</p><p>Total : 155 ms</p><p>The application spends:</p><p>145 ms waiting</p><p>5 ms computing</p><p>With traditional threads, resources are tied up while waiting.</p><p>With virtual threads, the JVM efficiently suspends waiting operations and utilizes carrier threads for other work.</p><p>This can substantially increase the number of concurrent requests a service can handle.</p><h3>When Virtual Threads Will NOT Help</h3><p>Virtual Threads are not a magic solution.</p><p>If your application is primarily CPU intensive, benefits will be limited.</p><h3>Examples</h3><p>❌ Large-scale data processing</p><p>❌ Image processing</p><p>❌ Video transcoding</p><p>❌ Heavy encryption</p><p>❌ Scientific calculations</p><h3>Spring Boot Makes Adoption Easy</h3><p>For applications running:</p><ul><li>Java 21</li><li>Spring Boot 3.2+</li></ul><p>Enabling Virtual Threads is surprisingly simple.</p><p><strong>spring.threads.virtual.enabled=true</strong></p><h3>Final Thoughts</h3><p>Before provisioning more servers, it is worth evaluating whether your Java 21 microservice is truly constrained by compute resources or simply by traditional thread management.</p><p>If your service spends most of its time waiting on databases, APIs, Redis, Kafka, or other I/O operations, Virtual Threads may unlock substantial scalability gains with minimal code changes.</p><p>Rather than immediately scaling horizontally, organizations can first optimize how efficiently existing resources are utilized. With Java 21, Virtual Threads provide a powerful new tool for doing exactly that.</p><p><strong>Scale smarter before scaling bigger.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88133055b2a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Preventing Infinite Retry Loops in Apache Camel Microservice Calls]]></title>
            <link>https://medium.com/@pavankumar0b/preventing-infinite-retry-loops-in-apache-camel-microservice-calls-a81f62a693c5?source=rss-b749da3db4fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/a81f62a693c5</guid>
            <category><![CDATA[retry]]></category>
            <category><![CDATA[production-issue]]></category>
            <category><![CDATA[apache-camel]]></category>
            <dc:creator><![CDATA[Pavan b]]></dc:creator>
            <pubDate>Wed, 01 Jul 2026 06:56:56 GMT</pubDate>
            <atom:updated>2026-07-01T06:56:56.354Z</atom:updated>
            <content:encoded><![CDATA[<h3>📌 Introduction</h3><p>While working with <strong>Apache Camel</strong> for microservice integrations, a common issue developers face is <strong>unexpected multiple retries or infinite looping</strong> when calling external services using .to().</p><p>For example:</p><p><strong>.to(“http://microservice1/api/v1/locations&quot;)</strong></p><p>If the service returns an error (like 404), Camel may <strong>retry the call multiple times</strong>, sometimes leading to <strong>15+ repeated attempts</strong>.</p><p>This blog explains <strong>why this happens</strong> and <strong>how to fix it effectively</strong>.</p><h3>⚠️ Problem Statement</h3><p>You call a microservice from a Camel route:</p><p><strong>from(“direct:start”)</strong></p><p><strong>.to(“http://microservice1/v1/locations&quot;);</strong></p><p>But when the service returns an error:</p><ul><li>The request gets retried multiple times</li><li>Logs show repeated calls</li><li>It may even appear like an infinite loop</li></ul><h3>🔍 Root Cause</h3><h3>1️⃣ Camel Default Error Handler</h3><p>By default, Camel:</p><ul><li>Retries failed exchanges up to <strong>6 times</strong></li><li>Triggers on <strong>exceptions</strong></li></ul><h3>2️⃣ HTTP Component Behavior</h3><ul><li>Camel treats <strong>non-2xx responses (like 404, 500)</strong> as exceptions</li><li>Internally uses <strong>Apache HttpClient</strong>, which may retry <strong>3 times</strong></li></ul><p>👉 Combined effect:</p><pre>6 (Camel retries) × 3 (HTTP retries) = ~18 attempts</pre><p>✅ Solution Strategies</p><h3>✅ 1. Treat Expected HTTP Codes as Success</h3><p>If 404 is a valid response (not an error), configure:</p><p><strong>.to(“http://microservice1/v1/locations?okStatusCodeRange=200-404&quot;)</strong></p><p>✅ This prevents Camel from throwing an exception<br> ✅ Stops unnecessary retries</p><p>✅ <strong>2. Disable Camel Retries</strong></p><p><strong>errorHandler(defaultErrorHandler().maximumRedeliveries(0));</strong></p><h3>✅ Key Takeaways</h3><ul><li>Camel retries happen due to <strong>exceptions + default error handler</strong></li><li>HTTP component adds <strong>additional hidden retries</strong></li><li>Non-2xx responses like 404 can trigger unnecessary retries</li><li>Misconfigured routes can cause <strong>infinite recursion</strong></li></ul><h3>🎯 Conclusion</h3><p>In microservice architectures, <strong>retry handling must be controlled carefully</strong>.<br> Without proper configuration, Camel can unintentionally cause:</p><ul><li>Performance issues</li><li>Duplicate requests</li><li>Infinite loops</li></ul><p>By applying the fixes above, you can ensure: ✅ Stable integrations<br> ✅ Controlled retry behavior<br> ✅ Clean and predictable request flow</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a81f62a693c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Splitter Pattern in Apache Camel]]></title>
            <link>https://medium.com/@pavankumar0b/understanding-the-splitter-pattern-in-apache-camel-1fd30c8c6bde?source=rss-b749da3db4fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fd30c8c6bde</guid>
            <category><![CDATA[apache-camel]]></category>
            <category><![CDATA[splitter]]></category>
            <dc:creator><![CDATA[Pavan b]]></dc:creator>
            <pubDate>Tue, 30 Jun 2026 17:12:32 GMT</pubDate>
            <atom:updated>2026-06-30T17:14:55.143Z</atom:updated>
            <content:encoded><![CDATA[<p>In enterprise integration, it’s common to receive large or complex messages that need to be broken into smaller, manageable pieces before processing. Apache Camel provides a powerful solution for this through the <strong>Splitter Enterprise Integration Pattern (EIP)</strong>.</p><h4>🔹 What is the Splitter Pattern?</h4><p>The <strong>Splitter</strong> pattern breaks a single message into multiple smaller messages and processes each part independently.</p><h3>Real-world Example:</h3><p>Imagine receiving a bulk order containing multiple items:</p><p>{</p><p>“orderId”: “123”,</p><p>“items”: [</p><p>{“itemId”: “A1”, “qty”: 2},</p><p>{“itemId”: “B2”, “qty”: 5}</p><p>]</p><p>}</p><p>Instead of processing everything at once, the splitter separates each item so they can be handled individually.</p><h3>🔹 Splitter in Apache Camel</h3><p>Apache Camel provides built-in support for the Splitter pattern using the .split() DSL.</p><h3>Basic Syntax:</h3><p>from(“direct:start”)</p><p>.split(body())</p><p>.to(“log:split-message”);</p><p>Here:</p><ul><li>body() represents the incoming message body (usually a collection)</li><li>.split() splits it into multiple messages</li><li>Each individual message is processed through the route</li></ul><h3>🔹 Example 1: Splitting a List</h3><p>from(“direct:start”)</p><p>.split(simple(“${body}”))</p><p>.to(“log:each-item”);</p><p>Show more lines</p><h3>Input:</h3><p>[“apple”, “banana”, “orange”]</p><h3>Behavior:</h3><p>Camel will process each element separately:</p><ul><li>apple</li><li>banana</li><li>orange</li></ul><h3>🔹 Parallel Processing</h3><p>By default, Camel processes splits <strong>sequentially</strong>. To improve performance, you can enable parallel processing:</p><p>from(“direct:start”)</p><p>.split(body())</p><p>.parallelProcessing()</p><p>.to(“log:parallel”);</p><h3>Benefits:</h3><ul><li>Faster processing for large datasets</li><li>Better resource utilization</li></ul><p>⚠️ <strong>Note:</strong> Ensure thread safety when using parallel processing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fd30c8c6bde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implement Multicasting With Apache Camel]]></title>
            <link>https://medium.com/@pavankumar0b/implement-multicasting-with-apache-camel-6ab0ad0ed61d?source=rss-b749da3db4fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ab0ad0ed61d</guid>
            <category><![CDATA[camel]]></category>
            <category><![CDATA[implement]]></category>
            <category><![CDATA[multicast]]></category>
            <dc:creator><![CDATA[Pavan b]]></dc:creator>
            <pubDate>Tue, 01 Apr 2025 14:10:34 GMT</pubDate>
            <atom:updated>2025-04-01T14:10:34.975Z</atom:updated>
            <content:encoded><![CDATA[<p>The Multicast EIP allows routing <strong>the same</strong> message to a number of <a href="https://camel.apache.org/manual/endpoint.html">endpoints</a> and process them in a different way. Multicasting can be done in sequentially in the same thread or using parallel processing.</p><p>Multicasting means the message will be duplicated and sent to all N number of endpoints at once, and they will all process the message independently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*NpXJ5PNfC5Oo7AxA6mPvvA.png" /></figure><h3>Using Multicast <strong>Sequentially</strong></h3><p>The following example shows how to take a request from the direct:a endpoint, then multicast these requests to direct:x, direct:y, and direct:z</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*uKcENXEFJSSGpgkT_cPnsA.png" /></figure><p>By default, Multicast EIP runs in single threaded mode, which means that the next multicasted message is processed only when the previous is finished. This means that direct:b must be done before Camel will call direct:c and so on.</p><h3>Multicasting with parallel processing</h3><p>A message is transmitted to multiple endpoints at the same time using parallel processing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*EYmaQNZYg2UkYsEFQMqOTQ.png" /></figure><p><strong>.parallelProcessing()</strong>: This option ensures that each endpoint (i.e., direct:x, direct:y, direct:z) processes the message <strong>in parallel</strong>. Instead of waiting for each endpoint to complete sequentially, the message will be sent to all three endpoints simultaneously, and Camel will process them concurrently (as long as the underlying endpoints support parallel processing).</p><p>The order of processing is not guaranteed since they are handled in parallel.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ab0ad0ed61d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to connect kafka in camel with Simple Application]]></title>
            <link>https://medium.com/@pavankumar0b/how-to-connect-kafka-in-camel-with-simple-application-53a1d6cbfa5b?source=rss-b749da3db4fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/53a1d6cbfa5b</guid>
            <dc:creator><![CDATA[Pavan b]]></dc:creator>
            <pubDate>Wed, 07 Sep 2022 12:48:36 GMT</pubDate>
            <atom:updated>2022-09-13T14:35:06.749Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello EveryOne,</p><p>We will discuss how to connect kafka in camel with sample application.I will explain briefly about Apache camel and code to connect kafka in Apache camel.</p><h4>Apache Kafka:</h4><p>Apache Kafka is a distributed <a href="https://www.redhat.com/en/topics/integration/what-is-streaming-data">data streaming</a> platform that can publish, subscribe to, store, and process streams of records in real time. It is designed to handle data streams from multiple sources and deliver them to multiple consumers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*kVWKvivtY90VspwoW-lxkw.png" /></figure><h4>Topics:</h4><p>Topic refers to a category or a common name used to store and publish a particular stream of data. Basically, topics in Kafka are similar to tables in the database.It is identified by its name, which depends on the user’s choice. A producer publishes data to the topics, and a consumer reads that data from the topic by subscribing it.</p><h4>Partitions:</h4><p>A topic is split into several parts which are known as the partitions of the topic. These partitions are separated in an order. The data content gets stored in the partitions within the topic. Therefore, while creating a topic, we need to specify the number of partitions(the number is arbitrary and can be changed later). Each message gets stored into partitions with an incremental id known as its Offset value. The order of the <strong>offset value</strong> is guaranteed within the partition only and not across the partition. The offsets for a partition are infinite.</p><h4>Producer:</h4><p>A producer is the one which publishes or writes data to the topics within different partitions. Producers automatically know that, what data should be written to which partition and broker.</p><h4>Consumer:</h4><p>A consumer is the one that consumes or reads data from the Kafka cluster via a topic. A consumer also knows that from which broker, it should read the data. The consumer reads the data within each partition in an orderly manner. It means that the consumer is not supposed to read data from offset 1 before reading from offset 0. Also, a consumer can easily read data from multiple brokers at the same time</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53a1d6cbfa5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>