<?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 Niko Aldi Ariboy on Medium]]></title>
        <description><![CDATA[Stories by Niko Aldi Ariboy on Medium]]></description>
        <link>https://medium.com/@nikoaldiariboy?source=rss-4796d3d6d334------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*FPSJW_bEolO5sp_g</url>
            <title>Stories by Niko Aldi Ariboy on Medium</title>
            <link>https://medium.com/@nikoaldiariboy?source=rss-4796d3d6d334------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 14:07:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nikoaldiariboy/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[Implementing Polymorphic Associations in a Vehicle Rental System Using Express.js]]></title>
            <link>https://medium.com/@nikoaldiariboy/implementing-polymorphic-associations-in-a-vehicle-rental-system-using-express-js-787653df95ee?source=rss-4796d3d6d334------2</link>
            <guid isPermaLink="false">https://medium.com/p/787653df95ee</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[polymorphic-association]]></category>
            <dc:creator><![CDATA[Niko Aldi Ariboy]]></dc:creator>
            <pubDate>Fri, 07 Feb 2025 05:08:49 GMT</pubDate>
            <atom:updated>2025-02-07T06:50:04.838Z</atom:updated>
            <content:encoded><![CDATA[<p>Polymorphic associations are a powerful feature in object-relational mapping (ORM) that allows a single model to be associated with multiple other models in a flexible way. In the context of a vehicle rental system, polymorphic associations can be used to model relationships where multiple entities (like different types of vehicles) can be associated with shared attributes or behaviors.</p><p>In this article, I won’t be discussing polymorphic associations in detail, as I covered them extensively in a previous article. You can read that article here:</p><p><a href="https://medium.com/@nikoaldiariboy/polymorphic-associations-database-schema-e-g-commenting-system-and-vehicle-rental-system-case-9e2dc9d1d60a">Polymorphic associations database schema (e.g Commenting System and Vehicle Rental System Case)</a></p><h3>Example for Rental Vehicle Case (Bike, Motorcycle, Car)</h3><p>Let’s say we have a <strong>Rental System</strong> where users can rent <strong>Vehicles</strong>, and those vehicles can be of different types (bikes, motorcycles, or cars).</p><p>In a <strong>rental system</strong>, a user can rent a vehicle, and the system needs to store rental records. The vehicles (Bike, Motorcycle, and Car) can be managed in separate tables, but we want to link these to a <strong>Rental</strong> record.</p><p>Here’s an Entity-Relationship Diagram (ERD) outline for a <strong>rental database</strong> that includes <strong>bikes, motorcycles, and cars</strong>. The diagram will have the following entities:</p><p><strong>ERD :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*8KzT8rVBvIvrFFk4OASqDQ.png" /></figure><p>In the traditional way, we would have separate foreign keys for each vehicle type in the booking model (for example, car_id, motorbike_id, bike_id). However, a polymorphic association allows us to avoid this and instead use a more flexible and scalable approach.</p><h4>Setting Up Polymorphic Associations</h4><p>To implement polymorphic associations in an Express.js application, you typically need a few models and relationships:</p><ol><li><strong>Car Model </strong>:</li></ol><pre>module.exports = (sequelize, Sequelize) =&gt; {<br>    const Car = sequelize.define(&quot;car&quot;, {<br>        id: {<br>            type: Sequelize.INTEGER,<br>            primaryKey: true,<br>            autoIncrement: true,<br>        },<br>        model: {<br>            type: Sequelize.STRING,<br>        },<br>        color: {<br>            type: Sequelize.STRING,<br>        },<br>        year: {<br>            type: Sequelize.INTEGER,<br>        },<br>        engine_capacity: {<br>            type: Sequelize.STRING,<br>        },<br>        passenger_capacity: {<br>            type: Sequelize.STRING,<br>        },<br>        license_plate: {<br>            type: Sequelize.STRING,<br>        },<br>        rental_price: {<br>            type: Sequelize.STRING,<br>        },<br>        availability_status : {<br>            type: Sequelize.STRING,<br>        },<br>    }, {<br>        tableName: &quot;cars&quot;,<br>    });<br>    return Car;<br>};</pre><p><strong>2. Motorcycle Model :</strong></p><pre>module.exports = (sequelize, Sequelize) =&gt; {<br>    const Motorcycle = sequelize.define(&quot;motorcycle&quot;, {<br>        id: {<br>            type: Sequelize.INTEGER,<br>            primaryKey: true,<br>            autoIncrement: true,<br>        },<br>        model: {<br>            type: Sequelize.STRING,<br>        },<br>        color: {<br>            type: Sequelize.STRING,<br>        },<br>        year: {<br>            type: Sequelize.INTEGER,<br>        },<br>        engine_capacity: {<br>            type: Sequelize.STRING,<br>        },<br>        license_plate: {<br>            type: Sequelize.STRING,<br>        },<br>        rental_price: {<br>            type: Sequelize.STRING,<br>        },<br>        availability_status : {<br>            type: Sequelize.STRING,<br>        },<br>    }, {<br>        tableName: &quot;motorcycles&quot;,<br>    });<br>    return Motorcycle;<br>};</pre><p><strong>3. Bike Model :</strong></p><pre>module.exports = (sequelize, Sequelize) =&gt; {<br>    const Bike = sequelize.define(&quot;bike&quot;, {<br>        id: {<br>            type: Sequelize.INTEGER,<br>            primaryKey: true,<br>            autoIncrement: true,<br>        },<br>        model: {<br>            type: Sequelize.STRING,<br>        },<br>        color: {<br>            type: Sequelize.STRING,<br>        },<br>        rental_price: {<br>            type: Sequelize.STRING,<br>        },<br>        availability_status : {<br>            type: Sequelize.STRING,<br>        },<br>    }, {<br>        tableName: &quot;bikes&quot;,<br>    });<br>    return Bike;<br>};</pre><p><strong>4. Customer Model :</strong></p><pre>module.exports = (sequelize, Sequelize) =&gt; {<br>    const Customer= sequelize.define(&quot;customer&quot;, {<br>        id: {<br>            type: Sequelize.INTEGER,<br>            primaryKey: true,<br>            autoIncrement: true,<br>        },<br>        name: {<br>            type: Sequelize.STRING,<br>        },<br>        phone: {<br>            type: Sequelize.STRING,<br>        },<br>        address: {<br>            type: Sequelize.STRING,<br>        },<br>    }, {<br>        tableName: &quot;customers&quot;,<br>    });<br>    return Customer;<br>};</pre><p><strong>5. Rental Model :</strong></p><pre>module.exports = (sequelize, Sequelize) =&gt; {<br>    const Rental = sequelize.define(<br>        &quot;rental&quot;,<br>        {<br>            id: {<br>                type: Sequelize.INTEGER,<br>                primaryKey: true,<br>                autoIncrement: true,<br>            },<br>            rental_date : {<br>                type: Sequelize.DATE,<br>            },<br>            return_date: {<br>                type: Sequelize.DATE,<br>            },<br>            vehicle_id: {<br>                type: Sequelize.INTEGER,<br>            },<br>            vehicle_type: {<br>                type: Sequelize.STRING,<br>            },<br>            customer_id: {<br>                type: Sequelize.INTEGER,<br>                references: {<br>                    model: &quot;customers&quot;, <br>                    key: &quot;id&quot;,<br>                },<br>            },<br>            total_cost: {<br>                type: Sequelize.DECIMAL,<br>            },<br>            status: {<br>                type: Sequelize.STRING,<br>            },<br>        },<br>        {<br>            tableName: &quot;rentals&quot;,<br>        }<br>    );<br><br>    Rental.associate = (models) =&gt; {<br>        Rental.belongsTo(models.bike, {<br>            foreignKey: &quot;vehicle_id&quot;,<br>            constraints: false,<br>            as: &quot;bike&quot;,<br>        });<br>        Rental.belongsTo(models.motorcycle, {<br>            foreignKey: &quot;vehicle_id&quot;,<br>            constraints: false,<br>            as: &quot;motorcycle&quot;,<br>        });<br>        Rental.belongsTo(models.car, {<br>            foreignKey: &quot;vehicle_id&quot;,<br>            constraints: false,<br>            as: &quot;car&quot;,<br>        });<br>    };<br><br>    return Rental;<br>};</pre><p><strong>Breakdown of the Rental Model :</strong></p><ul><li><strong>Customer Details (Foreign Key)</strong></li></ul><pre>customer_id: {<br>    type: Sequelize.INTEGER,<br>    references: {<br>        model: &quot;customers&quot;, <br>        key: &quot;id&quot;,<br>    },<br>},</pre><p>The <strong>customer_id</strong> is a <strong>foreign key</strong> that references the <strong>&quot;customers&quot;</strong> table.</p><ul><li><strong>Defining Associations (Relationships)</strong></li></ul><pre>Rental.belongsTo(models.bike, {<br>    foreignKey: &quot;vehicle_id&quot;,<br>    constraints: false,<br>    as: &quot;bike&quot;,<br>});<br>Rental.belongsTo(models.motorcycle, {<br>    foreignKey: &quot;vehicle_id&quot;,<br>    constraints: false,<br>    as: &quot;motorcycle&quot;,<br>});<br>Rental.belongsTo(models.car, {<br>    foreignKey: &quot;vehicle_id&quot;,<br>    constraints: false,<br>    as: &quot;car&quot;,<br>});</pre><p>The rental can be associated with <strong>three possible vehicle models</strong></p><ul><li>Bike (models.bike)</li><li>Motorcycle (models.motorcycle)</li><li>Car (models.car)</li></ul><p>The<strong>foreignKey: &quot;vehicle_id&quot;</strong> means all vehicles share the same <strong>vehicle_id</strong> field.</p><p>The<strong>constraints: false</strong> prevents Sequelize from enforcing foreign key constraints strictly (useful for multiple potential associations).</p><p>Then<strong>as: &quot;bike&quot;, </strong><strong>as: &quot;motorcycle&quot;, </strong><strong>as: &quot;car&quot;</strong> allows <strong>differentiation</strong> when querying the relationships.</p><p>The entire implementation source code can be accessed on GitHub:</p><p><a href="https://github.com/nikoaldi/VEHICLE-RENTAL-SYSTEM">GitHub - nikoaldi/VEHICLE-RENTAL-SYSTEM: This is the backend of a vehicle rental system built with Express.js, using polymorphic associations. Polymorphic associations allow models to relate to multiple other models in a single association. In this system, different entities, like vehicles or customers, can be linked to rental transactions efficiently</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=787653df95ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Polymorphic associations database schema (e.g Commenting System and Vehicle Rental System Case)]]></title>
            <link>https://medium.com/@nikoaldiariboy/polymorphic-associations-database-schema-e-g-commenting-system-and-vehicle-rental-system-case-9e2dc9d1d60a?source=rss-4796d3d6d334------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e2dc9d1d60a</guid>
            <category><![CDATA[commenting-system]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[databse]]></category>
            <category><![CDATA[rental-system]]></category>
            <category><![CDATA[polymorphic-association]]></category>
            <dc:creator><![CDATA[Niko Aldi Ariboy]]></dc:creator>
            <pubDate>Thu, 06 Feb 2025 03:22:29 GMT</pubDate>
            <atom:updated>2025-02-07T06:51:20.954Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*YxmInzyQ1Q79TE_cTVVnhw.png" /></figure><p>A <strong>polymorphic association</strong> in a database refers to a situation where a model (or table) can be associated with multiple other models (or tables) in different ways. Essentially, it allows a single relationship to refer to more than one type of object. In a typical relational database, foreign keys typically reference a single table, but in a polymorphic association, a single foreign key can refer to multiple different types of tables.</p><h3>When to Use Polymorphic Association</h3><p>You might use this approach in cases where:</p><ol><li><strong>Multiple Models Require the Same Relationship</strong>: If several models need to have similar relationships with a common entity, instead of creating separate foreign keys for each model, a polymorphic association can be used.</li><li><strong>Reduce Redundant Data</strong>: If you want to avoid redundancy in your schema, for instance, not having to duplicate a similar foreign key across different tables.</li><li><strong>Flexible Schema Design</strong>: When you want a more flexible database design that can accommodate new types of related models without altering the schema structure.</li></ol><h3>Example for Commenting System and Vehicle Rental System Case</h3><ol><li><strong>Commenting System</strong></li></ol><p>In a scenario where a website has multiple entities (e.g., posts, photos, videos), each of which can have comments, you might use a polymorphic association to allow comments to belong to any of these entities.</p><p><strong>Schema</strong>: The Commenting System table might look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*_C_QGkK868xCk_kp_Pkyiw.png" /></figure><p><strong>Tables</strong>:</p><ul><li>comments: This will store the comments with the following fields: id, commentable_id, commentable_type, and content.</li><li>posts, photos, videos: These would be different types of entities to which the comments can be associated.</li></ul><p><strong>How it works :</strong></p><ul><li>A <strong>comment</strong> can belong to a <strong>post</strong>, <strong>video</strong>, or <strong>photo</strong>.</li><li>The commentable_id stores the <strong>ID</strong> of the associated entity.</li><li>The commentable_type stores the <strong>type</strong> of entity (e.g., &quot;Post&quot;, &quot;Video&quot;, &quot;Photo&quot;).</li></ul><p><strong>2. Vehicle Rental System</strong></p><p>Let’s say we have a <strong>Rental System</strong> where users can rent <strong>Vehicles</strong>, and those vehicles can be of different types (bikes, motorcycles, or cars).</p><p>In a <strong>rental system</strong>, a user can rent a vehicle, and the system needs to store rental records. The vehicles (Bike, Motorcycle, and Car) can be managed in separate tables, but we want to link these to a <strong>Rental</strong> record.</p><p>Here’s an Entity-Relationship Diagram (ERD) outline for a <strong>rental database</strong> that includes <strong>bikes, motorcycles, and cars</strong>. The diagram will have the following entities:</p><p><strong>ERD :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*8KzT8rVBvIvrFFk4OASqDQ.png" /></figure><p><strong>Tables</strong>:</p><ul><li>rentals : This will store the rental with the following fields: id, rental_date, return_date, vehicle_id, vehicle_type, customer_id, total_cost, status.</li><li>bikes, motorcycles, cars: These would be different types of entities to which the rental can be associated.</li></ul><p><strong>How it works :</strong></p><ul><li>A <strong>rental </strong>can belong to a <strong>bike</strong>, <strong>motorcycle</strong>, or <strong>car</strong>.</li><li>The vehicle_id stores the <strong>ID</strong> of the associated entity.</li><li>The vehicle_type stores the <strong>type</strong> of entity (e.g., &quot;cars&quot;, &quot;bike&quot;, &quot;motorcycle&quot;).</li></ul><p><strong>The key components of a polymorphic association are:</strong></p><ul><li>A <strong>single association field</strong> (often a pair of fields like reference_id and reference_type).</li><li>A <strong>type field</strong> (indicating the model or entity the reference_id is pointing to).</li><li>A <strong>foreign key</strong> (pointing to the primary key of the different tables).</li></ul><p>This allows one table to hold references to multiple tables while maintaining database normalization.</p><h3>Pros and Cons</h3><p><strong>Pros</strong>:</p><ul><li>Reduces duplication by allowing a single association to multiple models.</li><li>Makes it easy to add new types of entities that can be associated with the same child entity without altering the schema too much.</li></ul><p><strong>Cons</strong>:</p><ul><li>Queries can be more complex since you need to check the type field and potentially perform different joins based on that.</li><li>It may lead to data integrity challenges, as the system relies on the type field to manage relationships correctly.</li></ul><h3>Other Use Cases for Polymorphic Associations</h3><ol><li><strong>Reactions System</strong> (Users can react to posts, comments, or messages)</li><li><strong>Notifications</strong> (A notification can be linked to different actions like orders, messages, or friend requests)</li><li><strong>Attachments</strong> (Files can be attached to emails, tasks, or support tickets)</li><li><strong>Ratings &amp; Reviews</strong> (Users can review books, courses, or restaurants)</li></ol><h3>Summary</h3><p>Polymorphic associations allow you to handle relationships between a child entity and multiple parent entities without needing separate columns or tables for each parent type. It’s ideal for situations where many different models can be related to a single model in a flexible way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e2dc9d1d60a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Menjalankan Kafka pada sistem operasi Windows]]></title>
            <link>https://medium.com/@nikoaldiariboy/menjalankan-kafka-pada-sistem-operasi-windows-e416e75abe34?source=rss-4796d3d6d334------2</link>
            <guid isPermaLink="false">https://medium.com/p/e416e75abe34</guid>
            <category><![CDATA[kafka-consumer]]></category>
            <category><![CDATA[kafka-windows]]></category>
            <category><![CDATA[message-broker]]></category>
            <category><![CDATA[kafka-producer]]></category>
            <category><![CDATA[kafka]]></category>
            <dc:creator><![CDATA[Niko Aldi Ariboy]]></dc:creator>
            <pubDate>Mon, 15 Jan 2024 03:37:19 GMT</pubDate>
            <atom:updated>2024-01-15T03:37:19.512Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6qiGP9jU_h--cSBpkntFeg.png" /></figure><p>Kafka merupakan sebuah platform distribusi streaming open-source yang digunakan untuk membangun sistem streaming data waktu nyata. Dikembangkan oleh Apache Software Foundation, Kafka dirancang untuk menangani aliran data besar dan membuatnya dapat diakses secara cepat oleh aplikasi dan sistem terkait.</p><p><strong>Beberapa karakteristik utama dari Kafka yaitu :</strong></p><ol><li>Pub-Sub Model: Kafka menggunakan model (publish-subscribe) di mana produsen data (publisher) mengirimkan pesan ke topik (topic), dan konsumen data (subscriber) dapat berlangganan topik tersebut untuk menerima pesan-pesan tersebut.</li><li>Skalabilitas: Kafka dapat dengan mudah dikonfigurasi dan diukur untuk menangani jumlah data yang besar dan mendukung skenario di mana data streaming dapat berkembang secara signifikan seiring waktu.</li><li>Daya Tahan Terhadap Kesalahan: Kafka memiliki daya tahan terhadap kesalahan yang baik. Pesan yang dikirimkan ke Kafka disimpan dalam log terdistribusi yang dapat direplikasi di beberapa node broker, sehingga memberikan kehandalan dan ketahanan terhadap kegagalan node tunggal.</li><li>Retensi Data: Kafka memungkinkan retensi data yang dapat dikonfigurasi. Ini berarti bahwa data dapat disimpan dalam Kafka untuk periode waktu tertentu sebelum dihapus atau diarsipkan.</li><li>Real-time Data Processing: Kafka memungkinkan sistem untuk memproses data secara waktu nyata, membuatnya ideal untuk aplikasi yang memerlukan pemrosesan data yang cepat dan efisien.</li></ol><h4>Menjalankan Kafka di Windows</h4><p>Pada artikel ini, implementasi Kafka akan menggunakan sistem operasi windows. Jika sebelumnya belum mendownload Kafka, maka dapat dilakukan pada link berikut :</p><p><a href="https://kafka.apache.org/downloads">Apache Kafka</a></p><p>Versi Kafka yang akan digunakan pada artikel ini yaitu versi 3.4.0 Scala 2.13. Jika sudah di download maka Extract file ke folder yang diinginkan. Pada contoh kali ini saya akan menyimpan Kafka di folder</p><p><strong>D:\Tools\kafka\kafka_2.13–3.4.0</strong></p><p>Terdapat beberapa file pada folder Kafka yang sudah di extract, jika ingin pengubah properties Kafka contohnya mengganti client port atau penyimpanan snapshot maka dapat dilakukan pada folder <strong>config/<em>zookeeper.properties</em></strong> file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j7GIsJxqw-rCRfxLxx2OBA.png" /></figure><p>Berikut Tahapan untuk menjalankan Kafka di Windows:</p><ol><li><strong>Menjalankan Zookeeper</strong></li></ol><p>Kafka bergantung pada Zookeeper untuk koordinasi dan penyimpanan konfigurasi. Zookeeper sudah termasuk dalam folder kafka yang sudah di download. Untuk menjalankan Zookeeper buka terminal baru dan arahkan ke folder Kafka yang sudah di extract (menyesuaikan):</p><pre>cd D:\Tools\kafka\kafka_2.13-3.4.0</pre><p>Lalu jalankan perntah berikut :</p><pre>.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties</pre><p>Jika berhasil maka akan muncul tampilan sebagai berikut pada terminal :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tm88ipIpvWQw0nwCxmtqYg.png" /></figure><p><strong>2. Menjalankan Kafka Server</strong></p><p>Untuk menjalankan Kafka Server buka terminal baru dan arahkan ke folder Kafka yang sudah di extract, Lalu jalankan perntah berikut :</p><pre>.\bin\windows\kafka-server-start.bat .\config\server.properties</pre><p>Jika berhasil maka akan muncul tampilan sebagai berikut pada terminal :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HFIbyC1i1lsiHp1YSa2wHg.png" /></figure><p><strong>3. Cek Kafka apakah sudah berjalan</strong></p><p>Untuk mengecek apakah Kafka sudah berjalan bisa dilakukan dengan menjalankan Producer(publish) dan Consumer(subscribe) yang sudah disediakan pada file Kafka yang sudah di extract sebelumnya.</p><ul><li><strong>Membuat Kafka Topik</strong></li></ul><p>Sebelum menjalankan Producer dan Consumer maka perlu membuat Kafka topik terlebih dahulu. Dalam Kafka, data diorganisir menjadi topik-topik yang bersifat pub/sub (publish/subscribe). Publisher mengirimkan pesan ke topik tertentu, dan pelanggan yang berlangganan (subscribe) ke topik tersebut akan menerima pesan-pesan tersebut. Ini memungkinkan sistem untuk menyusun dan menyampaikan aliran data secara efisien kepada pihak yang berkepentingan.</p><p>Untuk membuat topik dilakukan dengan cara membuka terminal baru dan arahkan ke folder Kafka yang sudah di extract, Lalu jalankan perntah berikut :</p><pre>.\bin\windows\kafka-topics.bat --create --topic nama-topik --bootstrap-server localhost:9092</pre><p>Sesuaikan “<strong>nama-topik”</strong> sesuai kebutuhan, disini nama yang dicontohkan adalah “<strong>kafka-windows</strong>”. Jika berhasil maka akan muncul tampilan sebagai berikut “<strong>Created topic kafka-windows</strong>” pada terminal :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nRkAWd6VSYOrJq8FFeqBXQ.png" /></figure><ul><li><strong>Menjalankan Kafka Producer</strong></li></ul><p>Untuk menjalankan Kafka Producer dilakukan dengan cara membuka terminal baru dan arahkan ke folder Kafka yang sudah di extract Lalu jalankan perntah berikut :</p><pre>.\bin\windows\kafka-console-producer.bat --topic nama-topik --bootstrap-server localhost:9092</pre><p>Ubah “<strong>nama-topik”</strong> dengan topik yang sudah dibuat sebelumnya, contoh pada artikel ini Kafka topik yaitu “<strong>kafka-windows</strong>”</p><p>Jika berhasil maka akan muncul tampilan sebagai berikut pada terminal :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hd_LILtgvTczcpYIVLX0eg.png" /></figure><ul><li><strong>Menjalankan Kafka Consumer</strong></li></ul><p>Untuk menjalankan Kafka Consumer dilakukan dengan cara membuka terminal baru dan arahkan ke folder Kafka yang sudah di extract Lalu jalankan perntah berikut :</p><pre>.\bin\windows\kafka-console-consumer.bat --topic nama-topik --bootstrap-server localhost:29092</pre><p>Ubah “<strong>nama-topik”</strong> dengan topik yang sudah dibuat sebelumnya, contoh pada artikel ini Kafka topik yaitu “<strong>kafka-windows</strong>”</p><p>Jika berhasil maka akan muncul tampilan sebagai berikut pada terminal :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SPJgK-oG9vbvihwxCgeCNA.png" /></figure><ul><li><strong>Tes Mengirim data dari Kafka Producer ke Kafka Consumer</strong></li></ul><p>Untuk mengirim data dari Kafka producer dilakukan dengen mengetikan data yang akan dikirim ke Kafka consumer pada terminal Kafka Producer, contohnya disini akan mengirim data text “<strong>Test Kafka di Windows</strong>”, seperti gambar berikut :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*shDNJi5iQDyTQuuupOxszw.png" /></figure><p>Jika berhasil terkirim maka data akan langsung tampil dalam terminal Kafka consumer seperti gambar berikut :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*55Ktx8LZA6DuWQUvhpZcWw.png" /></figure><p>Dilihat dari gambar diatas, bahwa pengiriman data dari Kafka Producer sudah berhasil dan diterima oleh Kafka Consumer.</p><p>Thank you for taking the time to read this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e416e75abe34" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>