<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: William</title>
    <description>The latest articles on DEV Community by William (@innovate).</description>
    <link>https://dev.to/innovate</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2732448%2F4e18d577-4f6a-462e-80d4-8ced0a5814d6.png</url>
      <title>DEV Community: William</title>
      <link>https://dev.to/innovate</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/innovate"/>
    <language>en</language>
    <item>
      <title>Building Choragi: How We Orchestrated a 6-Agent Concert Planning System with Gemini Live and Google Cloud</title>
      <dc:creator>William</dc:creator>
      <pubDate>Fri, 13 Mar 2026 11:35:52 +0000</pubDate>
      <link>https://dev.to/innovate/building-choragi-how-we-orchestrated-a-6-agent-concert-planning-system-with-gemini-live-and-google-4jg7</link>
      <guid>https://dev.to/innovate/building-choragi-how-we-orchestrated-a-6-agent-concert-planning-system-with-gemini-live-and-google-4jg7</guid>
      <description>&lt;p&gt;*We created this piece of content for the purposes of entering the Gemini Live Agent Challenge. &lt;/p&gt;

&lt;h1&gt;
  
  
  GeminiLiveAgentChallenge*
&lt;/h1&gt;

&lt;p&gt;Music has a universal power to heal and bring communities together. But behind every magical live concert is a grueling logistical nightmare. Independent artists and event planners spend weeks scouting venues, making stressful phone calls to negotiate rates, designing promotional materials, and manually wrestling with ad campaigns. &lt;/p&gt;

&lt;p&gt;We thought: &lt;em&gt;What if we could build an engine that takes away the logistical burden, turning a month of planning into a 5-minute automated sequence?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Enter &lt;strong&gt;Choragi&lt;/strong&gt;—an autonomous, multi-agent event orchestration system triggered entirely by a natural voice conversation. In this post, I’ll break down how we built this system using Java Spring Boot, Gemini Live API, Google Cloud Run, and the absolute cutting edge of Google's generative AI models.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Architecture: A Serverless Symphony
&lt;/h2&gt;

&lt;p&gt;Choragi is not a single monolith; it is a highly specialized microservices architecture. We built 6 independent Spring Boot applications and deployed them entirely on &lt;strong&gt;Google Cloud Run&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;By leveraging Cloud Run, we achieved a scalable, serverless backend where each agent scales independently based on its workload. We secured the entire internal network using Google Cloud's &lt;strong&gt;Application Default Credentials (ADC)&lt;/strong&gt;, entirely eliminating the need for hardcoded service account keys in our codebase.&lt;/p&gt;

&lt;p&gt;Here is the breakdown of the fleet:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;UI Dashboard (&lt;code&gt;ui-client&lt;/code&gt;)&lt;/strong&gt;: The real-time WebSockets command center.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Venue Scout (&lt;code&gt;venue-finder&lt;/code&gt;)&lt;/strong&gt;: Discovers potential concert spaces.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Live Negotiator (&lt;code&gt;live-negotiator&lt;/code&gt;)&lt;/strong&gt;: Telephony agent connecting Twilio to Gemini.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Creative Director (&lt;code&gt;creative-director&lt;/code&gt;)&lt;/strong&gt;: Generates 8K posters and cinematic video trailers.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Site Builder (&lt;code&gt;site-builder&lt;/code&gt;)&lt;/strong&gt;: Autonomously deploys a live promotional website.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Digital Promoter (&lt;code&gt;digital-promoter&lt;/code&gt;)&lt;/strong&gt;: Navigates Google Ads to launch campaigns.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Brains: Integrating Google AI Models
&lt;/h2&gt;

&lt;p&gt;To make this pipeline truly autonomous, we had to fuse multiple modalities of AI. &lt;/p&gt;

&lt;h3&gt;
  
  
  1. Real-Time Telephony with Gemini 2.5 Flash Native Audio
&lt;/h3&gt;

&lt;p&gt;The most ambitious part of Choragi was the &lt;code&gt;live-negotiator&lt;/code&gt;. We wanted the AI to actually call a venue owner over the phone and negotiate a booking space.&lt;/p&gt;

&lt;p&gt;We bridged a Twilio WebSocket stream directly to the &lt;strong&gt;Gemini BidiGenerateContent API&lt;/strong&gt;. Because Twilio streams audio in 8kHz MuLaw format and Gemini strictly requires 16kHz PCM, we had to build an on-the-fly byte transcoder in Java. We utilized the &lt;code&gt;["AUDIO"]&lt;/code&gt; response modality to ensure the model spoke naturally, and we implemented a custom Voice Activity Detection (VAD) algorithm using RMS thresholding to prevent noisy phone lines from interrupting the AI.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Multi-Modal Creative Generation
&lt;/h3&gt;

