<?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 Firman on Medium]]></title>
        <description><![CDATA[Stories by Firman on Medium]]></description>
        <link>https://medium.com/@mfirmanakbar?source=rss-de57ddfbb121------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hlwKlX_ljydxnlj-1JAfNg.png</url>
            <title>Stories by Firman on Medium</title>
            <link>https://medium.com/@mfirmanakbar?source=rss-de57ddfbb121------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 01:00:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mfirmanakbar/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[When One KEYS * Command Took Down Our Redis]]></title>
            <link>https://medium.com/@mfirmanakbar/when-one-keys-command-took-down-our-redis-9c2c51c90049?source=rss-de57ddfbb121------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c2c51c90049</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[production]]></category>
            <category><![CDATA[redis]]></category>
            <dc:creator><![CDATA[Firman]]></dc:creator>
            <pubDate>Sun, 15 Feb 2026 05:01:56 GMT</pubDate>
            <atom:updated>2026-02-15T05:01:56.510Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GKGtqfZdYgAzOGqpYjk56Q.png" /></figure><p>Sometimes production issues <strong>don’t come from complex bugs</strong>. Sometimes, they come from<strong> a</strong> <strong>single command</strong>. In our case, it was this:</p><pre>KEYS *</pre><p>And <strong>YES,</strong> it was executed in production.</p><h3>What Happened?</h3><p>One of our team members ran KEYS * on our production Redis instance. At first, it looks harmless. Just listing keys, right? then here’s what actually happened:</p><ul><li>CPU usage spiked drastically</li><li>Redis became slow</li><li>Some services got timed out and unstable</li><li>Threads waiting for Redis responses got stuck</li></ul><p>All of that, because of just <strong>one</strong> command.</p><h3>Why is KEYS * Dangerous?</h3><p>The KEYS command scans the entire Redis. That means:</p><ul><li>It is blocking</li><li>It runs in a single thread (Redis is single-threaded)</li><li>It consumes CPU while scanning everything</li><li>It prevents other commands from executing efficiently</li></ul><p>If your Redis contains millions of keys, this command becomes extremely expensive.</p><p>It’s fine for:</p><ul><li>Local development</li><li>Small datasets</li><li>Debugging in <strong>non-production environments</strong></li></ul><p>It is <strong>not fine for production</strong>.</p><h3>The Real Impact</h3><p>What made it worse wasn’t just high CPU. Because Redis is often a critical dependency (caching, session store, locks, rate limiting), when Redis slows down.</p><h3>The Correct Way: Use SCAN</h3><p>If you need to search for keys safely in production, use SCAN.</p><pre>SCAN 0 MATCH order:* COUNT 100</pre><p>What makes SCAN better?</p><ul><li>It is non-blocking</li><li>It iterates gradually</li><li>It returns partial results</li><li>It does not freeze Redis</li></ul><p>You keep calling SCAN using the returned cursor until it returns 0.</p><p>This makes it safe even with large datasets.</p><h3>Production Best Practice: Block KEYS</h3><p>After this incident, we implemented a rule:</p><blockquote>KEYS must not be usable in production.</blockquote><p>we disable it inside redis.conf:</p><pre>rename-command KEYS &quot;&quot;</pre><p>This completely disables the command.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c2c51c90049" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How target="_top" Saved My Credit Card API Integration]]></title>
            <link>https://medium.com/@mfirmanakbar/how-target-top-saved-my-credit-card-api-integration-889624a2cfb8?source=rss-de57ddfbb121------2</link>
            <guid isPermaLink="false">https://medium.com/p/889624a2cfb8</guid>
            <category><![CDATA[iframe]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[creditcardpayment]]></category>
            <category><![CDATA[payment-gateway]]></category>
            <category><![CDATA[fintech]]></category>
            <dc:creator><![CDATA[Firman]]></dc:creator>
            <pubDate>Sat, 24 Jan 2026 05:05:37 GMT</pubDate>
            <atom:updated>2026-01-24T05:05:37.139Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LcdgPrLy0P2BclFx" /></figure><p>Working as a payment gateway means dealing with many kinds of integrations. APIs, different behaviors between sandbox and production, and sometimes… unexpected problems.</p><p>One interesting case I faced was when integrating <strong>Credit Card payments with Finpay (</strong><a href="https://hub.finpay.id/docs/finpay-pg/api/credit-card/threeds-auth-payer"><strong>docs</strong></a><strong>)</strong></p><h3>The Problem</h3><p>The payment flow itself was normal:</p><ul><li>User chooses credit card</li><li>Goes to authentication (3DS)</li><li>Then returns to the merchant</li></ul><blockquote>But there was one issue → <strong>Finnet CC API did not give us a direct redirect URL</strong> Instead, they provided an <strong>iframe-based HTML response</strong>.</blockquote><p>At first, I thought:</p><blockquote>“Okay, just render the iframe and done.”</blockquote><p>But reality said otherwise.</p><h3>Trying to Find a Way Around It</h3><p>I started digging into:</p><ul><li>How the iframe is rendered</li><li>How the form is submitted</li><li>How browsers handle embedded payment pages</li></ul><p>Then I noticed something small that I had never really paid attention to before:</p><blockquote>The target attribute in the form</blockquote><p>By default, the form was submitted with target=_self</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1uvp25eIKGVI9NmqCzVRxQ.png" /><figcaption>www.google.com</figcaption></figure><p>Out of curiosity, I tried changing it to target=_top</p><p>And surprisingly… it worked.</p><h3>Why target=&quot;_top&quot; Fixed Everything</h3><p>target=&quot;_top&quot; tells the browser:</p><ul><li>Load the response in the <strong>full window</strong></li><li>Break out from any iframe</li><li>Act like a normal full-page redirect</li></ul><p>The result:</p><ul><li>The 3DS page loaded properly</li><li>No iframe issues</li><li>Much better behavior on mobile browsers</li><li>The flow became stable</li></ul><h3>The funny part?</h3><blockquote><em>I didn’t change the Finnet API at all.<br>I only changed </em><strong><em>how the browser handles the form submission</em></strong><em>.</em></blockquote><p>Simple Example</p><pre>&lt;div id=&quot;threedsChallengeRedirect&quot; style=&quot;height: 100vh&quot;&gt;<br>  &lt;form<br>    id=&quot;threedsChallengeRedirectForm&quot;<br>    method=&quot;POST&quot;<br>    action=&quot;https://ap.gateway.mastercard.com/acs/mastercard/v2/prompt&quot;<br>    target=&quot;_top&quot;<br>  &gt;<br>    &lt;input<br>      type=&quot;hidden&quot;<br>      name=&quot;creq&quot;<br>      value=&quot;xxxxxxxxxxxxxxxxxxx&quot;<br>    /&gt;<br>  &lt;/form&gt;<br><br>  &lt;script id=&quot;authenticate-payer-script&quot;&gt;<br>    var e = document.getElementById(&quot;threedsChallengeRedirectForm&quot;);<br>    if (e) {<br>      e.submit();<br>    }<br>  &lt;/script&gt;<br>&lt;/div&gt;</pre><p>That’s it.</p><blockquote>Such a small change, but a big impact.</blockquote><h3>Closing</h3><p>If you’re working with:</p><ul><li>Payment gateways</li><li>Credit card or 3DS integrations</li><li>APIs that force you to use iframes</li></ul><p>Take a closer look at <strong>how your form is submitted</strong>.</p><p>Sometimes, the solution is simpler than you think 🙂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=889624a2cfb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Install ELK Stack & Setup Spring Boot Logging with Filebeat]]></title>
            <link>https://medium.com/@mfirmanakbar/install-elk-stack-setup-spring-boot-logging-with-filebeat-a6b1ff13eb85?source=rss-de57ddfbb121------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6b1ff13eb85</guid>
            <category><![CDATA[elk-stack]]></category>
            <category><![CDATA[filebeat]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[logstash]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <dc:creator><![CDATA[Firman]]></dc:creator>
            <pubDate>Sun, 21 Dec 2025 11:26:47 GMT</pubDate>
            <atom:updated>2025-12-21T11:26:47.637Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0QO8JNEvTu9Zdhnt5c0jbw.png" /></figure><p>In this guide, I will show you how to install ELK stack (Elasticsearch, Logstash, Kibana) and send logs from a Spring Boot app using Logback and Filebeat.</p><h3>Prepare Your System</h3><p>First, update your server and install some tools:</p><pre>sudo apt update &amp;&amp; sudo apt upgrade -y<br>sudo apt install apt-transport-https wget curl gnupg -y</pre><p>Add the Elastic repository:</p><pre>wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg<br>echo &quot;deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main&quot; | sudo tee /etc/apt/sources.list.d/elastic-8.x.list<br>sudo apt update</pre><h3>Install ELK Stack</h3><h4>Elasticsearch</h4><p>Install and start Elasticsearch, Elasticsearch stores and indexes all logs.</p><pre>sudo apt install elasticsearch -y<br>sudo systemctl enable elasticsearch<br>sudo systemctl start elasticsearch</pre><p>Check with:</p><pre>curl -k https://localhost:9200</pre><h4>Kibana</h4><p>Install and start Kibana, Kibana shows dashboards and visualizations.</p><pre>sudo apt install kibana -y<br>sudo systemctl enable kibana<br>sudo systemctl start kibana</pre><p>Edit the config to allow access from outside:</p><pre>sudo nano /etc/kibana/kibana.yml<br># change: server.host: &quot;0.0.0.0&quot;</pre><p>Open port and access:</p><pre>sudo ufw allow 5601</pre><p>Then visit <a href="http://your_server_ip:5601/">http://YOUR_SERVER_IP:5601</a></p><h4>Config Elasctic &amp; Kibana</h4><p>Open Kibana in your browser <a href="http://your_server_ip:5601/">http://YOUR_SERVER_IP:5601</a></p><p>Find the Elastic token :</p><pre>sudo /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana</pre><p>Find Kibana Verification Code :</p><pre>sudo /usr/share/kibana/bin/kibana-verification-code</pre><p>Reset the password where username is elastic</p><pre>sudo /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic</pre><h4>Logstash</h4><p>Install and start Logstash. Logstash processes logs and sends them to Elasticsearch.</p><pre>sudo apt install logstash -y<br>sudo systemctl enable logstash<br>sudo systemctl start logstash</pre><h3>How to send Spring Boot Logs to Logstash</h3><p>How it works:</p><ul><li>Spring Boot writes logs to file using Logback</li><li>Filebeat reads the log files</li><li>Filebeat sends logs to Logstash (or directly to Elasticsearch)</li><li>Logstash (optional) parses logs</li><li>Elasticsearch stores logs</li><li>Kibana displays logs</li></ul><h4>Configure Spring Boot Logback</h4><p>In your Spring Boot project, create logback-spring.xml in src/main/resources/ , here the Example simple config that makes your app write logs to a file that Filebeat can read.</p><pre>&lt;configuration scan=&quot;true&quot;&gt;<br><br>    &lt;property name=&quot;LOG_DIR&quot; value=&quot;/var/log/taxes-backend&quot;/&gt;<br>    &lt;property name=&quot;APP_NAME&quot; value=&quot;taxes-backend&quot;/&gt;<br><br>    &lt;appender name=&quot;CONSOLE&quot; class=&quot;ch.qos.logback.core.ConsoleAppender&quot;&gt;<br>        &lt;encoder&gt;<br>            &lt;pattern&gt;%d{HH:mm:ss} %-5level [%thread] %logger{36} - %msg%n&lt;/pattern&gt;<br>        &lt;/encoder&gt;<br>    &lt;/appender&gt;<br><br>    &lt;appender name=&quot;FILE&quot; class=&quot;ch.qos.logback.core.rolling.RollingFileAppender&quot;&gt;<br>        &lt;file&gt;${LOG_DIR}/${APP_NAME}-app.log&lt;/file&gt;<br>        &lt;rollingPolicy class=&quot;ch.qos.logback.core.rolling.TimeBasedRollingPolicy&quot;&gt;<br>            &lt;fileNamePattern&gt;${LOG_DIR}/${APP_NAME}.%d{yyyy-MM-dd}.gz&lt;/fileNamePattern&gt;<br>            &lt;maxHistory&gt;30&lt;/maxHistory&gt;<br>        &lt;/rollingPolicy&gt;<br>        &lt;encoder&gt;<br>            &lt;pattern&gt;%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread] %logger{36} - %msg%n&lt;/pattern&gt;<br>        &lt;/encoder&gt;<br>    &lt;/appender&gt;<br><br>    &lt;root level=&quot;INFO&quot;&gt;<br>        &lt;appender-ref ref=&quot;CONSOLE&quot;/&gt;<br>        &lt;appender-ref ref=&quot;FILE&quot;/&gt;<br>    &lt;/root&gt;<br><br>&lt;/configuration&gt;</pre><p>Make sure the log directory is available on both your local machine and the VM server where your Spring Boot JAR is deployed.</p><pre>sudo mkdir -p /var/log/myapp<br>sudo chmod 777 /var/log/myapp</pre><h4>Install and Configure Filebeat</h4><p>Install Filebeat:</p><pre>sudo apt install filebeat -y</pre><p>Open filebeat config file:</p><pre>sudo nano /etc/filebeat/filebeat.yml</pre><p>Edit filebeat.yml, set input to read your Spring Boot log file:</p><pre># ============================== Filebeat inputs ===============================<br><br>filebeat.inputs:<br>  - type: log<br>    enabled: true<br>    paths:<br>      - /var/log/taxes-backend/taxes-backend-app.log<br><br><br># ============================== Filebeat modules ==============================<br><br>filebeat.config.modules:<br>  # Glob pattern for configuration loading<br>  path: ${path.config}/modules.d/*.yml<br><br>  # Set to true to enable config reloading<br>  reload.enabled: false<br><br># ======================= Elasticsearch template setting =======================<br><br>setup.template.settings:<br>  index.number_of_shards: 1<br><br><br><br># =================================== Kibana ===================================<br><br>setup.kibana:<br><br># ------------------------------ Logstash Output -------------------------------<br><br>output.logstash:<br>  hosts: [&quot;localhost:5044&quot;]<br><br># ================================= Processors =================================<br>processors:<br>  - add_host_metadata:<br>      when.not.contains.tags: forwarded<br>  - add_cloud_metadata: ~<br>  - add_docker_metadata: ~<br>  - add_kubernetes_metadata: ~<br></pre><p>This localhost:5044 to tell Filebeat where to send logs (Logstash or Elasticsearch)</p><p>Start Filebeat and it will read your log files and forward them.:</p><pre>sudo systemctl enable filebeat<br>sudo systemctl restart filebeat<br>sudo systemctl status filebeat</pre><h4>Configure Logstash Pipeline</h4><p>Create a Logstash config, e.g., springboot-logstash.conf:</p><pre>sudo nano /etc/logstash/conf.d/springboot.conf</pre><p>Edit the config file :</p><pre>input {<br>  beats {<br>    port =&gt; 5044<br>  }<br>}<br><br>filter {<br>  grok {<br>    match =&gt; { &quot;message&quot; =&gt; &quot;%{TIMESTAMP_ISO8601:timestamp} %{LOGLEVEL:level} \[%{DATA:thread}\] %{DATA:logger} - %{GREEDYDATA:msg}&quot; }<br>  }<br><br>  date {<br>    match =&gt; [&quot;timestamp&quot;, &quot;yyyy-MM-dd HH:mm:ss&quot;]<br>    timezone =&gt; &quot;UTC&quot;<br>  }<br><br>  mutate {<br>    remove_field =&gt; [&quot;timestamp&quot;]<br>  }<br>}<br><br>output {<br>  elasticsearch {<br>    hosts =&gt; [&quot;https://localhost:9200&quot;]<br>    user =&gt; &quot;elastic&quot;<br>    password =&gt; &quot;ENTER_YOUR_ELASTIC_PASSWORD&quot;<br>    ssl_verification_mode =&gt; &quot;none&quot;<br>    index =&gt; &quot;springboot-%{+YYYY.MM.dd}&quot;<br>  }<br>}</pre><p>Test the Logstash config syntax</p><pre>sudo /usr/share/logstash/bin/logstash --config.test_and_exit -f /etc/logstash/conf.d/springboot.conf</pre><p>Start Logstash and this receives logs from Filebeat and sends them to Elasticsearch.</p><pre><br>sudo systemctl restart logstash<br></pre><p>Run this test command and make sure an index like springboot-2025 should appear in Elasticsearch.</p><pre>curl -k -u elastic:ENTER_YOUR_ELASTIC_PASSWORD &quot;https://localhost:9200/_cat/indices?v&quot;</pre><h3>View Logs in Kibana</h3><ul><li>Open Kibana: <a href="http://your_server_ip:5601/">http://YOUR_SERVER_IP:5601</a></li><li>Go to Stack Management</li><li>Create an Index Pattern that matches your logs (e.g., springboot-logs-*)</li><li>Use Discover to see logs</li><li>Build Dashboards to visualize log levels, services, errors, etc.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6b1ff13eb85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cara Cepat Membuat Project Laravel + Livewire + Bootstrap CSS 5]]></title>
            <link>https://medium.com/@mfirmanakbar/cara-cepat-membuat-project-laravel-livewire-bootstrap-css-5-7b6c8169f8d7?source=rss-de57ddfbb121------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b6c8169f8d7</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[laravel-livewire]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[bootstrap-5]]></category>
            <category><![CDATA[livewire]]></category>
            <dc:creator><![CDATA[Firman]]></dc:creator>
            <pubDate>Thu, 25 Sep 2025 10:49:10 GMT</pubDate>
            <atom:updated>2025-09-25T10:49:10.850Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pFVZyMJfP4REy0DgSZkWIw.png" /></figure><p>Kalau kamu baru mulai dengan Laravel, berikut adalah langkah praktis untuk setup project Laravel dengan <strong>Livewire</strong> dan <strong>Bootstrap</strong> dari awal.</p><p>Jalankan perintah berikut untuk menginstal Laravel Installer secara global:</p><pre>$ composer global require laravel/installer</pre><p>Gunakan command laravel new untuk membuat project:</p><pre>$ laravel new PROJECT_NAME<br><br># pilih NONE, kita install manual library yang mau dipakai saja</pre><p>Kita install Livewire manual supaya layout bisa kita atur dari awal:</p><pre>$ composer require livewire/livewire<br></pre><p>Tambahkan Bootstrap dan Popper.js dengan cara jalankan ini di terminal:</p><pre>$ npm install bootstrap @popperjs/core</pre><p>Buka file resources/js/app.js lalu tambahkan:</p><pre>// 1. Laravel bootstrap (axios, echo, dll)<br>import &quot;./bootstrap&quot;;<br><br>// 2. CSS global<br>import &quot;../css/app.css&quot;;<br><br>// 3. JS Library tambahan (bootstrap, alpine, dll)<br>import &quot;bootstrap/dist/js/bootstrap.bundle&quot;;</pre><p>Edit resources/css/app.css atau buat file baru:</p><pre>@import &quot;bootstrap/dist/css/bootstrap.min.css&quot;;<br><br>/* Tambahkan custom CSS kamu di bawah ini */<br>body {<br>    font-family: &quot;Instrument Sans&quot;, ui-sans-serif, system-ui, sans-serif,<br>        &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;,<br>        &quot;Noto Color Emoji&quot;;<br>}</pre><p>Buka resources/views/welcome.blade.php lalu ubah menjadi seperti ini:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br><br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;ie=edge&quot;&gt;<br>    &lt;title&gt;Welcome&lt;/title&gt;<br>    @vite([&#39;resources/css/app.css&#39;, &#39;resources/js/app.js&#39;])<br>&lt;/head&gt;<br><br>&lt;body&gt;<br>    &lt;h1&gt;Welcome to Our Application!&lt;/h1&gt;<br>    &lt;p&gt;This is the welcome page.&lt;/p&gt;<br>    &lt;button type=&quot;button&quot; class=&quot;btn btn-primary&quot;&gt;Primary&lt;/button&gt;<br>&lt;/body&gt;<br><br>&lt;/html&gt;</pre><p>Buka dua terminal.</p><p>Terminal 1 → Jalankan Vite</p><pre>$ npm run dev</pre><p>Terminal 2 → Jalankan server Laravel</p><pre>$ php artisan serve</pre><p>Sekarang buka browser dan akses:</p><p>👉 <a href="http://127.0.0.1:8000/">http://127.0.0.1:8000</a></p><p>Jika berhasil, kamu akan melihat halaman Welcome dengan tombol <strong>Bootstrap Primary</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b6c8169f8d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PMD Source Code Analyzer]]></title>
            <link>https://medium.com/@mfirmanakbar/pmd-source-code-analyzer-0973ebf70efc?source=rss-de57ddfbb121------2</link>
            <guid isPermaLink="false">https://medium.com/p/0973ebf70efc</guid>
            <category><![CDATA[code-analyzer]]></category>
            <category><![CDATA[pmd]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Firman]]></dc:creator>
            <pubDate>Wed, 29 Jan 2025 08:55:18 GMT</pubDate>
            <atom:updated>2025-01-29T08:55:18.061Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*AU-vHGxLPgE_0S7N.png" /><figcaption><a href="https://pmd.github.io/">https://pmd.github.io</a></figcaption></figure><h4>Apa Itu PMD?</h4><p><a href="https://pmd.github.io/">PMD</a> adalah alat static code analysis untuk menemukan masalah dalam kode sumber Java, Apex, JavaScript, dan beberapa bahasa lain.</p><h4>Fungsi Utama</h4><p>Berikut fungsi utama pada <a href="https://pmd.github.io/">PMD</a> :</p><ol><li>Mendeteksi bad practices dan kode redundan</li><li>Menemukan bug potensial (misalnya, NullPointerException)</li><li>Memeriksa style code agar lebih bersih dan maintainable</li><li>Bisa diintegrasikan dengan Maven, Gradle, atau CI/CD pipeline</li></ol><h4>Contoh Penggunaan PMD di Java</h4><p>Misalnya, kita punya kode Java berikut yang memiliki beberapa masalah:</p><pre>public class Example {<br>    public void badMethod() {<br>        String message = &quot;Hello&quot;; // Variabel tidak digunakan<br>        if (true) {<br>            System.out.println(&quot;This is always true&quot;);<br>        }<br>    }<br>}</pre><p>Masalah yang bisa dideteksi PMD:<br>❌ Variabel message tidak digunakan (UnusedLocalVariable)<br>❌ if (true) adalah redundant conditional statement</p><h4>Cara Menggunakan PMD (Java)</h4><p>Install PMD via Homebrew dengan command</p><pre>$ brew install pmd</pre><p>Jalankan PMD untuk Menganalisis Kode</p><pre>$ pmd check -d /path/to/project/src -R rulesets/java/quickstart.xml -f text<br><br><br># -d → Direktori kode yang akan dianalisis<br># -R → Ruleset yang digunakan (bisa custom)<br># -f text → Format output</pre><h4>Contoh Hasil Output PMD</h4><pre>Example.java:2: Avoid unused local variables such as &#39;message&#39;<br>Example.java:3: Avoid if statements that are always true or false</pre><p>Dari hasil ini, kita tahu harus menghapus variabel message dan memperbaiki redundant conditional.</p><h4>Integrasi dengan Maven</h4><p>Jika proyek menggunakan Maven, tambahkan dependency PMD berikut. Keuntungan dengan menggunakan maven bisa otomatis mengecek kode saat build.</p><pre>&lt;plugin&gt;<br>    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br>    &lt;artifactId&gt;maven-pmd-plugin&lt;/artifactId&gt;<br>    &lt;version&gt;3.15.0&lt;/version&gt;<br>    &lt;executions&gt;<br>        &lt;execution&gt;<br>            &lt;goals&gt;<br>                &lt;goal&gt;check&lt;/goal&gt;<br>            &lt;/goals&gt;<br>        &lt;/execution&gt;<br>    &lt;/executions&gt;<br>&lt;/plugin&gt;</pre><p>Lalu jalankan:</p><pre>mvn pmd:check</pre><h4>Kesimpulan</h4><p>✅ PMD membantu mendeteksi kode buruk sebelum masuk ke production.<br>✅ Cocok untuk proyek besar dengan banyak developer.<br>✅ Bisa diintegrasikan ke CI/CD agar kode lebih bersih &amp; maintainable.</p><p>Cocok buat kamu yang ingin menulis Java yang lebih baik tanpa harus cek manual! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0973ebf70efc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Circuit Breaker dengan Resilience4j]]></title>
            <link>https://medium.com/@mfirmanakbar/circuit-breaker-dengan-resilience4j-46ec56beb56d?source=rss-de57ddfbb121------2</link>
            <guid isPermaLink="false">https://medium.com/p/46ec56beb56d</guid>
            <category><![CDATA[circuit-breaker]]></category>
            <category><![CDATA[resilience4j]]></category>
            <category><![CDATA[circuit-breaker-pattern]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Firman]]></dc:creator>
            <pubDate>Sat, 21 Dec 2024 23:05:23 GMT</pubDate>
            <atom:updated>2024-12-21T23:05:23.750Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nkeEHi6i2silpsOcNmO81w.png" /></figure><h3>Penjelasan Circuit Breaker dengan Cerita Sederhana</h3><p>Bayangkan Anda memiliki <strong>kafe</strong> yang menawarkan layanan pesan antar kopi. Dalam cerita ini:</p><ul><li><strong>Pelanggan</strong>: Orang yang memesan kopi (aplikasi Anda).</li><li><strong>Barista</strong>: Orang yang membuat kopi (layanan eksternal, misalnya API pihak ketiga).</li><li><strong>Circuit Breaker</strong>: Seorang manajer di kafe yang memantau apakah barista terlalu sibuk atau sedang bermasalah.</li></ul><h4><strong>Skenario Tanpa Circuit Breaker</strong></h4><ol><li>Banyak pelanggan memesan kopi.</li><li>Barista mulai kewalahan karena mesin kopi rusak (layanan eksternal mengalami masalah).</li><li>Pelanggan terus memesan, tapi kopi tidak pernah selesai karena mesin rusak.</li><li>Akhirnya, <strong>pelanggan kecewa</strong>, kafe menjadi kacau karena antrean tidak berhenti.</li></ol><h4><strong>Skenario Dengan Circuit Breaker</strong></h4><ol><li>Manajer melihat barista mulai gagal membuat kopi (misalnya lebih dari 50% pesanan gagal).</li><li>Manajer memutuskan untuk sementara <strong>menghentikan penerimaan pesanan</strong> (Circuit Breaker masuk ke <strong>Open State</strong>).</li><li>Pelanggan diberi pesan ramah:<br><em>“Maaf, layanan kami sedang sibuk. Silakan coba lagi beberapa saat.”</em></li><li>Setelah beberapa saat, manajer mencoba kembali memesan satu atau dua kopi untuk mengecek apakah barista dan mesin sudah kembali normal (<strong>Half-Open State</strong>).</li><li>Jika barista bisa membuat kopi, layanan dibuka kembali (<strong>Closed State</strong>). Jika gagal, tetap ditutup</li></ol><h4><strong>Fungsi Circuit Breaker</strong></h4><ol><li><strong>Melindungi layanan utama</strong>: Aplikasi tidak terus-menerus menghabiskan sumber daya untuk memanggil layanan yang sedang bermasalah.</li><li><strong>Mengurangi waktu respon</strong>: Pelanggan langsung mendapat jawaban (fallback) tanpa menunggu lama.</li><li><strong>Memberi kesempatan layanan eksternal untuk pulih</strong>: Dengan menunda sementara permintaan baru.</li></ol><h3>Implementasi</h3><ol><li>Dependensi pada pom.xml</li></ol><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;io.github.resilience4j&lt;/groupId&gt;<br>    &lt;artifactId&gt;resilience4j-spring-boot3&lt;/artifactId&gt;<br>    &lt;version&gt;2.0.2&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p>2. Service dengan Circuit Breaker</p><pre>import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;<br>import org.springframework.stereotype.Service;<br>import org.springframework.web.client.RestTemplate;<br><br>@Service<br>public class PaymentService {<br><br>    private final RestTemplate restTemplate = new RestTemplate();<br><br>    @CircuitBreaker(name = &quot;paymentService&quot;, fallbackMethod = &quot;paymentFallback&quot;)<br>    public String processPayment() {<br>        // Simulasi panggilan ke layanan pembayaran<br>        String url = &quot;https://api.external-payment.com/pay&quot;;<br>        return restTemplate.getForObject(url, String.class);<br>    }<br><br>    // Fallback jika pembayaran gagal<br>    public String paymentFallback(Exception e) {<br>        return &quot;Layanan pembayaran sedang sibuk. Silakan coba lagi nanti.&quot;;<br>    }<br>}</pre><p>3. Controller yang memanggil service</p><pre>import org.springframework.web.bind.annotation.GetMapping;<br>import org.springframework.web.bind.annotation.RestController;<br><br>@RestController<br>public class PaymentController {<br><br>    private final PaymentService paymentService;<br><br>    public PaymentController(PaymentService paymentService) {<br>        this.paymentService = paymentService;<br>    }<br><br>    @GetMapping(&quot;/pay&quot;)<br>    public String makePayment() {<br>        return paymentService.processPayment();<br>    }<br>}</pre><p>4. Konfigurasi</p><pre># Memantau 5 panggilan terakhir<br>resilience4j.circuitbreaker.instances.paymentService.slidingWindowSize=5<br><br># Circuit terbuka jika lebih dari 50% gagal<br>resilience4j.circuitbreaker.instances.paymentService.failureRateThreshold=50<br><br># Tunggu 10 detik sebelum mencoba lagi<br>resilience4j.circuitbreaker.instances.paymentService.waitDurationInOpenState=10s</pre><h3><strong>Kesimpulan</strong></h3><ul><li>Circuit Breaker <strong>seperti manajer pintar</strong> yang mencegah sistem Anda terus-menerus mencoba memanggil layanan yang bermasalah.</li><li>Dengan fallback, pengguna tidak perlu menunggu lama untuk mengetahui bahwa layanan sedang bermasalah.</li><li>Setelah layanan pulih, Circuit Breaker secara otomatis membuka kembali jalur komunikasi.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46ec56beb56d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rate Limit dengan Bucket4j]]></title>
            <link>https://medium.com/@mfirmanakbar/rate-limit-dengan-bucket4j-a00be984e3dd?source=rss-de57ddfbb121------2</link>
            <guid isPermaLink="false">https://medium.com/p/a00be984e3dd</guid>
            <category><![CDATA[bucket4j]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[rate-limit]]></category>
            <dc:creator><![CDATA[Firman]]></dc:creator>
            <pubDate>Tue, 03 Dec 2024 08:28:40 GMT</pubDate>
            <atom:updated>2024-12-03T08:28:40.528Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Fh2eZjZ4scC7fCZb" /></figure><p>Rate Limit adalah proses untuk mengatur seberapa banyak request yang diterima pada aplikasi. Rate Limit memiliki manfaat, contohnya adalah melindungi web resource, memastikan penggunaan API yang wajar (fair-usage) dan mencegah web dari penyalahgunaan API.</p><p>Contoh penggunaan dari Rate Limit bisa kita implementasikan pada API Login. API Login yang menggunakan Rate Limit dapat menghindari user/oknum dalam melakukan serangan brute-force pada paramater username dan password.</p><h3>Bucket4J</h3><p>Bucket4J adalah sebuah library Java yang digunakan untuk implementasi rate limiting pada aplikasi. Library ini memungkinkan kita untuk mengatur batasan jumlah request yang dapat dilakukan oleh pengguna dalam waktu tertentu.</p><p>Kita akan menggunakan <strong>bucket4J</strong> sebagai pembatasan user untuk hit API Login. Contoh seorang user hanya bisa hit API login selama 3 menit sebanyak 3x, jika lebih dari itu kita akan berikan error “Too many requested” dan User harus menunggu selama 3 menit ke depan untuk mencoba login lagi dan pada case ini saya menggunakan redis untuk menyimpan session data Rate Limit per-usename tersebut.</p><h3>Configuration</h3><p>Berikut source code dan configutation untuk rate limit.</p><h4>Pom.xml</h4><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-cache&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-data-redis&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-data-redis&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br><br>&lt;dependency&gt;<br>  &lt;groupId&gt;com.github.vladimir-bukhtoyarov&lt;/groupId&gt;<br>  &lt;artifactId&gt;bucket4j-core&lt;/artifactId&gt;<br>  &lt;version&gt;8.0.1&lt;/version&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;com.github.vladimir-bukhtoyarov&lt;/groupId&gt;<br>  &lt;artifactId&gt;bucket4j-jcache&lt;/artifactId&gt;<br>  &lt;version&gt;8.0.1&lt;/version&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;com.bucket4j&lt;/groupId&gt;<br>  &lt;artifactId&gt;bucket4j_jdk17-core&lt;/artifactId&gt;<br>  &lt;version&gt;8.14.0&lt;/version&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;org.redisson&lt;/groupId&gt;<br>  &lt;artifactId&gt;redisson&lt;/artifactId&gt;<br>  &lt;version&gt;3.17.0&lt;/version&gt;<br>&lt;/dependency&gt;</pre><h4>CacheConfig</h4><pre><br>import org.springframework.cache.CacheManager;<br>import org.springframework.cache.annotation.CachingConfigurer;<br>import org.springframework.cache.annotation.EnableCaching;<br>import org.springframework.cache.support.CompositeCacheManager;<br>import org.springframework.context.annotation.Configuration;<br>import org.springframework.data.redis.cache.RedisCacheManager;<br><br>import lombok.AllArgsConstructor;<br><br>@Configuration<br>@EnableCaching<br>@AllArgsConstructor<br>public class CacheConfig implements CachingConfigurer {<br><br>    private RedisCacheManager redisCacheManager;<br><br>    @Override<br>    public CacheManager cacheManager() {<br>        final var cacheManager = new CompositeCacheManager(redisCacheManager);<br>        cacheManager.setFallbackToNoOpCache(true);<br>        return cacheManager;<br>    }<br>}</pre><h4>RedisBucket4jConfig</h4><pre>import javax.cache.CacheManager;<br>import javax.cache.Caching;<br>import javax.cache.spi.CachingProvider;<br><br>import org.redisson.config.Config;<br>import org.redisson.jcache.configuration.RedissonConfiguration;<br>import org.springframework.context.annotation.Bean;<br>import org.springframework.context.annotation.Configuration;<br>import org.springframework.data.redis.connection.RedisConnectionFactory;<br>import org.springframework.data.redis.core.RedisTemplate;<br><br>import io.github.bucket4j.distributed.proxy.ProxyManager;<br>import io.github.bucket4j.grid.jcache.JCacheProxyManager;<br><br>@Configuration<br>public class RedisBucket4jConfig {<br><br>    private String cacheName = &quot;bucket4j-rate-limits&quot;;<br><br>    @Bean<br>    public Config redissonConfig() {<br>        Config config = new Config();<br>        config.useSingleServer().setAddress(&quot;redis://localhost:6379&quot;);<br>        return config;<br>    }<br><br>    @Bean<br>    public CacheManager bucket4jCacheManager(Config redissonConfig) {<br>        CachingProvider cachingProvider = Caching.getCachingProvider();<br>        CacheManager cacheManager = cachingProvider.getCacheManager();<br>        cacheManager.createCache(cacheName, RedissonConfiguration.fromConfig(redissonConfig));<br>        return cacheManager;<br>    }<br><br>    @Bean<br>    public ProxyManager&lt;String&gt; proxyManager(CacheManager manager) {<br>        return new JCacheProxyManager&lt;&gt;(manager.getCache(cacheName));<br>    }<br><br>    @Bean<br>    public RedisTemplate&lt;String, String&gt; redisTemplate(RedisConnectionFactory redisConnectionFactory) {<br>        RedisTemplate&lt;String, String&gt; template = new RedisTemplate&lt;&gt;();<br>        template.setConnectionFactory(redisConnectionFactory);<br>        return template;<br>    }<br>}</pre><h4>Bucket4jConfig</h4><pre><br>import java.time.Duration;<br><br>import org.springframework.context.annotation.Bean;<br>import org.springframework.context.annotation.Configuration;<br><br>import io.github.bucket4j.Bandwidth;<br>import io.github.bucket4j.Bucket;<br>import io.github.bucket4j.BucketConfiguration;<br>import io.github.bucket4j.Refill;<br>import io.github.bucket4j.distributed.proxy.ProxyManager;<br><br>@Configuration<br>public class Bucket4jConfig {<br><br>    private final ProxyManager&lt;String&gt; proxyManager;<br><br>    public Bucket4jConfig(ProxyManager&lt;String&gt; proxyManager) {<br>        this.proxyManager = proxyManager;<br>    }<br><br>    // save to Redis<br>    public Bucket loginBucket(String username) {<br>        Refill refill = Refill.intervally(3, Duration.ofMinutes(1));<br>        Bandwidth bandwidth = Bandwidth.classic(3, refill);<br>        BucketConfiguration configuration = BucketConfiguration.builder()<br>                .addLimit(bandwidth)<br>                .build();<br>        return proxyManager.builder().build(username, () -&gt; configuration);<br>    }<br><br>    @Bean<br>    public Bucket loginBucket() {<br>        Refill refill = Refill.intervally(1, Duration.ofMinutes(1));<br>        Bandwidth bandwidth = Bandwidth.classic(3, refill);<br>        return Bucket.builder()<br>                .addLimit(bandwidth)<br>                .build();<br>    }<br><br>}</pre><h4>Application.Properties</h4><pre># spring redis config<br>spring.redis.host=localhost<br>spring.redis.port=6379<br>spring.redis.timeout=60000<br>spring.redis.type=redis<br>spring.cache.type=redis<br><br>logging.level.org.springframework.cache.*=trace</pre><h4>AuthController</h4><pre>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.http.HttpStatus;<br>import org.springframework.security.authentication.AuthenticationManager;<br>import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;<br>import org.springframework.security.core.Authentication;<br>import org.springframework.security.core.userdetails.UsernameNotFoundException;<br>import org.springframework.web.bind.annotation.PostMapping;<br>import org.springframework.web.bind.annotation.RequestBody;<br>import org.springframework.web.bind.annotation.RestController;<br><br>import com.fastcampus.blog.config.Bucket4jConfig;<br>import com.fastcampus.blog.exception.ApiException;<br>import com.fastcampus.blog.io.LoginRequest;<br>import com.fastcampus.blog.io.LoginResponse;<br>import com.fastcampus.blog.service.JwtService;<br>import com.fastcampus.blog.service.MyUserDetailsService;<br><br>import io.github.bucket4j.Bucket;<br>import jakarta.validation.Valid;<br><br>@RestController<br>public class AuthController {<br><br>    @Autowired<br>    JwtService jwtService;<br><br>    @Autowired<br>    AuthenticationManager authenticationManager;<br><br>    @Autowired<br>    MyUserDetailsService myUserDetailsService;<br><br>    @Autowired<br>    Bucket4jConfig bucket4jConfig;<br><br>    //private final Map&lt;String, Bucket&gt; bucketMap = new ConcurrentHashMap&lt;&gt;();<br><br>    @PostMapping(&quot;/api/public/login&quot;)<br>    public LoginResponse login(@Valid @RequestBody LoginRequest loginRequest) {<br>        /*Bucket loginBucket = bucketMap.computeIfAbsent(loginRequest.getUsername(),<br>                k -&gt; bucket4jConfig.loginBucket());*/<br><br>        Bucket loginBucket = bucket4jConfig.loginBucket(loginRequest.getUsername());<br><br>        if (!loginBucket.tryConsume(1)) {<br>            throw new ApiException(&quot;TOO MANY REQUESTS&quot;, HttpStatus.TOO_MANY_REQUESTS);<br>        }<br><br>        Authentication authentication = authenticationManager.authenticate(<br>                new UsernamePasswordAuthenticationToken(loginRequest.getUsername(), loginRequest.getPassword())<br>        );<br><br>        if (authentication.isAuthenticated()) {<br>            String token = jwtService.generateToken(myUserDetailsService<br>                    .loadUserByUsername(loginRequest.getUsername()));<br>            return LoginResponse.builder().token(token).build();<br>        }<br><br>        throw new UsernameNotFoundException(&quot;invalid user&quot;);<br>    }<br><br>}</pre><h3>Testing Result</h3><p>Di sini saya testing untuk hit API sebanyak lebih dari 3x maka akan meresponse dengan error too many request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oDCIN7UiX_iQttQdtrO-Cw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a00be984e3dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Redis Caching in Spring Boot]]></title>
            <link>https://medium.com/@mfirmanakbar/redis-caching-in-spring-boot-cac863462812?source=rss-de57ddfbb121------2</link>
            <guid isPermaLink="false">https://medium.com/p/cac863462812</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[cache]]></category>
            <category><![CDATA[spring-cache]]></category>
            <category><![CDATA[caching]]></category>
            <category><![CDATA[redis]]></category>
            <dc:creator><![CDATA[Firman]]></dc:creator>
            <pubDate>Sat, 30 Nov 2024 17:18:01 GMT</pubDate>
            <atom:updated>2024-11-30T17:18:01.939Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ht26nP2NAXh02MQGs0Z6tA.png" /></figure><h3>Caching Design Pattern</h3><p>Pada penerapan penggunaan Redis untuk caching, terdapat beberapa <strong>design pattern</strong> yang digunakan untuk mengelola data secara efisien. Berikut adalah pattern untuk Caching, kita dapat mengimplementasikan sesuai kondisi dan kasus yang dihadapi.</p><h4>Cache Aside Pattern</h4><ul><li>Data di-cache hanya saat dibutuhkan, dan aplikasi akan mengelola sinkronisasi antara cache dan database utama.</li><li>Jika data tidak ada di cache, aplikasi mengambil data dari database utama dan menyimpannya ke dalam cache.</li><li>Data di-cache dapat dihapus atau diperbarui sesuai kebutuhan.</li></ul><h4>Write-Through Pattern</h4><ul><li>Setiap kali data baru ditulis ke database, data tersebut juga langsung ditulis ke cache.</li><li>Cache selalu memiliki data terbaru.</li></ul><h4>Read-Through Pattern</h4><ul><li>Aplikasi membaca data langsung dari cache.</li><li>Jika data tidak ditemukan, data diambil dari database dan disimpan kembali di cache oleh cache layer.</li></ul><h4>Write-Behind Pattern</h4><ul><li>Data ditulis ke cache terlebih dahulu, dan pembaruan ke database dilakukan secara asynchronous di latar belakang.</li><li>Membantu meningkatkan performa saat ada banyak operasi tulis.</li></ul><h4>CQRS (Command Query Responsibility Segregation)</h4><ul><li>Memisahkan alur write (command) dan read (query) pada data.</li><li>Redis digunakan sebagai lapisan baca (query) untuk mempercepat akses data, sementara database utama menangani operasi tulis (command).</li></ul><h4>Data Sharding Pattern</h4><ul><li>Data dibagi ke dalam beberapa kelompok kecil berdasarkan kunci tertentu untuk memudahkan akses dan manajemen.</li><li>Umumnya digunakan pada Redis untuk menyimpan data yang sangat besar, seperti pembagian Sorted Set berdasarkan tanggal atau ID pengguna.</li></ul><h3>Basic Commands</h3><pre>$ redis-server # start the redis server<br><br>$ docker exec -it blog-redis-1 sh # start the redis via docker<br><br>$ redis-cli # start redis cli<br>$ quit # exit from redis cli<br><br>$ set [key] [value] # save data<br>$ keys * # get all data<br>$ get [key] # get data by key<br>$ FLUSHALL # clears all keys in all databases of Redis<br>$ FLUSHDB # clears all keys in the current database</pre><h3>Spring Cache Annotation</h3><p>Ada beberapa anotasi pada Spring Cache yang dapat kita gunakan untuk mengelola data di cache secara efisien yaitu :</p><ul><li><strong>@Cacheable</strong> → digunakan untuk menyimpan data hasil dari suatu method ke dalam cache. Jika cache sudah memiliki data yang sama, maka aplikasi akan mengambil data dari cache.</li><li><strong>@CacheEvict</strong> → digunakan untuk menghapus data dari cache. Biasanya digunakan ketika data dalam cache perlu diperbarui atau dihapus karena adanya perubahan pada sumber datanya.</li><li><strong>@CachePut</strong> → digunakan untuk memperbarui data di cache secara langsung setelah method dieksekusi. Anotasi ini akan selalu mengeksekusi method dan hasilnya akan di-update di cache.</li></ul><h3>Spring Boot Redis Configuration</h3><p>Pada project ini saya menggunakan versi <strong>spring boot 3.3.5</strong> dengan Java 21.</p><ol><li>Setup redis on <strong>pom.xml</strong></li></ol><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>    &lt;artifactId&gt;spring-boot-starter-cache&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>    &lt;artifactId&gt;spring-boot-starter-data-redis&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;<br>    &lt;artifactId&gt;spring-data-redis&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><p>2. Buat class <strong>CacheConfig.java</strong></p><pre>import org.springframework.cache.CacheManager;<br>import org.springframework.cache.annotation.CachingConfigurer;<br>import org.springframework.cache.annotation.EnableCaching;<br>import org.springframework.cache.support.CompositeCacheManager;<br>import org.springframework.context.annotation.Configuration;<br>import org.springframework.data.redis.cache.RedisCacheManager;<br><br>import lombok.AllArgsConstructor;<br><br>@Configuration<br>@EnableCaching<br>@AllArgsConstructor<br>public class CacheConfig implements CachingConfigurer {<br><br>    private RedisCacheManager redisCacheManager;<br><br>    @Override<br>    public CacheManager cacheManager() {<br>        final var cacheManager = new CompositeCacheManager(redisCacheManager);<br>        cacheManager.setFallbackToNoOpCache(true);<br>        return cacheManager;<br>    }<br>}</pre><p>3. Buat class <strong>RedisConfig.java</strong></p><pre>import java.time.Duration;<br><br>import org.springframework.context.annotation.Bean;<br>import org.springframework.context.annotation.Configuration;<br>import org.springframework.data.redis.cache.RedisCacheConfiguration;<br>import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;<br>import org.springframework.data.redis.serializer.RedisSerializationContext;<br>import org.springframework.data.redis.serializer.StringRedisSerializer;<br><br>@Configuration<br>public class RedisConfig {<br><br>    @Bean<br>    public RedisCacheConfiguration redisCacheConfiguration() {<br>        return RedisCacheConfiguration.defaultCacheConfig()<br>                .disableCachingNullValues()<br>                .entryTtl(Duration.ofMinutes(30L)) // NOTE: for me maybe 14 days<br>                .serializeKeysWith(RedisSerializationContext.SerializationPair<br>                        .fromSerializer(new StringRedisSerializer()))<br>                .serializeValuesWith(RedisSerializationContext.SerializationPair<br>                        .fromSerializer(new GenericJackson2JsonRedisSerializer()));<br>    }<br>}</pre><p>4. Update <strong>application.properties</strong></p><pre>spring.redis.host=localhost<br>spring.redis.port=6379<br>spring.redis.timeout=60000<br>spring.redis.type=redis<br><br>logging.level.org.springframework.cache.*=trace</pre><p>5. Class Service yang akan mengimplemtasikan fungsi redis, pada pembahasan ini beberapa aturan :</p><ul><li>Ketika fungsi <strong>Get All Post</strong> dijalankan maka kita akan melakukan cache dengan<strong> @Cacheable </strong>maka data akan di simpan di cache, jika tidak ada maka data akan dipanggil ke Databas utama lalu di simpan pada Cache</li><li>Ketika fungsi <strong>Create Post </strong>atau <strong>Delete Post </strong>dijalankan maka kita akan melakukan <strong>@CacheEvict</strong> pada Key yang sama / digunakan pada <strong>Get All Post</strong> agar kita dapat menghapus data cache.</li><li>Ketika fungsi <strong>Update Post </strong>dijalankan maka kita gunakan <strong>@CachePut </strong>agar dapat memperbarui data cache.</li></ul><pre>@Cacheable(value = &quot;PostService.getPosts&quot;, key = &quot;{#isDeleted, #isPublished}&quot;)<br>public List&lt;Post&gt; getPosts(boolean isDeleted, boolean isPublished) {<br>    return postRepository.findByIsDeletedAndIsPublishedOrderByPublishedAtDesc(isDeleted, isPublished);<br>}<br><br>@CacheEvict(value = &quot;PostService.getPosts&quot;, key = &quot;{#isDeleted, #isPublichsed}&quot;)<br>public CreatePostResponse createPost(CreatePostRequest createPostRequest) {<br>    Post post = PostMapper.INSTANCE.mapToPost(createPostRequest);<br>    post.setCommentCount(0L);<br>    post.setCreatedAt(Instant.now().getEpochSecond());<br>    post = postRepository.save(post);<br>    return PostMapper.INSTANCE.mapToPostResponse(post);<br>}<br><br>@CachePut(value = &quot;PostService.getPosts&quot;, key = &quot;#slug&quot;)<br>public Post updatePostBySlug(String slug, Post postRequest) {<br>    Post existingPost = postRepository.findFirstBySlugAndIsDeleted(slug, false).orElse(null);<br>    if (existingPost == null) {<br>        return null;<br>    }<br>    existingPost.setTitle(postRequest.getTitle());<br>    existingPost.setSlug(postRequest.getSlug());<br>    return postRepository.save(existingPost);<br>}<br><br>@Cacheable(value = &quot;PostService.getPostBySlug&quot;, key = &quot;{#slug, #isDeleted}&quot;)<br>public GetPostResponse getPostBySlug(String slug, boolean isDeleted) {<br>    Post post = postRepository<br>            .findFirstBySlugAndIsDeleted(slug, isDeleted)<br>            .orElseThrow(() -&gt; new ApiException(&quot;not found&quot;, HttpStatus.NOT_FOUND));<br>    return PostMapper.INSTANCE.mapToGetPostResponse(post);<br>}<br><br>//@CacheEvict(value = &quot;PostService.getPosts&quot;, key = &quot;{#isDeleted, #isPublichsed}&quot;)<br>//@CacheEvict(value = &quot;PostService.getPostBySlug&quot;, key = &quot;{#result.slug, false}&quot;)<br>// NOTE: result.slug --&gt; result itu value-return dari method deletePostBySlug()<br>@Caching(evict = {<br>        @CacheEvict(value = &quot;PostService.getPosts&quot;, key = &quot;{#isDeleted, #isPublished}&quot;),<br>        @CacheEvict(value = &quot;PostService.getPostBySlug&quot;, key = &quot;{#result.slug, false}&quot;)<br>})<br>public DeletePostByIdResponse deletePostBySlug(Integer id) {<br>    Post post = postRepository.findById(id).orElseThrow(<br>            () -&gt; new ApiException(&quot;data not found&quot;, HttpStatus.NOT_FOUND)<br>    );<br><br>    post.setDeleted(true);<br>    postRepository.save(post);<br><br>    return DeletePostByIdResponse.builder()<br>            .id(id)<br>            .slug(post.getSlug())<br>            .build();<br>}</pre><p>Buka pada terminal lain lalu jalankan Redis CLI:</p><pre>$ redis-cli<br>$ keys *<br>$ get &quot;PostService.getPosts::false,false&quot;<br>$ get &quot;PostService.getPostBySlug::slug2,false&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vB1QKB6Zi2ziTntsRlTVow.png" /></figure><p><strong>Project Repo:</strong><br><a href="https://github.com/mfirmanakbar/fc-blog">https://github.com/mfirmanakbar/fc-blog</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cac863462812" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Run Code Coverage in Intellij IDEA]]></title>
            <link>https://medium.com/@mfirmanakbar/how-to-run-code-coverage-in-intellij-idea-8a1ebbede537?source=rss-de57ddfbb121------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a1ebbede537</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[intellij-idea]]></category>
            <dc:creator><![CDATA[Firman]]></dc:creator>
            <pubDate>Sun, 24 Nov 2024 14:23:47 GMT</pubDate>
            <atom:updated>2024-11-24T14:25:22.115Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to run Code Coverage in Intellij IDEA</h3><p>Pastikan sudah terinstall plugin berikut → Code Coverage for Java.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t0dZVEVBs7h0ttArsYY3lw.png" /></figure><p>Klik Kanan pada folder src/test/java lalu pilih <strong>More run/debug → Run Tests in ‘java’ with Coverage</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SSplQqcqPI-ix54oaREruQ.png" /></figure><p>Hasil dari Code Coverage. Kita bisa buatkan unit testing pada masing-masing Class / Method / Line / Branch yang belum tercover.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ufdLDT2MYq_zpU3QNQukhw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a1ebbede537" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Penanganan Global Exception Java Spring Boot]]></title>
            <link>https://medium.com/@mfirmanakbar/penanganan-global-exception-java-spring-boot-d2de9aadd1f6?source=rss-de57ddfbb121------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2de9aadd1f6</guid>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java-exception-handling]]></category>
            <category><![CDATA[exception-handling]]></category>
            <dc:creator><![CDATA[Firman]]></dc:creator>
            <pubDate>Sun, 20 Oct 2024 06:30:39 GMT</pubDate>
            <atom:updated>2024-10-20T06:30:39.780Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jNz-o2P7WCmNQ9awE4k_Og.png" /></figure><h3>Apa Itu Exception</h3><p>Exception adalah kondisi yang tidak diharapkan yang dapat mengganggu alur fungsi yang normal pada sebuah program. Beberapa alasan umum yang menyebabkan terjadinya exception antara lain:</p><ul><li>Input yang tidak valid (contoh: membagi bilangan dengan nol)</li><li>Kesalahan saat berkomunikasi dengan database</li><li>Masalah koneksi jaringan</li></ul><p>Java mengelompokkan exception menjadi beberapa tipe utama:</p><ol><li><strong>Checked Exception:</strong> Exception yang harus ditangani atau dinyatakan dalam kode dengan kata kunci throws. Contoh: IOException, SQLException.</li><li><strong>Unchecked Exception (Runtime Exception):</strong> Exception yang terjadi saat runtime dan tidak perlu ditangani secara eksplisit. Contoh: NullPointerException, ArithmeticException.</li><li><strong>Error:</strong> Masalah serius yang biasanya tidak bisa diatasi oleh aplikasi. Contoh: OutOfMemoryError.</li></ol><h3>Masalah yang Sering Terjadi</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NZ5nHz2I_8Hm1im222tURA.png" /></figure><p>Mungkin bagi teman-teman yang sudah sering mengembangkan aplikasi menggunakan Java Spring Boot, tampilan error seperti di gambar di atas sudah tidak asing lagi.</p><p>Namun, tampilan ini cenderung kurang informatif dan tidak ideal, baik bagi pengguna maupun sesama programmer.</p><p>Pesan error yang lebih jelas dan disertai detail kontekstual tentunya akan jauh lebih membantu dalam mengidentifikasi dan mengatasi masalah.</p><h3>Solusi dengan Global Exception Handler</h3><p>Kita hanya perlu membuat sebuah class GlobalExceptionHandler dan mendefinisikan fungsi-fungsi untuk menangani exception secara global menggunakan anotasi @RestControllerAdvice atau @ControllerAdvice.</p><p>Dengan demikian, jika terjadi error yang tidak terduga dalam aplikasi, sistem akan secara otomatis mengarahkan ke GlobalExceptionHandler, yang akan memberikan respons sesuai dengan format yang sudah kita tentukan sebelumnya.</p><p>Pertama, kita buat class ErrorObject untuk menyimpan informasi terkait error yang terjadi dalam aplikasi. Class ini berfungsi sebagai wadah untuk menampung detail seperti status kode, pesan error, dan waktu terjadinya error.</p><pre><br>import java.util.Date;<br><br>import lombok.Data;<br><br>@Data<br>public class ErrorObject {<br>    private Integer statusCode;<br>    private String message;<br>    private Date timestamp;<br>}</pre><p>Selanjutnya, kita akan membuat class GlobalExceptionHandler, yang berfungsi untuk menangani error dan mengarahkan respons ke fungsi yang telah kita buat sebelumnya. Class ini akan menangkap berbagai jenis exception yang terjadi dalam aplikasi dan memberikan respons yang terstruktur kepada pengguna.</p><p>Dengan implementasi ini, jika terjadi kesalahan saat pengguna mengakses endpoint, aplikasi akan memberikan respons yang jelas dan informatif sesuai dengan format ErrorObject, sehingga memudahkan programmer dan pengguna dalam memahami masalah yang terjadi.</p><pre><br>import java.util.Date;<br><br>import org.springframework.http.HttpStatus;<br>import org.springframework.http.ResponseEntity;<br>import org.springframework.web.bind.annotation.ExceptionHandler;<br>import org.springframework.web.bind.annotation.RestControllerAdvice;<br>import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;<br>import org.springframework.web.reactive.result.method.annotation.ResponseEntityExceptionHandler;<br><br>import com.pslu.exceptionproject.model.ErrorObject;<br><br>@RestControllerAdvice<br>public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {<br><br>    @ExceptionHandler(MethodArgumentTypeMismatchException.class)<br>    public ResponseEntity&lt;ErrorObject&gt; handleMethodArgumentTypeMismatchException(<br>            MethodArgumentTypeMismatchException ex) {<br>        ErrorObject errorObject = new ErrorObject();<br>        errorObject.setStatusCode(HttpStatus.BAD_REQUEST.value());<br>        errorObject.setMessage(ex.getMessage());<br>        errorObject.setTimestamp(new Date());<br>        return new ResponseEntity&lt;&gt;(errorObject, HttpStatus.BAD_REQUEST);<br>    }<br><br>    @ExceptionHandler(Exception.class)<br>    public ResponseEntity&lt;ErrorObject&gt; handleGeneralException(Exception ex) {<br>        ErrorObject errorObject = new ErrorObject();<br>        errorObject.setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR.value());<br>        errorObject.setMessage(ex.getMessage());<br>        errorObject.setTimestamp(new Date());<br>        return new ResponseEntity&lt;&gt;(errorObject, HttpStatus.INTERNAL_SERVER_ERROR);<br>    }<br>}</pre><h3>Expected Global Exception Handler</h3><p>Berikut hasil yang diharapkan dengan pesan error yang lebih informatif dengan format yang jelas. Dengan tampilan seperti ini, baik pengguna maupun programmer dapat lebih mudah memahami dan mengatasi masalah yang terjadi. Pesan error yang detail membantu dalam mengidentifikasi penyebab kesalahan dan mempercepat proses perbaikan, sehingga pengalaman pengguna menjadi lebih baik dan pengembangan aplikasi lebih efisien.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QJwASuotU-XhbTwm2nNQqw.png" /></figure><h3>Custom Global Exception Handler</h3><p>Kita juga dapat membuat custom global exception handler, yang memungkinkan penggunaan class dan fungsi ini di berbagai bagian aplikasi. Dengan pendekatan ini, kita bisa mendefinisikan penanganan exception yang spesifik sesuai kebutuhan, memberikan fleksibilitas lebih dalam pengelolaan error. Selain itu, custom global exception handler juga memudahkan dalam menjaga konsistensi format respons error di seluruh aplikasi. Contoh kita akan buat ItemAlreadyExistsException dan ResourceNotFoundException .</p><h4>ItemAlreadyExistsException</h4><p>ItemAlreadyExistsException bisa kita gunakan jika ada inputan data yang sudah exist atau untuk mencegah data terduplikasi.</p><pre><br>import java.io.Serial;<br><br>import org.springframework.http.HttpStatus;<br>import org.springframework.web.bind.annotation.ResponseStatus;<br><br>@ResponseStatus(value = HttpStatus.CONFLICT)<br>public class ItemAlreadyExistsException extends RuntimeException {<br><br>    @Serial<br>    private static final long serialVersionUID = 1L;<br><br>    public ItemAlreadyExistsException(String message) {<br>        super(message);<br>    }<br>}</pre><h4>ResourceNotFoundException</h4><p>ResourceNotFoundException kita gunakan jika ada inputan data yang tidak valid dan tidak ada pada database.</p><pre><br>import java.io.Serial;<br><br>public class ResourceNotFoundException extends RuntimeException {<br><br>    @Serial<br>    private static final long serialVersionUID = 1L;<br><br>    public ResourceNotFoundException(String message) {<br>        super(message);<br>    }<br>}</pre><h4>Update Global Exception Handler</h4><p>Lalu kita buat fungsi handleExpenseNotFoundException dan handleItemAlreadyExistsException pada class GlobalExceptionHandler.</p><p>Selanjutnya, kita akan membuat dua fungsi baru, yaitu handleExpenseNotFoundException dan handleItemAlreadyExistsException, di dalam class GlobalExceptionHandler.</p><p>Berikut adalah contoh implementasi fungsi-fungsi tersebut:</p><pre><br>import java.util.Date;<br><br>import org.springframework.http.HttpStatus;<br>import org.springframework.http.ResponseEntity;<br>import org.springframework.web.bind.annotation.ExceptionHandler;<br>import org.springframework.web.bind.annotation.RestControllerAdvice;<br>import org.springframework.web.context.request.WebRequest;<br>import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;<br>import org.springframework.web.reactive.result.method.annotation.ResponseEntityExceptionHandler;<br><br>import com.pslu.exceptionproject.model.ErrorObject;<br><br>@RestControllerAdvice<br>public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {<br><br>    ...<br><br>    ...<br><br>    ...<br><br>    @ExceptionHandler<br>    public ResponseEntity&lt;ErrorObject&gt; handleExpenseNotFoundException(ResourceNotFoundException ex,<br>            WebRequest request) {<br>        ErrorObject errorObject = new ErrorObject();<br>        errorObject.setStatusCode(HttpStatus.NOT_FOUND.value());<br>        errorObject.setMessage(ex.getMessage());<br>        errorObject.setTimestamp(new Date());<br>        return new ResponseEntity&lt;ErrorObject&gt;(errorObject, HttpStatus.NOT_FOUND);<br>    }<br><br>    @ExceptionHandler(ItemAlreadyExistsException.class)<br>    public ResponseEntity&lt;ErrorObject&gt; handleItemAlreadyExistsException(Exception ex, WebRequest request) {<br>        ErrorObject errorObject = new ErrorObject();<br>        errorObject.setStatusCode(HttpStatus.CONFLICT.value());<br>        errorObject.setMessage(ex.getMessage());<br>        errorObject.setTimestamp(new Date());<br>        return new ResponseEntity&lt;ErrorObject&gt;(errorObject, HttpStatus.CONFLICT);<br>    }<br>}</pre><h4>Cara Menggunakan Custom Global Exception</h4><p>Penggunaan ItemAlreadyExistsException dapat diterapkan dalam fungsi pencarian email yang telah terdaftar. Misalnya, saat pengguna mencoba mendaftar dengan email yang sudah ada dalam sistem, kita dapat melempar exception ini untuk menandakan bahwa email tersebut tidak dapat digunakan.</p><pre>@Override<br>public User createUser(UserModel userModel) {<br>    if (userRepository.existsByEmail(userModel.getEmail())) {<br>        throw new ItemAlreadyExistsException(&quot;User is already registered with email &quot; + userModel.getEmail());<br>    }<br>    User newUser = new User();<br>    BeanUtils.copyProperties(userModel, newUser);<br>    newUser.setPassword(passwordEncoder.encode(newUser.getPassword()));<br>    return userRepository.save(newUser);<br>}</pre><p>Penggunaan ResourceNotFoundException sangat relevan ketika melakukan pencarian data yang tidak ada dalam database. Misalnya, saat pengguna mencoba mengakses informasi tentang entitas tertentu, seperti pengguna atau produk, dan data tersebut tidak ditemukan, kita bisa melempar exception ini.</p><pre>private Expense getExpenseEntity(String expenseId) {<br>    Optional&lt;Expense&gt; expense = expenseRepository<br>            .findByUserIdAndExpenseId(userService.getLoggedInUser().getId(), expenseId);<br>    if (expense.isPresent()) {<br>        return expense.get();<br>    }<br>    throw new ResourceNotFoundException(&quot;Expense is not found for the id &quot; + expenseId);<br>}</pre><h3>Kesimpulan</h3><p>Melalui pendekatan ini, kita tidak hanya meningkatkan pengalaman pengguna dengan memberikan feedback yang jelas, tetapi juga membantu pengembang dalam mendeteksi dan menangani masalah yang terkait dengan data yang hilang. Ini memastikan bahwa aplikasi kita lebih informatif dan responsif terhadap berbagai situasi yang mungkin terjadi.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2de9aadd1f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>