<?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 Adil Houmadi on Medium]]></title>
        <description><![CDATA[Stories by Adil Houmadi on Medium]]></description>
        <link>https://medium.com/@adilhoumadi?source=rss-6f63802b73b5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qqMOYYt12mZtVOp7.jpg</url>
            <title>Stories by Adil Houmadi on Medium</title>
            <link>https://medium.com/@adilhoumadi?source=rss-6f63802b73b5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 05:24:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adilhoumadi/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[Extending ksqlDB built-in capability]]></title>
            <link>https://medium.com/adidoescode/extending-ksqldb-built-in-capability-54b9a84c06b?source=rss-6f63802b73b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/54b9a84c06b</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[ksqldb]]></category>
            <dc:creator><![CDATA[Adil Houmadi]]></dc:creator>
            <pubDate>Fri, 30 Jul 2021 08:32:04 GMT</pubDate>
            <atom:updated>2021-08-02T07:53:19.849Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>As we may know, Apache Kafka handles your data in real-time, but when it comes to stream processing usually developers use a set of components that require Java programming skills, such as <strong>Kafka streams</strong>, <strong>Apache Flink, Apache Spark</strong>.<br>Hence, what about non-tech users? Is there any alternative to process the data without these set of skills?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EfTMeFW1YKj1wQ2MFa-MdA.jpeg" /><figcaption>How to stream your flow (Photo by <a href="https://unsplash.com/@robertlukeman">@robertlukeman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>)</figcaption></figure><p>Fortunately, there is a great alternative developed by Confluent, through only using an SQL-like language which is called: <a href="https://docs.ksqldb.io/en/latest/">ksqlDB</a>. This event streaming database allows non tech-users to play with data in real time. It provides a powerful interface via SQL-like queries without the need for programming language. This technology is also suitable for developers who are interested in building modern IoT system or big data platforms.</p><p>As mentioned previously working with high level abstraction is effortless compared to a programming language, the API and CLI of ksqlDB makes the interaction with the data much more easier.</p><p>Furthermore, managing a Kafka connector can be executed using similar technology that simplifies the architecture, and speed up the integrations.</p><p>ksqlDB allows stream processing operations, such as filtering, transforming, enhancing, and aggregating the data.</p><p>Hence, in case the built-in functions are not sufficient, the technology could extended easily to achieve the same capability like in Kafka streams.</p><p>Good news is that ksqlDB supports this feature via <strong>user defined function</strong> (<a href="https://docs.ksqldb.io/en/latest/how-to-guides/create-a-user-defined-function/">UDF</a>). In one of our projects, we had a requirement to split data from a main topic to a regional one that will contain only data from that region, at the same time, some fields of the new events needed to be hashed using a specific encryption algorithm.</p><h3>Implementation</h3><p>Often, you are looking to have a custom behaviour or to have some computation in your ksqlDB queries, regardless of the complexity of the usage case, ksqlDB provides a Java API to achieve this goal, it gives the possibility to extend the core of the engine by creating your own user-defined function.</p><p>If you check the documentation of the technology, filtering or masking data is already supported by default, but when it comes to hashing a field using a specific algorithm, a custom development is needed.</p><p>In our case, we created a hashing function to encrypt the data according to a set of algorithms. The first implementation was able to accept a string as input, hash the entry according to the specified algorithm, and send it back as hash.</p><p>The Java implementation looks like the following:</p><p>Couple of annotations are needed to make the function compatible with ksqlDB engine:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7883d829169b2613d42dd4622dbc394a/href">https://medium.com/media/7883d829169b2613d42dd4622dbc394a/href</a></iframe><p>An example of Utils Class can be found here: <a href="https://gist.github.com/AdilHoumadi/b0adec2e9b1cdbce5b8cc920ba71c7dd">Utils.java</a></p><p>Once we finished the development of our extension, we need to package it into a fat <strong>JAR</strong> file, using our favourite package manager in our case, we did use maven to generate this <strong>JAR</strong>.</p><p>We need to deploy the generated JAR to ksqlDB server, in our case, we do have a dockerized environment that will facilitate the task for us, by mounting the JAR to <strong>KSQL_KSQL_EXTENSION_DIR</strong>, it will be scanned via the internal ksqlDB framework and will be recognised.</p><p>Once the extension is deployed and recognised in the ksqlDB Server, finally we will be able to browse its documentation and start using it in our queries.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e45ba6f2ef722b93e6e5b202b9cc624/href">https://medium.com/media/4e45ba6f2ef722b93e6e5b202b9cc624/href</a></iframe><p>Let’s try out our transient query by selecting and hashing the <strong>regionid</strong> using SHA-256 algorithm, the results will be returned to the client and will not be written to any Kafka topic.</p><p>Here comes the results, to persist this output we will use persistent query in the next section, it will write back the results to a Kafka topic, this proves very useful, thus, we would want to share this data with another client.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/68c5ca60f68b3b39872c7dbe62530c51/href">https://medium.com/media/68c5ca60f68b3b39872c7dbe62530c51/href</a></iframe><h3>Demonstration</h3><p>In this section we will demonstrate a working example using ksqlDB, we will cover the following case study:</p><p><em>We will be interested to filter data that match the gender </em><strong><em>FEMALE</em></strong><em> and hash the </em><strong><em>regionid</em></strong><em> of each record.</em></p><p>This section contains the following details:</p><ul><li>Setup the environment</li><li>Generate random data</li><li>Create a stream and apply the hash function</li><li>Browse the output topic</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*Qac8q1uwvaAp1osPaVDqbg.png" /><figcaption>Stream processing workflow</figcaption></figure><h3>Setup the environment</h3><p>Using docker and docker-compose, we can spawn our environment.</p><p>You can spawn your own environment using this <a href="https://gist.github.com/AdilHoumadi/85b88e9990e2fa09a01bfc749d1a6931">docker-compose.yml</a> file</p><p>The environment contains the following components:</p><ul><li>Zookeeper, Kafka broker, Schema registry: To handle the topic and the schema of the data</li><li>Kowl UI: To browse the data</li><li>ksqlDB server, ksqldDB client, ksqlDB-datagen: To stream the data and generate random data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*azpaZBObW86qOhZJQKXMDg.png" /><figcaption>Docker Environment</figcaption></figure><h3>Generate random data</h3><p>We will use ksqlDB-datagen to generate random data in Avro Format and push it forward to the topic.</p><p>The random data that will be generated, will have the following structure:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7bb739185228eb0522a43125c384439e/href">https://medium.com/media/7bb739185228eb0522a43125c384439e/href</a></iframe><p>We are generating 1000 msgs/second in 1000 iterations.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e102e2dc13d1487ed8d315ba07e3b53a/href">https://medium.com/media/e102e2dc13d1487ed8d315ba07e3b53a/href</a></iframe><p>An example of the data that has been pushed to the topic: ‘users’</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c13ed64ec28f988d114f671e16360807/href">https://medium.com/media/c13ed64ec28f988d114f671e16360807/href</a></iframe><h3>Create a stream and apply the hash function</h3><p>We will create a stream on top of our topic. First, we can check the content of our topic in ksqlDB by executing this command, it will give us the format for key, the value, and print the rows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/355f0cfc321a157a1287e4371d40bd91/href">https://medium.com/media/355f0cfc321a157a1287e4371d40bd91/href</a></iframe><p>In order to create the stream and start interacting with the topic, we use the following command:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a400dd3c593d68542aaadf734a48a3c1/href">https://medium.com/media/a400dd3c593d68542aaadf734a48a3c1/href</a></iframe><p>We can check the stream creation by listing all the streams.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d28e3ed6a1325d61c81c0a9c1505936/href">https://medium.com/media/3d28e3ed6a1325d61c81c0a9c1505936/href</a></iframe><p>This transient query selects the <strong>userid</strong>, <strong>gender</strong> and hash the <strong>regionid:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a454f47dde8b04d85d59c0d37354c288/href">https://medium.com/media/a454f47dde8b04d85d59c0d37354c288/href</a></iframe><p>Create the stream with a persistent query, the result of the query will be written back to the <strong>users_female</strong> topic:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d586995b919a933a46d85095e9eac432/href">https://medium.com/media/d586995b919a933a46d85095e9eac432/href</a></iframe><h3>Browse the output topic</h3><p>The data is flowing in the final topic (users_female) in AVRO format. As we keep pushing random data to input topic ‘<strong>users</strong>’ the ksqlDB query is processing each record and pushing back to ‘<strong>users_female</strong>’ topic</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zPorTl6sj2svQLMdVZmXIQ.png" /><figcaption>Browse the data via Kowl UI</figcaption></figure><p>Out of the box, ksqlDB provides a set of functions that will allow filtering, grouping, and transforming the data easily and achievably.</p><p>It’s a good alternative to Kafka streams, no need to write code in a programming language to meet your requirement. Thus, when it comes achieving it: the API is very simple to use, and it will also eventually cover corner use cases, similar to case we have demonstrated in this article.</p><h3>References</h3><p><a href="https://docs.ksqldb.io/en/latest/">https://docs.ksqldb.io/en/latest/</a></p><p><a href="https://docs.ksqldb.io/en/latest/how-to-guides/create-a-user-defined-function/">https://docs.ksqldb.io/en/latest/how-to-guides/create-a-user-defined-function/</a></p><p><a href="https://tomershaiman.medium.com/tutorial-building-a-s3-parquet-datalake-without-a-single-line-of-code-5ea4455edc1e">https://tomershaiman.medium.com/tutorial-building-a-s3-parquet-datalake-without-a-single-line-of-code-5ea4455edc1e</a></p><p><a href="https://github.com/cloudhut/kowl">https://github.com/cloudhut/kowl</a></p><p><a href="https://github.com/confluentinc/cp-all-in-one/tree/6.2.x/cp-all-in-one">https://github.com/confluentinc/cp-all-in-one/tree/6.2.x/cp-all-in-one</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54b9a84c06b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adidoescode/extending-ksqldb-built-in-capability-54b9a84c06b">Extending ksqlDB built-in capability</a> was originally published in <a href="https://medium.com/adidoescode">adidoescode</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Consume and produce data to Apache Kafka using CLI]]></title>
            <link>https://adilhoumadi.medium.com/consume-and-produce-data-to-apache-kafka-using-cli-40126a0b49bd?source=rss-6f63802b73b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/40126a0b49bd</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[kafka-producer]]></category>
            <category><![CDATA[kafka-consumer]]></category>
            <category><![CDATA[kafka-cli]]></category>
            <dc:creator><![CDATA[Adil Houmadi]]></dc:creator>
            <pubDate>Mon, 22 Mar 2021 12:57:31 GMT</pubDate>
            <atom:updated>2021-03-22T14:23:14.701Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In this series of articles we will see the different methods that we can use in order to produce data to a topic, and the way to consume it. We will start by setting up a local environment using docker and docker-compose. Once the kafka ecosystem is ready we will create a topic, than produce some data and consume it via CLI.</p><h3>Local environment</h3><p>Using the following docker-compose we will be able to start a local environment that contain: a broker and zookeeper.</p><p>docker-compose.yml</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5db7765cef785db1ed4aca6fb7728bce/href">https://medium.com/media/5db7765cef785db1ed4aca6fb7728bce/href</a></iframe><p>Start the local environment by executing this command:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2587e81cc0ea74e8c838c32addbaa5f5/href">https://medium.com/media/2587e81cc0ea74e8c838c32addbaa5f5/href</a></iframe><p>Check if the environment is ready:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd890baa3e826955d7999dc6a7529a60/href">https://medium.com/media/dd890baa3e826955d7999dc6a7529a60/href</a></iframe><h3>Setup kafka CLI</h3><p>In order to interact with the kafka broker, Apache Kafka provides a client CLI:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/440a981cf2fb36c283b3b859c12f7e29/href">https://medium.com/media/440a981cf2fb36c283b3b859c12f7e29/href</a></iframe><blockquote><em>Add this export to your shell profile, it will allow to execute the bin from any location in the system.</em></blockquote><h3>Create the topic</h3><p>In order to create the topic, we will need to use kafka-topics.sh command and set the required parameters:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d5d1e3d78e24f669fdfb9ee019af22b/href">https://medium.com/media/7d5d1e3d78e24f669fdfb9ee019af22b/href</a></iframe><ul><li>localhost:9092 - the broker address</li><li>newTopic - the topic name</li><li>3 - The number of partitions for topic</li><li>1 - The number of replication for the topic, in our environment we have only on broker.S</li></ul><p>To check the creation of the topic we will use the previous command with</p><p>--list option.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7a1eaab42f4a61dbd39ac309331a71b/href">https://medium.com/media/c7a1eaab42f4a61dbd39ac309331a71b/href</a></iframe><p>To Have more details about the topic that has been created, there is an option that we can set to kafka-topics.sh which is called --describe.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/89e13b2c056e6555a1c3b7338a89ff2f/href">https://medium.com/media/89e13b2c056e6555a1c3b7338a89ff2f/href</a></iframe><p>The output of the command give us: the number of partitions and the replicas. In our case we are using only on instance for the broker which is obviously refer to the number of replicas.</p><blockquote><em>In a future article we can discuss a setup that contain a cluster with multiple brokers.</em></blockquote><h3>Produce the data</h3><p>Now that we have our topic created in the broker and we could describe its configuration, we can start producing messages.</p><p>In order to send messages to our topic we will use kafka-console-producer.sh. An interactive prompt will be shown and we can start writing our messages.</p><p>To confirm the sending of the message we need to hit ENTER and continue.</p><p>Once we finish our sending we can quit the process using CTRL+C</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b989b2fa4526207d258431bb7ae7e122/href">https://medium.com/media/b989b2fa4526207d258431bb7ae7e122/href</a></iframe><blockquote><em>DETAIL: We can start producing the data without creation of the topic. A question that we can ask ourself is the following: Why we took the time to create the topic before sending the messages? Usually in production environment the </em><em>auto-creation for topics is disabled by default, Organizations prefer to have control and approve the creation of topics, if we want to have this behavior in our setup we can set this environment variable in our docker-compose.yml</em></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/049b128fe66bf74594e150c562e5736f/href">https://medium.com/media/049b128fe66bf74594e150c562e5736f/href</a></iframe><p>To make the production of the data more interesting we can use Meetup Streaming API. The following endpoint will stream open events from Meetup-API:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b73774f7539f4831ad3b2319c7e3eb5/href">https://medium.com/media/4b73774f7539f4831ad3b2319c7e3eb5/href</a></iframe><p>We need to execute this command to have a continuous flow from Meetup-API</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1f9ea5144d43000c73a19de114539fe/href">https://medium.com/media/a1f9ea5144d43000c73a19de114539fe/href</a></iframe><p>We execute a GET request via curl on Meetup-API and we pipe the result to jq to map the output and get the following fields:</p><ul><li>id</li><li>event_url</li><li>name</li></ul><p>For each message produced to the topic a &gt; sign will be printed to the terminal. We keep running this command in a tab to feed our topic. We will end up having json objects in our topic that look like the following structure:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42f1a7024e03004e7d6c5a3143bdcb27/href">https://medium.com/media/42f1a7024e03004e7d6c5a3143bdcb27/href</a></iframe><h3>Consume the data</h3><p>In the section we will spawn a new terminal to consume the data that has been produced previously. To do so, we will need kafka-console-consumer.sh binary and set the required parameters to start the consumption.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c88b1b75260f457ba6de2e52f4d49afe/href">https://medium.com/media/c88b1b75260f457ba6de2e52f4d49afe/href</a></iframe><p>We can play with this command and consume from a specific offset for a specific partition with a fixed number of messages before exiting.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9b5aa50f21eaf88e3fc92583ba715acf/href">https://medium.com/media/9b5aa50f21eaf88e3fc92583ba715acf/href</a></iframe><ul><li>--offset: rewind the process to the specified offset.</li><li>--partition: consume from this specific partition.</li><li>--max-messages: total messages to consume before exiting the process.</li></ul><blockquote><em>--offset accepts an integer and </em><em>earliest to start from the beginning or </em><em>latest which the default value that mean consume from end.</em></blockquote><p>To get the status of each partition we can execute this command:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9aa4226833ef1262672dfe1ba59e0a8/href">https://medium.com/media/f9aa4226833ef1262672dfe1ba59e0a8/href</a></iframe><p>We see clearly that our topic has 3 partitions: 0, 1 and 2 and for each partition we have the last offset that has been reached.</p><ul><li>partition 0 offset 34</li><li>partition 1 offset 41</li><li>partition 2 offset 36</li></ul><h3>Conclusion</h3><p>As you have seen put in place a Kafka local environment is accessible to every developer that is interested to get in Streaming world. In a few minutes, we manage to setup the cluster and start producing and consuming the data.</p><p>For testing purpose working with the CLI is fine and allows to prototype quickly. But for production application the Favorite way of producing/consuming the data is via a programming language of or using kafka connector. In the next article we will discuss how we can implement it via the Java SDK.</p><p>Stay tuned ✌!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40126a0b49bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hello world!]]></title>
            <link>https://adilhoumadi.medium.com/hello-world-17b03b73fea7?source=rss-6f63802b73b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/17b03b73fea7</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[hello-world]]></category>
            <dc:creator><![CDATA[Adil Houmadi]]></dc:creator>
            <pubDate>Sat, 20 Mar 2021 00:00:00 GMT</pubDate>
            <atom:updated>2021-03-22T12:34:59.976Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hello world</h3><p>Hello, I am Adil, currently I am working as Kafka Platform Engineer.</p><p>I do have 7 years experience specialising in Backend/Infrastructure and Web Development. I love to work in Linux environment and code scripts in (Golang/Python) in order to avoid repetitive tasks.</p><p>I am Interested in devising a better problem-solving method for challenging tasks, and learning new technologies and tools.</p><p>In this blog I am willing to write technical articles related to Programming, Devops, Kafka Streaming, Kubernetes …</p><p>Thank you 👋!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17b03b73fea7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>