&lt;p&gt;Once the venue is secured, the &lt;code&gt;creative-director&lt;/code&gt; agent takes over to generate promotional assets, directly uploading the results to a public &lt;strong&gt;Google Cloud Storage&lt;/strong&gt; bucket.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tour Posters:&lt;/strong&gt; We utilized &lt;strong&gt;Gemini 2.5 Flash Image&lt;/strong&gt; to generate highly realistic, professional concert posters that strictly adhered to text prompts for the artist's name and location.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cinematic Video Trailers:&lt;/strong&gt; We integrated &lt;strong&gt;Vertex AI Veo 3.0 Fast&lt;/strong&gt; via its Long-Running Operations REST API to generate photorealistic concert stage visuals. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Robotic Web Automation with Gemini Vision
&lt;/h3&gt;

&lt;p&gt;For the &lt;code&gt;digital-promoter&lt;/code&gt;, we didn't want to use standard APIs. We wanted the agent to navigate the web like a human. Using Microsoft Playwright in a headless Chromium container, the agent literally "looks" at the Google Ads dashboard using &lt;strong&gt;Gemini 2.5 Flash&lt;/strong&gt;. The model analyzes the screenshot of the DOM and outputs precise visual coordinates and text commands (e.g., &lt;code&gt;CLICK_TEXT: Page views&lt;/code&gt;, &lt;code&gt;FILL_FIELD: businessName&lt;/code&gt;) to autonomously launch the campaign.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Hardest Technical Challenge: Vertex AI REST Routing
&lt;/h2&gt;

&lt;p&gt;When building hackathon projects, you quickly find the bleeding edge of new APIs. When integrating Veo 3.0 Fast, we bypassed the standard SDK and hit the raw Vertex AI &lt;code&gt;predictLongRunning&lt;/code&gt; REST endpoints. &lt;/p&gt;

&lt;p&gt;We successfully authenticated and triggered the video generation, receiving an Operation ID (a UUID) to poll for the video's completion. However, we discovered a routing quirk: polling the standard &lt;code&gt;v1&lt;/code&gt; API with a UUID resulted in a &lt;code&gt;400 Bad Request: The Operation ID must be a Long&lt;/code&gt;. The &lt;code&gt;v1&lt;/code&gt; endpoint was strictly expecting numeric legacy IDs!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Solution:&lt;/strong&gt; We engineered a resilient fallback mechanism. We stripped the publisher paths from the operation name and routed the polling request to the experimental &lt;code&gt;v1beta1&lt;/code&gt; endpoint. Furthermore, we wrapped the polling loop in a "God Mode" safety net—if the Google routing API threw an exception, our Spring Boot service caught the &lt;code&gt;HttpStatusCodeException&lt;/code&gt;, gracefully waited 40 seconds for the backend Veo rendering to finish, and successfully returned the Cloud Storage URL anyway. The architecture held strong.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Building Choragi pushed us to the limits of real-time streaming, asynchronous microservices, and multi-modal AI orchestration. By combining the infrastructure of Google Cloud with the intelligence of Gemini and Vertex AI, we successfully transformed the logistical chaos of event planning into an elegant, autonomous engine. &lt;/p&gt;

&lt;p&gt;Artists should spend their time creating music that heals, not navigating ad campaigns and making cold calls. With AI orchestration, we can finally let them get back to the music.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Check out our full repository and project submission for the #GeminiLiveAgentChallenge!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>geminiliveagentchallenge</category>
      <category>googlecloud</category>
      <category>ai</category>
      <category>java</category>
    </item>
    <item>
      <title>From First Issue to Merged PR: My Journey Contributing to Spring AI</title>
      <dc:creator>William</dc:creator>
      <pubDate>Sun, 19 Oct 2025 14:42:48 +0000</pubDate>
      <link>https://dev.to/innovate/from-first-issue-to-merged-pr-my-journey-contributing-to-spring-ai-i2d</link>
      <guid>https://dev.to/innovate/from-first-issue-to-merged-pr-my-journey-contributing-to-spring-ai-i2d</guid>
      <description>&lt;h2&gt;
  
  
  INTRODUCTION
