<?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 Mouli Shanmuhavelu on Medium]]></title>
        <description><![CDATA[Stories by Mouli Shanmuhavelu on Medium]]></description>
        <link>https://medium.com/@mouli2k5?source=rss-e6a60bb578e5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*5PlRowNVQ2S943xz.</url>
            <title>Stories by Mouli Shanmuhavelu on Medium</title>
            <link>https://medium.com/@mouli2k5?source=rss-e6a60bb578e5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 08:59:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mouli2k5/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[Data Sync Options to Modernize Mainframe Database to Modern RDBMS]]></title>
            <link>https://medium.com/@mouli2k5/data-sync-options-to-modernize-mainframe-database-to-modern-rdbms-a8d039bc577d?source=rss-e6a60bb578e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8d039bc577d</guid>
            <category><![CDATA[database-synchronization]]></category>
            <category><![CDATA[mainframe-modernization]]></category>
            <dc:creator><![CDATA[Mouli Shanmuhavelu]]></dc:creator>
            <pubDate>Sat, 07 Sep 2024 20:29:22 GMT</pubDate>
            <atom:updated>2024-09-10T20:16:51.559Z</atom:updated>
            <content:encoded><![CDATA[<p>Modernizing legacy systems is one of the top priorities for the organizations now a days. Mainframe databases such as DB2 have served as the backbone of critical business operations for decades. However, the constraints of legacy systems, including high costs and limited scalability, often push the organizations to transition to more modern relational databases (RDBMS) such as PostgreSQL, or MySQL, or Oracle, MS SQL etc.</p><p>While modernizing a mainframe database, a key challenge is ensuring <strong>data synchronization</strong> between the old and new systems. A poorly planned sync strategy can lead to data inconsistencies, potential business disruptions, and even lost information.</p><p>During the modernization process, both the mainframe and the new RDBMS often coexist during the migration period. This could be due to gradual migration, testing, or phased rollouts. During this period, data created or modified in one system must be reflected in the other to maintain consistency.</p><p>In this article, we’ll explore the various data sync options to consider while modernizing from a mainframe to a modern RDBMS.</p><h3><strong>Option 1 : Change Data Capture (CDC)</strong></h3><p>CDC works by monitoring changes (insert, update, delete) in the mainframe database and capturing them in near real-time to apply to the new RDBMS.</p><p>CDC tools operate at the database level, watching for changes in the mainframe’s transaction logs and propagating these changes to the RDBMS. This ensures that both databases remain synchronized with minimal lag. CDC tools support <strong>bi-directional</strong> sync as well.</p><h4>Use Case</h4><p>CDC is ideal when you need <strong>real-time updates</strong> between the mainframe and RDBMS, especially in scenarios where data latency could impact business operations, such as in financial transactions or inventory systems.</p><h4>Advantages:</h4><ul><li><strong>Real-time synchronization</strong>: Changes are captured and reflected immediately.</li><li><strong>Minimal performance impact</strong>: Captures changes directly from the database logs without putting a strain on the application layer.</li><li><strong>Scalable</strong>: Can handle large volumes of data and high-frequency changes.</li></ul><h4>Challenges:</h4><ul><li><strong>Setup complexity</strong>: Requires proper configuration and infrastructure support.</li><li><strong>Handling schema changes</strong>: If the mainframe and RDBMS schemas differ significantly, managing transformations can be challenging.</li></ul><h4>Popular Tools:</h4><ul><li>Debezium</li><li>Oracle GoldenGate</li><li>IBM InfoSphere CDC</li></ul><h3><strong>Option 2: Dual-Write</strong></h3><p>Dual-write ensures that any changes made in the application are written to both the mainframe and the modern RDBMS simultaneously. The application is responsible for writing data to both databases. When a transaction occurs, such as a new record or an update, the system writes to both the mainframe and RDBMS at the same time.</p><h4>Use Case</h4><p>Dual-write is useful when <strong>real-time synchronization</strong> is critical, but you also want the flexibility to manage synchronization through the application layer.</p><h4>Advantages:</h4><ul><li><strong>Real-time data consistency</strong>: Both systems are updated simultaneously.</li><li><strong>Application-driven</strong>: Allows for more control over data updates.</li></ul><h4>Challenges:</h4><ul><li><strong>Handling partial failures</strong>: If the update to one system succeeds while the other fails, it can cause inconsistencies.</li><li><strong>Performance impact</strong>: Writing to two databases can increase transaction time and impact system performance.</li></ul><h3>Option 3: Message Queueing / streaming</h3><p>Message queueing offers an asynchronous way to synchronize data between the mainframe and RDBMS. Changes in one system are sent as messages to a queue, which are then consumed by the other system. This ensures that all changes are applied even if one system is temporarily unavailable.</p><h4>Use Case</h4><p>Message queueing is best suited for systems where <strong>eventual consistency</strong> is acceptable, and slight delays in updates between systems won’t negatively impact operations</p><h4>Advantages:</h4><ul><li><strong>Asynchronous processing</strong>: Minimizes the performance impact on both systems.</li><li><strong>Highly resilient</strong>: In case one system fails, messages are stored in the queue until they can be processed.</li><li><strong>Scalable</strong>: Can handle high data volumes and complex distributed systems.</li></ul><h4>Challenges:</h4><ul><li><strong>Message ordering</strong>: Ensuring messages are processed in the correct order is crucial to maintaining data integrity.</li><li><strong>Retries and failure handling</strong>: Requires logic for reprocessing failed messages.</li></ul><h4>Popular Tools:</h4><ul><li><strong>RabbitMQ</strong></li><li><strong>IBM MQ</strong></li><li><strong>Kafka</strong></li></ul><h3>Option 4: Extract, Transform and Load (ETL)</h3><p><strong>ETL</strong> is a traditional approach for data synchronization that involves periodically extracting data from the mainframe, transforming it to match the schema of the RDBMS, and then loading it into the new system. This is typically done in <strong>batch mode</strong>.</p><h4>Use Case</h4><p>ETL is well-suited for systems where <strong>batch processing</strong> is acceptable, such as end-of-day reporting or data warehousing.</p><h4>Advantages:</h4><ul><li><strong>Simple implementation</strong>: ETL processes are well understood and relatively easy to implement for periodic updates.</li><li><strong>Lower cost</strong>: Suitable for scenarios with limited budget or technical resources.</li></ul><h4>Challenges:</h4><ul><li><strong>Not real-time</strong>: Data sync happens at scheduled intervals, so the RDBMS may be out of sync until the next batch.</li><li><strong>High system load</strong>: Large batches can cause performance bottlenecks during extraction and load.</li></ul><h4>Popular Tools:</h4><ul><li><strong>Apache NiFi</strong></li><li><strong>Talend</strong></li><li><strong>IBM DataStage</strong></li></ul><h3>Option 5: API-based Integration</h3><p><strong>API-based integration</strong> is another method for data synchronization that leverages RESTful or SOAP APIs to share data between systems. APIs are exposed on both the mainframe and the new system, allowing real-time data exchange. When data is created or updated in one system, the API sends a request to the other system to synchronize the data</p><h4>Use Case</h4><p>API-based integration is ideal when <strong>flexibility</strong> is required in data synchronization and when you want to <strong>modularize</strong> the integration process.</p><h4>Advantages:</h4><ul><li><strong>Real-time data exchange</strong>: APIs can enable real-time syncing with low latency.</li><li><strong>Modular and flexible</strong>: Allows you to expose only the necessary data fields and services.</li><li><strong>Easily extensible</strong>: APIs are scalable and can be extended as the system grows.</li></ul><h4>Challenges:</h4><ul><li><strong>Performance impact</strong>: Real-time API calls could add latency if there is network overhead or performance bottlenecks.</li><li><strong>Error handling</strong>: Requires robust mechanisms to handle failed API calls and ensure retries or fallback procedures are in place.</li></ul><h4>Popular Tools:</h4><ul><li><strong>IBM API Connect</strong></li><li><strong>Apigee</strong></li><li><strong>Mulesoft Anypoint Platform</strong></li></ul><h3>Conclusion</h3><p>Modernizing a mainframe database to a RDBMS is complex, but with the right data synchronization strategy, it’s entirely achievable. The key is to choose the data sync option that best aligns with your organization’s needs, performance requirements, and future growth plans.</p><ul><li><strong>For real-time synchronization</strong>, consider <strong>Change Data Capture (CDC)</strong> or <strong>Dual-Write</strong>. The combination of CDC and Dual-write can also be used to achieve the real-time synchronization.</li><li><strong>For eventual consistency</strong> and scalability, <strong>Message Queueing</strong> is a solid choice.</li><li><strong>For batch updates</strong>, <strong>ETL</strong> offers a simpler and cost-effective solution.</li><li><strong>For flexibility</strong>, <strong>API-based integration </strong>is an option when you want to <strong>modularize </strong>the integration process.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8d039bc577d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solution for Kafka CommitFailedException]]></title>
            <link>https://medium.com/@mouli2k5/solution-for-kafka-commitfailedexception-c3a6c9baae51?source=rss-e6a60bb578e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3a6c9baae51</guid>
            <category><![CDATA[apache-camel]]></category>
            <category><![CDATA[kafka-commit]]></category>
            <category><![CDATA[commitfailedexception]]></category>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[kafka-consumer]]></category>
            <dc:creator><![CDATA[Mouli Shanmuhavelu]]></dc:creator>
            <pubDate>Thu, 13 Aug 2020 20:16:37 GMT</pubDate>
            <atom:updated>2020-08-13T20:16:37.365Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In this article, I’ll explain how we resolved the CommitFailedException that was frequently occurring in our Kafka Consumer applications.</p><p>we observed many occurrences of this error in our log and same messages are processed again and again which caused the duplicate messages in the target system.</p><h3>Description</h3><p>We have Open source apache kafka broker within our On-Premise environment. We have Consumer applications running in both our On-Premise and public cloud environment.</p><p>We implemented Kafka consumer applications using Apache Camel and Spring boot. We also do manual commit since we wanted to avoid the offset commit if the target system goes down in mid of processing a batch.</p><p>For some of the Kafka topics, we have more than one partitions and equivalent consumer threads. You can find our Kafka Consumer implementation details in :</p><p><a href="https://medium.com/@mouli2k5/circuit-breaker-pattern-in-kafka-consumer-application-14f6b10f8f6">Circuit breaker pattern in Kafka consumer application</a></p><h3>Exception stack trace</h3><p>All our Consumer applications had the below error trace in different times.</p><pre>KafkaConsumer[acme.accounts] [clients.consumer.internals.ConsumerCoordinator(onJoinPrepare:482)] [Consumer clientId=consumer-4, groupId=accounts] User provided listener org.apache.camel.component.kafka.KafkaConsumer$KafkaFetchRecords failed on partition revocation<br>org.apache.kafka.clients.consumer.CommitFailedException: Commit cannot be completed since the group has already rebalanced and assigned the partitions to another member. This means that the time between subsequent calls to poll() was longer than the configured max.poll.interval.ms, which typically implies that the poll loop is spending too much time message processing. You can address this either by increasing max.poll.interval.ms or by reducing the maximum size of batches returned in poll() with max.poll.records.<br> at org.apache.kafka.clients.consumer.internals.ConsumerCoordinator.sendOffsetCommitRequest(ConsumerCoordinator.java:820) ~[kafka-clients-2.3.1.jar!/:?]<br> at org.apache.kafka.clients.consumer.internals.ConsumerCoordinator.commitOffsetsSync(ConsumerCoordinator.java:692) ~[kafka-clients-2.3.1.jar!/:?]<br> at org.apache.kafka.clients.consumer.KafkaConsumer.commitSync(KafkaConsumer.java:1454) ~[kafka-clients-2.3.1.jar!/:?]<br> at org.apache.kafka.clients.consumer.KafkaConsumer.commitSync(KafkaConsumer.java:1412) ~[kafka-clients-2.3.1.jar!/:?]<br> at org.apache.camel.component.kafka.KafkaConsumer$KafkaFetchRecords.commitOffset(KafkaConsumer.java:436) ~[camel-kafka-3.0.0.jar!/:3.0.0]<br> at org.apache.camel.component.kafka.KafkaConsumer$KafkaFetchRecords.onPartitionsRevoked(KafkaConsumer.java:459) ~[camel-kafka-3.0.0.jar!/:3.0.0]<br> at org.apache.kafka.clients.consumer.internals.ConsumerCoordinator.onJoinPrepare(ConsumerCoordinator.java:478) [kafka-clients-2.3.1.jar!/:?]<br> at org.apache.kafka.clients.consumer.internals.AbstractCoordinator.joinGroupIfNeeded(AbstractCoordinator.java:410) [kafka-clients-2.3.1.jar!/:?]<br> at org.apache.kafka.clients.consumer.internals.AbstractCoordinator.ensureActiveGroup(AbstractCoordinator.java:358) [kafka-clients-2.3.1.jar!/:?]<br> at org.apache.kafka.clients.consumer.internals.ConsumerCoordinator.poll(ConsumerCoordinator.java:353) [kafka-clients-2.3.1.jar!/:?]<br> at org.apache.kafka.clients.consumer.KafkaConsumer.updateAssignmentMetadataIfNeeded(KafkaConsumer.java:1251) [kafka-clients-2.3.1.jar!/:?]<br> at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1220) [kafka-clients-2.3.1.jar!/:?]<br> at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1159) [kafka-clients-2.3.1.jar!/:?]<br> at org.apache.camel.component.kafka.KafkaConsumer$KafkaFetchRecords.doRun(KafkaConsumer.java:307) [camel-kafka-3.0.0.jar!/:3.0.0]<br> at org.apache.camel.component.kafka.KafkaConsumer$KafkaFetchRecords.run(KafkaConsumer.java:218) [camel-kafka-3.0.0.jar!/:3.0.0]<br> at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_171]<br> at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_171]<br> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_171]<br> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_171]<br> at java.lang.Thread.run(Unknown Source) [?:1.8.0_171]</pre><p>The implication of this error was Consumer tried to Commit the offset and it failed. Due to this it fetched the same messages again and sent the duplicate messages to our downstream applications.</p><h3>Possibilities of Commit Failure</h3><ul><li>If there are any network failures, consumers cannot reach out to broker and will throw this exception. But there were no network failures when these exceptions occurred.</li><li>As mentioned in the error trace, if too much time is spent on processing the message, the ConsumerCoordinator will lose the connection and the commit will fail. So we analyzed this possibility and found that the below configurations will have impact on polling.</li></ul><p>The values given here are the default kafka consumer configuration values.</p><p>request.timeout.ms=40000<br>heartbeat.interval.ms=3000<br>max.poll.interval.ms=300000<br>max.poll.records=500<br>session.timeout.ms=10000</p><h3>Solution</h3><p>We just reduced the max.poll.records to 100 but still the exception was occurring some times. So we changed the configurations as below;</p><p>request.timeout.ms=300000<br>heartbeat.interval.ms=1000<br>max.poll.interval.ms=900000<br>max.poll.records=100<br>session.timeout.ms=600000</p><p>We reduced the heartbeat interval so that broker will be updated frequently that the Consumer is active. And also increased the session timeout configurations.<br>After deploying our consumers with these configurations we do not see the error anymore.</p><h3>Summary</h3><p>You do not need to configure the same values in your consumer applications.</p><p>But reducing the max poll records is not solving the error, you can try with the other configurations as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3a6c9baae51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOAP Webservices using Apache Camel, Springboot and CXF]]></title>
            <link>https://medium.com/@mouli2k5/soap-webservices-using-apache-camel-springboot-and-cxf-201ca25b4e2?source=rss-e6a60bb578e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/201ca25b4e2</guid>
            <category><![CDATA[apache-camel]]></category>
            <category><![CDATA[apache-cxf]]></category>
            <category><![CDATA[ibm-mq-client]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[soap-webservices]]></category>
            <dc:creator><![CDATA[Mouli Shanmuhavelu]]></dc:creator>
            <pubDate>Mon, 27 Apr 2020 14:19:14 GMT</pubDate>
            <atom:updated>2020-04-27T14:19:14.192Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In this article, we will see how to write a common implementation for a SOAP service which can be accessed by both HTTP and JMS endpoints.<br>We will be using Apache Camel, CXF and Springboot frameworks for this implementation.</p><p>As I do not see many reference for IBM MQ integration, I have integrated with IBM MQ message broker in this sample implementation. You can also integrate with any other message brokers like ActiveMQ or RabbitMQ by adding its dependencies to the project.</p><p>It is required to know the basics of Apache Camel, CXF and Springboot to continue with this article. You can find the complete source code of the application in github given in Summary section.</p><h4>Apache Camel</h4><p>Apache camel is a powerful opensource integration framework to efficiently integrate with various systems to exchange messages.</p><h4>Apache CXF</h4><p>Apache CXF is an open source services framework. It helps you build and develop services using APIs like JAX-WS and JAX-RS. These services can speak a variety of protocols such as SOAP, XML/HTTP, RESTful HTTP, or CORBA and work over a variety of transports such as HTTP, JMS or JBI.</p><h4>Springboot</h4><p>Springboot provides auto-configuration for Apache Camel. Auto-configuration of CamelContext auto-detects the Camel routes available in Spring context and registers the key Camel utilities.</p><h3>Application overview</h3><p>In this sample application, we will write a SOAP service which will get the employee id in the request and returns the corresponding employee details in response.<br>It is configured with both the HTTP and JMS endpoints. You can send a SOAP request through Http or JMS endpoint and the response will be returned to the same endpoint. We will use the tomcat embedded container of the Springboot to implement Http endpoint.</p><h3>Application Structure</h3><p>The overall structure of the application is depicted in the picture below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*yQe52RiVaixwhzW5eNAhtA.png" /></figure><h4>wsdl</h4><p>The wsdl definition of the service to fetch the EmployeeDetails is given here. It contains the definition of Request object and Response object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*e7MyZjP0l7PCkXNjgD_xdw.png" /></figure><h4>soap request</h4><p>GetEmployeeDetailRequest is the request object which has one field named EmployeeID in SOAP body</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*p-sWfYBwVUAak2yyfHGMdA.png" /></figure><h4>soap response</h4><p>GetEmployeeDetailResponse is the response object which contains the fields named EmployeeID, EmployeeName and EmployeeEmail in SOAP Body.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*SWsD6A_pOVmOUjlPQw4U7w.png" /></figure><h4>endpoint xml</h4><p>I have created a file called get-employee-detail.xml to define the endpoints for Http and JMS. Two beans with id cXFGetEmployeeDetailHttp and cXFGetEmployeeDetailWmq0 will be created which will be used by Apache Camel to consume the messages.</p><p>I have also provided some interceptors to print the exact soap request and soap response messages for debugging purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b6aEyCeYmwTi-ueRyLsaNg.png" /></figure><h4>xsd validation</h4><p>By setting the cxf property <em>schema-validation-enabled</em> to true, we make use of xsd validation by CXF.</p><h3>Summary</h3><p>We have seen a sample implementation of SOAP web services using all open source technologies. This application can be deployed as a standalone application with embedded tomcat. It can also deployed in JBoss, Websphere or Weblogic servers.</p><p>The source code of the application is <a href="https://github.com/moulishanmuhavelu/camelcxfsoapservice">here in Github</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=201ca25b4e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Circuit breaker pattern in Kafka consumer application]]></title>
            <link>https://medium.com/@mouli2k5/circuit-breaker-pattern-in-kafka-consumer-application-14f6b10f8f6?source=rss-e6a60bb578e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/14f6b10f8f6</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[apache-camel]]></category>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[circuit-breaker]]></category>
            <dc:creator><![CDATA[Mouli Shanmuhavelu]]></dc:creator>
            <pubDate>Sun, 08 Mar 2020 16:13:30 GMT</pubDate>
            <atom:updated>2020-03-08T16:13:30.304Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction</h4><p>In this article, we will see how to handle the failure scenarios in Kafka Consumer application. We will implement the Circuit breaker pattern in Kafka Consumer application using Apache camel and Spring boot.<br>It is required to know the basics of Kafka concepts, Apache camel and Springboot to proceed with this article.</p><p><strong>Message processing challenge in Kafka</strong><br>Imagine that we have a Kafka consumer application that consumes a message from a Kafka topic and send the data to an external service. If the service is down, the application should stop consuming any messages from Kafka topic. Also, the current batch of messages consumed from the topic should not be committed back to Kafka so that these messages can be processed again once the service is up again. We can use Circuit breaker pattern to handle this scenario.</p><p><strong>What is Circuit breaker pattern ?</strong><br>Circuit breaker is a design pattern implemented to check if the external service is available. It will block the application accessing the external service until it becomes available and implement any failure mechanism in the mean time. Once the service is back again, it will allow the application to access the external service as in normal behavior.</p><p><strong>Apache camel </strong><br>Apache camel is a powerful opensource integration framework to efficiently integrate with various systems to exchange messages. Camel has Kafka component to produce and consume to communicate with Kafka. It provides out of box features for Streaming, handling failure scenarios in Kafka etc.</p><p><strong>Springboot</strong><br>Springboot provides auto-configuration for Apache Camel. Auto-configuration of CamelContext auto-detects the Camel routes available in Spring context and registers the key Camel utilities. Spring boot property configuration also supports Camel properties.</p><p><strong>ThrottlingRoutePolicy in Apache Camel</strong><br>Configuring a route policy in a camel route is used to control the route during runtime. <em>For example</em>, you can define a route policy to stop the route during a failure condition. ThrottlingRoutePolicy is used to suspend or resume routes dynamically based on some conditions.</p><p>For our scenario, we want to stop consuming from Kafka topic when external service is down and resume processing once the service becomes available. We can configure the failure threshold and also the halfOpen time to check if service is available. We can call the healthCheck to see if service is available and resume message processing again as shown in the diagram here</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*sT_18sDRc3NK05C8n21gfw.png" /><figcaption>Circuit breaker patter overview</figcaption></figure><p><strong>Kafka Consumer implementation</strong></p><p>Let us have two applications for this example:</p><ol><li>Kafka Consumer</li><li>External Service</li></ol><p>In Kafka Consumer application, we have Apache Camel and Springboot. It will consume message from a Kafka topic and send the message to the External service application which is implemented using Springboot.</p><p>Let us take a look at : <a href="https://gist.github.com/moulishanmuhavelu/92fbea2402d244f3617ed4466d4c99d6">https://gist.github.com/moulishanmuhavelu/92fbea2402d244f3617ed4466d4c99d6</a></p><p>The code snippet in the above link shows the Camel route implementation. We set a ThrottlingRoutePolicy implementation of RoutePolicy to the Camel route. We can also define the policy to be called only with the specific exceptions that we want. Only manual commit to kafka option is used so that we can control the message commit based on the availability of the external service.</p><p>A healthCheck call is implemented to check the availability of the external service when the circuit is open.</p><p>KafkaManualCommit implementation of Camel is used to do the manual commit to Kafka. It will check if this is the last record in the batch and then commit the batch offset to Kafka.</p><p>The external service is a simple Spring boot application exposing a REST endpoint. This application runs in the port that is configured. It exposes 2 endpoints, one for healthCheck and the other for process message. All the scenarios of the KafkaConsumer application can be tested by starting and stopping the external service application</p><p><strong>Summary</strong><br>In this article, we went through how to handle failure scenarios in Kafka consumer application to avoid any message loss.<br>We also saw how to make a Kafka consumer application to be resilient for the failure of downstream applications.</p><p>The source code of the consumer application is available in <a href="https://github.com/moulishanmuhavelu/CamelKafkaConsumer">Kafka Consumer</a> and the external service is available in <a href="https://github.com/moulishanmuhavelu/MySampleRestService">Sample Service</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14f6b10f8f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>