<?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 Ramzi Maâlej on Medium]]></title>
        <description><![CDATA[Stories by Ramzi Maâlej on Medium]]></description>
        <link>https://medium.com/@ramzi.maalej?source=rss-a3fcd29cd33d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1zleTMP5WavIEO3IT3e5dw.jpeg</url>
            <title>Stories by Ramzi Maâlej on Medium</title>
            <link>https://medium.com/@ramzi.maalej?source=rss-a3fcd29cd33d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 23:56:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ramzi.maalej/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[Micronaut: Using Google Cloud Sql]]></title>
            <link>https://medium.com/@ramzi.maalej/micronaut-using-google-cloud-sql-9b2fc466c01a?source=rss-a3fcd29cd33d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b2fc466c01a</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[micronaut-framework]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[micronaut]]></category>
            <dc:creator><![CDATA[Ramzi Maâlej]]></dc:creator>
            <pubDate>Fri, 01 Feb 2019 21:05:03 GMT</pubDate>
            <atom:updated>2019-02-01T21:26:43.609Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to configure Micronaut to use Google Cloud MySql as datastore</h3><p>In this blog post, I will show you how to configure your <a href="http://micronaut.io/">Micronaut</a> app to use <a href="https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory">Google Cloud Sql for MySQL</a> as a datastore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NvFGVfFqLsCEhFe8iMDgNA.png" /><figcaption>Micronaut Framework</figcaption></figure><h3>Context</h3><p>I have been a huge fan of <a href="https://spring.io/projects/spring-framework">Spring</a> and <a href="http://spring.io/projects/spring-boot">Spring boot</a> for a long time until I discovered Micronaut. Micronaut is one of the first Java frameworks that address the challenges of building and deploying microservices to the cloud. Not only does it support many cloud providers natively, but it also enjoys a blazing fast startup time.</p><p>At the opposite of Spring who relies on reflection to wire Java beans and construct your application at runtime, Micronaut leverages compile-time AOP processing that enables it to run faster and with lower memory footprint. Additionally, Micronaut supports Reactive and Non-blocking paradigms.</p><p>At <a href="https://www.veamly.com/">Veamly</a>, we heavily rely on spring-boot as the foundation for all our microservices. However, we were impressed by the capabilities of Micronaut, and we started experimenting with it since its first release. In this example, I will also cover how to configure <a href="https://www.liquibase.org/">Liquibase</a> and <a href="https://brettwooldridge.github.io/HikariCP/">Hikari</a> along side with Google Cloud SQL for MySQL.</p><h3>Hikari</h3><p>Hikari is production-ready connection pool that outperforms other popular connection pools like: Dbcp2, Tomcat, and Vibur. To add Hikari to your Micronaut application, you need to declare the following dependency:</p><pre>compile &quot;io.micronaut.configuration:micronaut-jdbc-hikari&quot;</pre><p>To use hibernate, you need add this (You can also use hibernate-gorm if you prefer):</p><pre>compile &quot;io.micronaut.configuration:micronaut-hibernate-jpa&quot;</pre><h3>Liquibase</h3><p>Liquibase is a database agnostic Java library that add versioning to your database. It allows to track changes to your database schema over time, making it easier to propagate database changes across environments or rollback them. While this is an optional step, I encourage you to start experimenting with Liquibase if you have not already done so.</p><pre>compile &quot;io.micronaut.configuration:micronaut-liquibase:1.0.0.RC1&quot;</pre><h3>Cloud SQL for MySQL</h3><p>Connecting to managed MySQL database on Google Cloud requires loading an additional library that alleviate the burden of dealing with IP whitelisting and SSL certificates. For this, you need to add the following Jar.</p><pre>compile &quot;com.google.cloud.sql:mysql-socket-factory-connector-j-8:1.0.11&quot;</pre><p>Note that this library provides a custom SocketFactory that you need to specify in the connection url.</p><p>First, you need to add the following snippet to application.yml. Then, you need change [DATABASE_NAME] and [Db_SERVER_INSTANCE] with the name of your database and server instance name respectively. Finally, make sure to set the username and password using the following environment variables: DB_USER, DB_PASSWORD</p><pre>---<br><strong>datasources</strong>:<br>  <strong>default</strong>:<br>    <strong>jdbcUrl</strong>: jdbc:mysql://google/[DATABASE_NAME]?cloudSqlInstance=[Db_SERVER_INSTANCE]&amp;socketFactory=com.google.cloud.sql.mysql.SocketFactory&amp;useSSL=false<br>    <strong>username</strong>: &quot;${DB_USER}&quot;<br>    <strong>password</strong>: &quot;${DB_PASSWORD}&quot;<br>    <strong>dataSourceClassName</strong>: com.zaxxer.hikari.HikariDataSource<br>    <strong>driverClassName</strong>: com.mysql.jdbc.Driver<br>    <strong>maximumPoolSize</strong>: 15<br>    <strong>minimumIdle</strong>: 5<br><strong>jpa</strong>:<br>  <strong>default</strong>:<br>    <strong>packages-to-scan</strong>:<br>      - &quot;com.veamly.service&quot;<br>    <strong>properties</strong>:<br>      <strong>hibernate</strong>:<br>        <strong>hbm2ddl</strong>:<br>          <strong>auto</strong>: none<br>        <strong>show_sql</strong>: false</pre><p>If your database has a private ip and SSL connections activated, you need to change the jdbcUrl to the following:</p><pre>jdbc:mysql://[IP_ADDRESS]/[DATABASE_NAME]?cloudSqlInstance=[Db_SERVER_INSTANCE]&amp;socketFactory=com.google.cloud.sql.mysql.SocketFactory&amp;useSSL=true</pre><p>Although Micronaut is still in its early days, our experiment showed very satisfying results. This is not surprising, since the team behind <strong>Grails</strong> is the one who has built Micronaut. Stay tuned if you interested in learning more about building production-grade applications with Micronaut.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b2fc466c01a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservices: What I learnt — Part 2]]></title>
            <link>https://medium.com/@ramzi.maalej/microservices-what-i-learnt-part-2-dc3e1a713c25?source=rss-a3fcd29cd33d------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc3e1a713c25</guid>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Ramzi Maâlej]]></dc:creator>
            <pubDate>Mon, 28 Jan 2019 05:19:14 GMT</pubDate>
            <atom:updated>2019-01-28T08:20:13.139Z</atom:updated>
            <content:encoded><![CDATA[<h3>Microservices: What I learnt — Part 2</h3><p>In <a href="https://medium.com/@ramzi.maalej/micro-services-lessons-learned-part-1-5abe3f889d2f">part 1</a> of this article, I’ve covered how migrating to microservices inherently requires some organizational changes. Today, I will describe some of the traps I witnessed at clients who undertook such effort for the first time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*3RBkPMlvCzCN4bLCfd6s2w.jpeg" /><figcaption>A long way to the greenery</figcaption></figure><h3>Passthrough microservices</h3><p>One of the common patterns I discovered with clients struggling with this migration process is to build microservices that simply delegate processing business logic to a downstream system (In most cases, it was the monolith). Not only does this approach violates the principle of bounded context in DDD, it also adds more complexity to your SDLC (Software Development Life Cycle). For instance, you will have to deal with the following concerns:</p><ul><li>Additional deployments</li><li>Harder debugging process</li><li>Additional network latency</li></ul><p>As an example, I came across an account-service that does nothing but delegates all user management actions to the monolith. A better approach would be to move the whole business logic to this component. However, if the monolith still contains some logic that relies on the user data, you may leverage eventual consistency to maintain a local copy of this data.</p><blockquote>One of the biggest challenges in the transition to Service Oriented Architectures is getting programmers to understand they have no choice but to understand both the “then” of data that has arrived from partner services, via the outside, and the “now” inside of the service itself.<br><strong>Pat Helland</strong></blockquote><p>There are a couple of techniques to accommodate similar scenarios (I will introduce a technique in the last section), and I would love if you can use the comments section to share which strategy you used until the migration is fully done.</p><h3>Authorization: Identity verification</h3><p>Taking into account the scenario introduced in the previous section, I will explain one of the side effects of this approach that added unnecessary overhead to all microservices that require authenticated requests.</p><p>To give you context: I was stuffed at one of the biggest retailers in North America when I had to collaborate with its internal team to modernize their Blue Martini based e-commerce application (which was years after its end-of-life).</p><p>Blue Martini is java e-commerce platform that relies on session based authentication. As account-service was a passthrough to Blue Martini, the team has built an endpoint to verify if the user is authenticated, which was consumed by every microservice that requires authenticated requests. This verification was done in a synchronous fashion that created additional overhead and latency to all endpoints. To alleviate this problem, we moved the authentication logic from Blue Martini to account-service and introduced JWT as stateless authentication mechanism. This resulted in removing the unnecessary calls to the verification endpoint, and in achieving higher throughput.</p><h3>Async vs Sync communication</h3><p>As you start thinking about building microservices, one of questions that arises is: What is the best why to make them communicate with each other? Should we rely on async or sync communication? The obvious answer to these questions is: <strong>It depends!</strong></p><p>While microservices are a good fit for asynchronous communication, the microservice logic is better performed in a synchronous way.</p><p>Let’s imagine a hypothetical scenario of showing a product details page that’s backed by a product-detail-service, which relies on product-service, price-service, promotion-service, and recommendation-service to build this page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UdHxXvgD8dwyWOluJUn8tg.png" /><figcaption>Product details page</figcaption></figure><p>Let’s image that each microservice requires 100ms to process the request. In a sequential fashion, this would require 400ms to compose the product details page response.</p><pre>getProductDetails()<br>.then(getProductPrice)<br>.catch(err)<br>.then(getProductPromo)<br>.catch(err)<br>.then(getProductRecommendation)<br>.catch(err)</pre><p>With modern programming languages that have done a great job in supporting parallel and asynchronous programming, it’s now easy to compose the response in 100ms (or up to the same response time of the slowest service).</p><pre>CompletableFuture&lt;ProductDetail&gt; productDetail = CompletableFuture.supplyAsync(() -&gt; this.productDetailClient.get(productId));<br>CompletableFuture&lt;ProductPrice&gt; productPrice = CompletableFuture.supplyAsync(() -&gt; this.productPriceClient.get(productId))<br>CompletableFuture&lt;ProductPromotion&gt; productPromotion = CompletableFuture.supplyAsync(() -&gt; this.productPromotionClient.get(productId)); <br>CompletableFuture&lt;ProductRecommendation&gt; productRecommendation = CompletableFuture.supplyAsync(() -&gt; this.productRecommendationClient.get(productId));<br>CompletableFuture&lt;Void&gt; productPageDetails = CompletableFuture.allOf(productDetail, productPrice, productPromotion, productRecommendation);<br>productPageDetails.get();</pre><p>It’s worth mentioning that this pattern is more suitable to query state. Additionally, to tolerate failure it’s recommended to use the circuit-breaker pattern.</p><p>In the scenario where microservices need to collaborate in processing a request that involves state change, event-based communication is the recommended way to ensure eventual consistency between services. One of the most popular techniques is to rely on <a href="https://martinfowler.com/eaaDev/EventSourcing.html">event sourcing</a> and <a href="https://martinfowler.com/bliki/CQRS.html">CQRS</a>. You can find more about this topic <a href="https://microservices.io/patterns/data/event-sourcing.html">here</a>.</p><p>If you find this article useful or have something to share about it, please comment below or use <a href="https://twitter.com/ramzi_maalej?lang=en">twitter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc3e1a713c25" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservices: What I learnt - Part 1]]></title>
            <link>https://medium.com/@ramzi.maalej/micro-services-lessons-learned-part-1-5abe3f889d2f?source=rss-a3fcd29cd33d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5abe3f889d2f</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[bounded-context]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <dc:creator><![CDATA[Ramzi Maâlej]]></dc:creator>
            <pubDate>Sun, 11 Feb 2018 08:30:40 GMT</pubDate>
            <atom:updated>2019-01-17T00:34:52.685Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog post captures some of the lessons learned from my experience at ThoughtWorks helping clients move from monolithic applications to microservices. That said, I won’t be focusing on the technical details of writing microservices, but mostly on how to break down the monolith in order to build independent and high performing teams. Moreover, I will also cover some pitfalls you may run into while transitioning towards microservices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8MqGbFtseA4lJmxqx5BoQg.jpeg" /><figcaption>my learning journey</figcaption></figure><h3><strong>Breaking the monolith</strong></h3><p>One of the promises of building microservices is to increase code ownership and quality by breaking the monolith into small and cohesive units of code. This is mostly the result of identifying the bounded contexts under which each team will operate. To give you an idea of what a bounded context is, I will recall this definition: “a specific responsibility enforced by explicit boundaries.” For instance, in Retail, it could be Product Catalog, Loyalty Program, Checkout, …</p><p>In order to identify the bounded contexts within your application, it’s recommended to apply Domain Driven Design principles. Thankfully, Eric J. Evans has done a fantastic job describing them in his book “Domain Driven Design” and showing how to use them to achieve higher isolation in complex systems. To get started with domain modeling, I recommend reading Martin Fowler blog entry, which can be found <a href="https://martinfowler.com/bliki/BoundedContext.html">here</a>.</p><p>Now that you have a glimpse of how to break the monolith from a technical standpoint, let’s focus on some of the traps you may fall into while transitioning towards microservices architecture.</p><h3>Common mistakes</h3><p>While microservice architecture promises faster delivery, higher ownership, and cohesive components, it also comes with a higher operational workload and organizational change. That being said, people adopting this architecture style should be conscious of some of the faux pas that fall under the following groups:</p><ul><li>Team structure</li><li>Microservice extraction</li></ul><p>In the first part of this article, I will focus on team structure and introduce some techniques to guide you through your journey.</p><p><strong>Team structure:</strong></p><p>One of the challenges that come with microservices is restructuring IT teams to achieve a continuous flow of added value, which requires frequent deployments to production (ideally multiple times a day). In fact, in layered organizations where dev teams hand over the artifact to be deployed to QA and Release management teams, the cycle time to production is often bigger compared to cross-functional teams.</p><p>During my years of experience, I have witnessed cross-functional teams achieving greater results by owning the whole process from writing code to deploying to production. Moreover, they showed higher ownership especially when agile techniques like pair-programming and automated testing are embraced by the team.</p><p>It comes as no surprise that structural changes are often hard to implement. For this reason, it’s wise to run a pilot to determine the challenges you may face before applying the transformation across the whole organization.</p><p>Moreover, I strongly recommend defining your assumptions and your KPIs (Key Performance Indicators) before undertaking such effort. In fact, collecting <strong>quantitative</strong> data before and after each experiment is crucial to make informed decisions. It also helps you establish a data-driven culture within your company.</p><p>Back to our example, your first hypothesis could be: “By forming cross-functional teams, we will be able to roll-out new features faster.” To be able to validate this assumption, we need to measure how long it takes to build and deploy an artifact to production. To achieve this goal, we will use <strong>Value Stream Mapping</strong>. In fact, <strong>Value Stream Mapping</strong> is a lean technique to analyze processes and help improve them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*57JR5p6dMC5ztbcLXR6DhQ.png" /><figcaption>Value Stream Mapping — Deployment Process</figcaption></figure><p>As depicted in the flowchart above, most of the cycle time is spent waiting for the QA and Release teams to perform their tasks. But, a deep analysis of the situation shows that the big effort is spent on the following activities:</p><ul><li>Debrief &amp; Context switching</li><li>Internal processes (Filing change requests, QA Reports, …)</li></ul><p>Let’s imagine now that the team has all the capabilities to own the process end-to-end. After running an experiment with its respective <strong>Value Stream Mapping</strong> flowchart, we should be able to make an informed decision to confirm or reject our initial assumptions (At ThoughtWorks, We have already validated this hypothesis at multiple clients, but I would love to hear about your personal experience). To conclude, the method I showed here is based on the 4 following steps:</p><p>1. Establish a hypothesis.<br> 2. Evaluate the current state.<br> 3. Run the experiment.<br> 4. Evaluate the future state, and decide which state to keep.</p><p>Finally, in this first part, I tried to demonstrate that implementing microservices inherently requires organizational changes to build high performing teams. I also explained a data-driven approach to help teams make informed decisions. In the next part, I will talk about some pitfalls you may run into while transitioning towards microservices.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5abe3f889d2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>