&lt;/h2&gt;

&lt;p&gt;For a long time, I admired open-source contributors from afar, people who helped build the libraries, frameworks, and tools that power the software we use daily. This October, during Hacktoberfest 2025, I decided to finally take the leap and make my first real contribution to open source.&lt;/p&gt;

&lt;p&gt;That experience, contributing to Spring AI, a project under the Spring Framework turned out to be both challenging and rewarding. In this post, I’ll share what I did, what I learned, and why I think everyone should try contributing at least once.&lt;/p&gt;

&lt;h2&gt;
  
  
  How It Started
&lt;/h2&gt;

&lt;p&gt;I joined Hacktoberfest this year with a simple goal: to understand what contributing to open source really feels like. After exploring a few repositories, I noticed Spring AI, an application framework for AI engineering built by the Spring team.&lt;/p&gt;

&lt;p&gt;As someone interested in backend development, Java, and AI integrations, this felt like the perfect project to dive into. I scanned through open issues, read contribution guidelines, and picked an issue related to fixing Azure OpenAI auto-configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Contribution
&lt;/h2&gt;

&lt;p&gt;The task was small but technical, updating a Spring Boot auto-configuration class to include the correct dependency for ToolCallingAutoConfiguration.&lt;/p&gt;

&lt;p&gt;I forked the repository, cloned it locally, and followed the contribution setup. Along the way, I ran into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Checkstyle formatting errors I didn’t cause but had to understand.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build failures that taught me how Maven and Spring’s formatting rules work.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A review cycle with one of the project maintainers, who helped me refine the PR.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After I made the requested updates and pushed the final changes, the maintainer rebased, squashed, and merged my code into the project. Seeing my work appear in a widely used open-source framework was an incredible moment.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;This single PR taught me a lot more than I expected:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Read contribution guides carefully, every project has its own workflow and formatting rules.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Code reviews are learning opportunities, maintainers often suggest small but important details that improve your engineering mindset.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Even small contributions matter, fixing a line of configuration or documentation still improves the project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Communication is key. Be polite, thank reviewers, and show that you’re open to feedback.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s okay if your PR isn’t merged directly, sometimes maintainers rebase or squash your commits for consistency; what matters is that your work becomes part of the codebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Hacktoberfest Twist
&lt;/h2&gt;

&lt;p&gt;Although my pull request was part of Hacktoberfest, it wasn’t counted automatically because the maintainer rebased and merged it manually, a common workflow for large enterprise projects.&lt;/p&gt;

&lt;p&gt;Still, the real reward wasn’t the t-shirt. It was seeing my name in the Spring AI commit history and knowing that I contributed to one of the world’s most recognized Java frameworks.&lt;/p&gt;

&lt;h2&gt;
  
  
  What’s Next
&lt;/h2&gt;

&lt;p&gt;This first experience gave me confidence to keep contributing, not just during Hacktoberfest, but throughout the year. My goal now is to explore more open-source projects, particularly those involving:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Java and Spring Boot&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AI integrations&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cloud and backend architecture&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you’re thinking about contributing but haven’t yet, start small. Fix a typo, improve documentation, or pick a “good first issue.” The open-source community is more welcoming than it looks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Contributing to open source is one of the best ways to grow as a developer. It pushes you beyond tutorials into real-world collaboration, code quality, and communication.&lt;/p&gt;

&lt;p&gt;I’m grateful to the Spring AI maintainers, especially @ilayaperumalg&lt;br&gt;
, for their guidance and patience during my first PR review.&lt;/p&gt;

&lt;p&gt;This experience reminded me that even the smallest contributions make a lasting impact, not only on the project but on your growth as a developer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pull Request:&lt;/strong&gt; &lt;a href="https://github.com/spring-projects/spring-ai/pull/4636" rel="noopener noreferrer"&gt;Fix Azure OpenAI Auto-Configuration – spring-projects/spring-ai#4636&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project:&lt;/strong&gt; &lt;a href="https://github.com/spring-projects/spring-ai" rel="noopener noreferrer"&gt;Spring AI GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Author:&lt;/strong&gt; &lt;a href="https://github.com/nnam-droid12" rel="noopener noreferrer"&gt;William Nnamani&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  hacktoberfest
&lt;/h1&gt;

</description>
      <category>beginners</category>
      <category>opensource</category>
      <category>ai</category>
      <category>hacktoberfest</category>
    </item>
    <item>
      <title>Event-Driven Microservices with Apache Kafka And Spring Boot: A Practical Guide</title>
      <dc:creator>William</dc:creator>
      <pubDate>Fri, 07 Feb 2025 18:39:37 +0000</pubDate>
      <link>https://dev.to/innovate/event-driven-microservices-with-apache-kafka-and-spring-boot-a-practical-guide-2k68</link>
      <guid>https://dev.to/innovate/event-driven-microservices-with-apache-kafka-and-spring-boot-a-practical-guide-2k68</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In modern microservices architecture, event-driven systems play a crucial role in enabling scalable, decoupled, and efficient communication between services. Apache Kafka has emerged as a leading distributed event-streaming platform, widely used for real-time data processing.&lt;/p&gt;

&lt;p&gt;In this article, we will explore how to build an event-driven microservices system using &lt;strong&gt;Java Spring Boot&lt;/strong&gt; and &lt;strong&gt;Apache Kafka&lt;/strong&gt;, with a practical example of decoupling &lt;strong&gt;order processing from inventory management&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Event-Driven Microservices?
&lt;/h2&gt;

&lt;p&gt;Traditional REST-based communication introduces tight coupling between services, making them harder to scale and maintain. Event-driven microservices solve this problem by allowing services to communicate asynchronously using events.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of Event-Driven Architecture:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Decoupling&lt;/strong&gt;: Services interact via events, reducing direct dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability&lt;/strong&gt;: Independent services can scale as needed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resilience&lt;/strong&gt;: Failures in one service do not immediately impact others.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexibility&lt;/strong&gt;: Easily extend systems by adding new consumers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setting Up Apache Kafka
&lt;/h2&gt;

&lt;p&gt;Before implementing our example, make sure you have &lt;strong&gt;Apache Kafka&lt;/strong&gt; installed and running.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Download and Extract Kafka:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Head over to this website [Download Apache Kafka](https://kafka.apache.org/downloads)
unzip to your favorite location
for this article i created a folder called software in local c on windows and rename kafka_2.13-3.0.0 to just kafka
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Start Zookeeper and Kafka Broker:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    FOR ZOOKEEPER

   * To Start Zookeeper
   * open command prompt or terminal and CD into C:\softwares\kafka\bin\windows&amp;gt;
  * Then run this,  zookeeper-server-start.bat ..\..\config\zookeeper.properties 

FOR KAFKA BROKER 
  * To start kafka broker
  * open another command prompt or terminal and CD into C:\softwares\kafka\bin\windows&amp;gt;
  * Then run this, kafka-server-start.bat ..\..\config\server.properties
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Experiment with Kafka
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;create a Topic - With another cmd instance open with same path you cd into to run both kafka broker and zookper while your kafka broker and zookeeper is still open, then run this command to create a kafka topic, &lt;code&gt;kafka-topic.bat --bootstrap-server --create --topic order-topic --partitions 3 --replication-factor 1&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt; list Topic - run this command to list a kafka topic, 
&lt;code&gt;kafka-topic.bat --bootstrap-server localhost:9092 --list&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;describe a Topic - run this command to describe a kafka topic,
&lt;code&gt;kafka-topic.bat --bootstrap-server localhost:9092 --describe --topic order-topic&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;publish message from producer to consumer - Open another instance of the command prompt and then run this to publish message from producer to consumer
&lt;code&gt;kafka-console-producer.bat --broker-list localhost:9092 --topic order-topic&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;subscribe/consume message from producer - Open another instance of the command prompt and then run this to subscribe to message from the producer
&lt;code&gt;kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic order-topic --from-beginning&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Implementing the Practical Example
&lt;/h2&gt;

&lt;p&gt;Let's implement a scenario where an &lt;strong&gt;Order Service&lt;/strong&gt; processes orders, and an &lt;strong&gt;Inventory Service&lt;/strong&gt; listens to order events to update stock levels.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Spring Boot project
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Head over to &lt;a href="https://start.spring.io/" rel="noopener noreferrer"&gt;Spring Starter template&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Create a Spring Boot Kafka Producer (Order Service)&lt;/li&gt;
&lt;li&gt;add the dependency spring web and kafka
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;dependency&amp;gt;
    &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;spring-boot-starter-web&amp;lt;/artifactId&amp;gt;
&amp;lt;/dependency&amp;gt;
&amp;lt;dependency&amp;gt;
    &amp;lt;groupId&amp;gt;org.springframework.kafka&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;spring-kafka&amp;lt;/artifactId&amp;gt;
&amp;lt;/dependency&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fozqwxrhobpp6wwpjmnwb.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fozqwxrhobpp6wwpjmnwb.PNG" alt="Image description" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create a Kafka Producer:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

@Service
public class OrderProducer {
    private final KafkaTemplate&amp;lt;String, String&amp;gt; kafkaTemplate;

    public OrderProducer(KafkaTemplate&amp;lt;String, String&amp;gt; kafkaTemplate) {
        this.kafkaTemplate = kafkaTemplate;
    }

    public void sendOrderEvent(String message) {
        kafkaTemplate.send("order-topic", message);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Expose an API to trigger order processing:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/orders")
public class OrderController {
    private final OrderProducer orderProducer;

    public OrderController(OrderProducer orderProducer) {
        this.orderProducer = orderProducer;
    }

    @PostMapping("/create")
    public String createOrder(@RequestBody String orderDetails) {
        orderProducer.sendOrderEvent(orderDetails);
        return "Order event sent!";
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Create a Spring Boot Kafka Consumer (Inventory Service)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Create a Kafka Consumer:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Service;

@Service
public class InventoryConsumer {
    @KafkaListener(topics = "order-topic", groupId = "inventory-group")
    public void listenOrderEvents(ConsumerRecord&amp;lt;String, String&amp;gt; record) {
        System.out.println("Received Order Event: " + record.value());
        updateInventory(record.value());
    }

    private void updateInventory(String orderDetails) {
        // Simulate inventory update logic
        System.out.println("Inventory updated for order: " + orderDetails);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Running the Application
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Start Kafka and Zookeeper&lt;/strong&gt; (if not already running).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run the Order Service&lt;/strong&gt;: Start the producer microservice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run the Inventory Service&lt;/strong&gt;: Start the consumer microservice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trigger an Order Event&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST http://localhost:8080/orders/create &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'"{"orderId": "123", "productId": "456", "quantity": "2"}"'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Check the Consumer Logs&lt;/strong&gt;: You should see the order event being processed and the inventory updated.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Event-driven microservices with Apache Kafka provide a powerful way to build decoupled, scalable systems. In this guide, we demonstrated how to implement a simple &lt;strong&gt;order processing system&lt;/strong&gt; using &lt;strong&gt;Kafka producers and consumers&lt;/strong&gt; in &lt;strong&gt;Spring Boot&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;By adopting event-driven design, you can create robust, loosely coupled microservices that scale efficiently while ensuring smooth communication between components.&lt;/p&gt;

&lt;p&gt;Please if you find the article interesting and valuable drop a like and comment. See you in the next one, keep building!&lt;br&gt;
Follow me on socials &lt;a href="https://www.linkedin.com/in/williamnnamani" rel="noopener noreferrer"&gt;my Linkedin Handle&lt;/a&gt;&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>java</category>
      <category>kafka</category>
      <category>eventdriven</category>
    </item>
    <item>
      <title>How to Design a Scalable Microservices Architecture: Lessons from Real-World Systems</title>
      <dc:creator>William</dc:creator>
      <pubDate>Fri, 07 Feb 2025 12:42:36 +0000</pubDate>
      <link>https://dev.to/innovate/how-to-design-a-scalable-microservices-architecture-lessons-from-real-world-systems-25p6</link>
      <guid>https://dev.to/innovate/how-to-design-a-scalable-microservices-architecture-lessons-from-real-world-systems-25p6</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Microservices architecture has become the poster child of modern software development. It promises scalability, flexibility, and the dream of independent deployability. But let’s be real—building a microservices-based system isn’t all sunshine and rainbows. It comes with its own set of challenges, especially when working with Java and Spring Boot.&lt;/p&gt;

&lt;p&gt;In this article, we’ll dive into real-world lessons learned from implementing microservices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 1: Microservices Doesn’t Mean Micro-Problems
&lt;/h2&gt;

&lt;p&gt;Many teams start with microservices thinking, &lt;em&gt;"Let’s break this monolith into smaller, manageable pieces."&lt;/em&gt; Sounds great, right? Until you realize you now have 20+ services talking to each other like a whole community fetching from a stagnant stream of water.&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution: Proper Service Boundaries
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;Domain-Driven Design (DDD)&lt;/strong&gt; to define proper service boundaries.&lt;/li&gt;
&lt;li&gt;Avoid creating microservices that are &lt;em&gt;too&lt;/em&gt; micro—sometimes a monolith is just a misunderstood hero.&lt;/li&gt;
&lt;li&gt;Ensure each service has a clear, independent responsibility.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Lesson 2: Distributed Transactions Are a Nightmare
&lt;/h2&gt;

&lt;p&gt;In monolithic applications, transactions are simple—you start one, do some operations, commit or rollback. But in microservices? Welcome to the &lt;em&gt;Saga&lt;/em&gt; pattern and compensating transactions, where a failed step means you have to undo everything.&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution: Handling Transactions Properly
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use the &lt;strong&gt;Saga pattern&lt;/strong&gt; for long-running transactions.&lt;/li&gt;
&lt;li&gt;Implement &lt;strong&gt;event-driven architectures&lt;/strong&gt; with tools like Kafka or RabbitMQ.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Idempotency is your best friend&lt;/strong&gt;—ensure your services can handle duplicate requests gracefully.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Lesson 3: Latency is the Silent Killer
&lt;/h2&gt;

&lt;p&gt;Breaking down a monolith into microservices means your once-simple function call is now a network request. And we all know how reliable networks are. Suddenly, your ultra-fast system is moving at the speed of a sloth on a Monday morning. &lt;/p&gt;

&lt;h3&gt;
  
  
  Solution: Performance Optimization
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;circuit breakers&lt;/strong&gt; (Resilience4j, Hystrix) to prevent cascading failures.&lt;/li&gt;
&lt;li&gt;Implement &lt;strong&gt;caching&lt;/strong&gt; (Redis, EhCache) to avoid unnecessary calls.&lt;/li&gt;
&lt;li&gt;Monitor API latencies and optimize slow endpoints.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Lesson 4: Versioning is Inevitable
&lt;/h2&gt;

&lt;p&gt;Deploying updates in a microservices world can be like trying to replace a car tire while speeding down the highway. One breaking change, and everything falls apart.&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution: Backward-Compatible APIs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;semantic versioning&lt;/strong&gt; (e.g., v1, v2 endpoints).&lt;/li&gt;
&lt;li&gt;Follow &lt;strong&gt;API-first design&lt;/strong&gt; with OpenAPI and Swagger.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Lesson 5: Logging and Monitoring Save Lives
&lt;/h2&gt;

&lt;p&gt;Debugging a microservices system without proper logging is like trying to solve a crime without evidence. You &lt;em&gt;think&lt;/em&gt; you know what’s happening, but reality is a different story.&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution: Observability Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Centralize logs using &lt;strong&gt;ELK Stack (Elasticsearch, Logstash, Kibana)&lt;/strong&gt; or &lt;strong&gt;Grafana Loki&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Implement &lt;strong&gt;distributed tracing&lt;/strong&gt; with &lt;strong&gt;Jaeger&lt;/strong&gt; or &lt;strong&gt;Zipkin&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Monitor metrics with &lt;strong&gt;Prometheus&lt;/strong&gt; and &lt;strong&gt;Grafana&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Lesson 6: Security is Not Optional
&lt;/h2&gt;

&lt;p&gt;Exposing multiple microservices to the world without security is like leaving your house with the doors open and a sign that says, &lt;em&gt;"Come on in, free valuables inside!"&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution: Secure Your Services
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;OAuth 2.0 and JWT&lt;/strong&gt; for authentication.&lt;/li&gt;
&lt;li&gt;Implement &lt;strong&gt;API gateways&lt;/strong&gt; (Spring Cloud Gateway) for centralized security.&lt;/li&gt;
&lt;li&gt;Keep dependencies up to date to avoid vulnerabilities.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Microservices architecture, when done right, can bring immense benefits. But it requires careful planning, solid design principles, and the right set of tools. Java and Spring Boot provide a robust ecosystem to build scalable and resilient microservices, but they also come with challenges that need to be addressed.&lt;/p&gt;

&lt;p&gt;So, before you jump headfirst into microservices, ask yourself: &lt;em&gt;"Do I really need this, or can my monolith still do the job?"&lt;/em&gt; Because sometimes, the best microservice decision is not using microservices at all!&lt;/p&gt;

&lt;p&gt;Please like this post and comment if you find it valuable and interesting, till next time keep building.&lt;br&gt;
You can connect with me on socials: &lt;a href="https://www.linkedin.com/in/williamnnamani" rel="noopener noreferrer"&gt;My Linkedin Handle&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>microservices</category>
      <category>database</category>
    </item>
  </channel>
</rss>
