<?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 Mutasim Malik on Medium]]></title>
        <description><![CDATA[Stories by Mutasim Malik on Medium]]></description>
        <link>https://medium.com/@malikmutasim2121?source=rss-c11b1f1ce0e8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*RQnd4v8SFOHLo0tw</url>
            <title>Stories by Mutasim Malik on Medium</title>
            <link>https://medium.com/@malikmutasim2121?source=rss-c11b1f1ce0e8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 14:28:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@malikmutasim2121/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[Creating a custom Load Balancer in .Net using YARP]]></title>
            <link>https://medium.com/@malikmutasim2121/creating-a-custom-load-balancer-in-net-using-yarp-c4fdf88c0e4f?source=rss-c11b1f1ce0e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4fdf88c0e4f</guid>
            <category><![CDATA[reverse-proxy]]></category>
            <category><![CDATA[load-balancer]]></category>
            <category><![CDATA[yarp]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <dc:creator><![CDATA[Mutasim Malik]]></dc:creator>
            <pubDate>Fri, 22 Nov 2024 12:34:30 GMT</pubDate>
            <atom:updated>2024-11-22T12:34:30.622Z</atom:updated>
            <content:encoded><![CDATA[<h3>Creating a custom Load Balancer in .Net using YARP</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*4P4aIyL7f29EklA9Uj_mtw.png" /></figure><p>While talking about high scalability and high availability, Load Balancer comes into the picture. We have Azure, AWS, Google Cloud to provide their Load Balancers, but how about you create one for fun.</p><p>We can use popular Reverse Proxy like NginX, relatively newer YARP or even API Gateway like Ocelot, to create a Load Balancer.</p><p>We will be creating a Load Balancer using YARP in this article.</p><p>Now, if you have questions regarding YARP, YARP aka Yet Another Reverse Proxy is a highly customizable Reverse Proxy built by Microsoft on .NET using the infrastructure from ASP.NET and .NET. If you want to know further, here is their official <a href="https://microsoft.github.io/reverse-proxy/">documentation</a>.</p><p><strong>What are we going to do?</strong></p><p>We will be creating two instances of APIs, the Load Balancer will be sitting between the client and APIs, to redirect the traffic. We will be using docker containers to containerize our APIs and Load Balancer.</p><p>Let’s take a look at the system diagram to have a better understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*G7MZtme3L9lFbIrsmvZMWQ.png" /><figcaption>Fig. 1: High level design</figcaption></figure><p>Now, if we want to build the project, this is how I build it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*KACh39OEpCQ39DNjQ4kF4A.png" /><figcaption>Fig. 2: Project structure</figcaption></figure><p>Let’s create the Api project first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*Lsb5ZCPKe0pgcSh8p5tOwA.png" /><figcaption>Fig. 3: Api project structure</figcaption></figure><p>Let’s focus on the Models classes. We will be using three classes: Employee, Department &amp; GenericResponse.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/694c3487467723db9344a40c27d1655a/href">https://medium.com/media/694c3487467723db9344a40c27d1655a/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc2b378f7bebbd088844692e621af25d/href">https://medium.com/media/fc2b378f7bebbd088844692e621af25d/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23b4a1f524904b23d4c5dc4e145677ff/href">https://medium.com/media/23b4a1f524904b23d4c5dc4e145677ff/href</a></iframe><p>The Url property in the GenericResponse class will return the url of the API from which the response is coming.</p><p>Let’s create the API controllers now:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a1130c405c146424a970eaa73698a39/href">https://medium.com/media/1a1130c405c146424a970eaa73698a39/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5cd7aa042ba2e715b6841cfeb866909d/href">https://medium.com/media/5cd7aa042ba2e715b6841cfeb866909d/href</a></iframe><p>That’s it for the API project. Create the Dockerfile based on your project structure or let Visual Studio do it for you.</p><p>Let’s focus on the LoadBalancer project now.</p><p>First off, we will be adding the <strong>Yarp.ReverseProxy </strong>into this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*epZ99BiOCaS85sJ64wQ8mA.png" /><figcaption>Fig. 4: Library</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*MGRlzPcRNx3pHj5sH3XfJg.png" /><figcaption>Fig. 5: LoadBalancer project structure</figcaption></figure><p>As we have two APIs, so we will be two config files for YARP to handle the routing.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3193ca4dabae69545844736194fbc7b8/href">https://medium.com/media/3193ca4dabae69545844736194fbc7b8/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f02ed1bc8521750ec7302395b280a46b/href">https://medium.com/media/f02ed1bc8521750ec7302395b280a46b/href</a></iframe><p>Let’s understand what is happening in the configurations above. The Path containing {**catch-all} (line 7) is actually a wildcard used here to catch all the requests.</p><p>We can also see two destinations, which is the two API instances we talked about earlier (see Fig.1)</p><p>The <strong>LoadBalancingPolicy </strong>determines which algorithm you prefer. YARP has some built in Load Balancing algorithms, but if you want your custom algorithm, YARP also let you add that.</p><p>Now, we have to make changes in the <strong>Program.cs</strong> file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0cf2db3b1561aa87467857367feea25/href">https://medium.com/media/f0cf2db3b1561aa87467857367feea25/href</a></iframe><p>In the code snippet above, line number 2 and 3 are added to add the two json files created earlier. Line number 6 tells from which section configs will be read. And last but not the least, you have to add line 23 to add the Reverse Proxy routes to the route table using the default processing pipline.</p><p>Create the docker file for the LoadBalancer project, the same way you created it for the API project.</p><p>Let’s create a docker-compose file to fire up all the containers. I will provide my docker-compose.yml file for reference.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26b5c5511da434c2733c76d7a8578b89/href">https://medium.com/media/26b5c5511da434c2733c76d7a8578b89/href</a></iframe><p>From the docker-compose you can see I have two api sections, as I said earlier, we will have two api instances. Let’s use <strong>docker-compose up </strong>and trigger all the containers.</p><p>After making sure all your containers are up, let’s use postman to check if the load balancing is working properly.</p><p>To check that, we will be using Postman and we will be requesting to <a href="https://localhost:3001/employee"><strong>https://localhost:3001/</strong></a><strong> </strong>because if you take a look at the docker-compose file above, the loadbalancer container is hosted on localhost:3001.</p><p>This is the result we will be getting from the url for the employee endpont:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*RqpWZzrD_6w6X-5kDIsmDw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*LB_C2DLFo8yS6IAFlnOmDw.jpeg" /></figure><p>In both of the above screenshots the request url is the same, but if you take a close look at the url in the response, they are different in each request. If you try it for department endpoints, it will be similar as well.</p><p>If you also check the load balancer container log in docker desktop, you will also find from where the response is coming.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*C8vkZQCAVUjmJR8K_tF1_w.png" /></figure><p>If there were three instances instead of 2, it would call 3 instances in the cyclic order as the Load Balancing algorithm we used is Round Robin.</p><p>And In a load balancer, “round robin” distributes incoming client requests to a group of servers in a cyclical manner, sending the first request to the first server in the list, the second request to the next server, and so on, effectively rotating through all servers in the pool until it reaches the end and starts again at the beginning, ensuring a relatively even distribution of traffic across all servers.</p><p>So, that’s it, we have found one of the easiest ways to create a load balancer on our own.</p><p>If you need further help with the source code, you can check my github <a href="https://github.com/MutasimMalik/YALB?tab=readme-ov-file">repo</a> related to this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4fdf88c0e4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handling multiple DB requests within a single transaction using Entity Framework Core]]></title>
            <link>https://medium.com/@malikmutasim2121/handling-multiple-db-request-within-a-single-transaction-using-entity-framework-core-80042b263d07?source=rss-c11b1f1ce0e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/80042b263d07</guid>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[database-transaction]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[entity-framework-core]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <dc:creator><![CDATA[Mutasim Malik]]></dc:creator>
            <pubDate>Thu, 20 Oct 2022 11:08:21 GMT</pubDate>
            <atom:updated>2022-10-20T16:40:48.803Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*fXrtewsyGIj06qfX6vz27A.png" /></figure><p>While working with Database, whether through APIs or by other ways, (using Entity Framework/ Core) what happens behind the scenes, how many of us pay attention to that?</p><p>For instance, if we are doing multiple DB operation within a single request, it will create a database connection and commit the changes separately. This will create a lot of round trips to the database for that request. Moreover, it might cause corrupted data if something goes wrong.</p><p>So, does it sound like a good idea? I believe, you might be thinking ‘this is not even remotely good enough’. And you are right.</p><p>Now, what could be the best approach then!!</p><p>Imagine opening a transaction and do all the database operation within that, and if all of them are completed, then commit the transaction. Through this approach, data integrity can be achieved and also if any of the operation fails, the whole transaction can be rolled back.</p><p>Sounds like a good idea, right? Then, let’s see that how we can achieve that.</p><p>We will be using EF Core in this example, and as EF Core does not show what it does behind the scenes by default, so we will be configure our <strong>DbContext </strong>class to see the commands it runs, in the console.</p><p>Here is the <strong>DbContext</strong> Class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed5d50d19f586cca463b6d7a26519527/href">https://medium.com/media/ed5d50d19f586cca463b6d7a26519527/href</a></iframe><p>The <strong>optionsBuilder.LogTo(Console.WriteLine) </strong>does the trick of showing the commands in the console.</p><p>Let’s focus on a typical scenario where we will be observing what happens when we call the <strong>saveChanges() </strong>method multiple times.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0dfcdc6ee706be63a154fdaba42a4a3/href">https://medium.com/media/f0dfcdc6ee706be63a154fdaba42a4a3/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zNDDoMW5cElb5qhymycBOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fUlVvd08i1xIx2QkBDHxxQ.png" /></figure><p>If we take a look at the above code snippet and the corresponding console logs, we can see that the SaveChanges() is called 2 times and in both times EF Core opened separate Database connections and committed the changes. That means, EF Core is creating two separate transactions for these two Insert operations. This is a costly approach, and we want to avoid it.</p><p>Now to achieve multiple <strong>SaveChanges() </strong>within a single transaction we can use a feature called <strong>BeginTransaction()</strong>.</p><p><strong>DbContext.Database.BeginTransaction():</strong> Creates a new transaction for the underlying database and allows us to commit or roll back changes made to the database using multiple SaveChanges method calls.</p><p>Now, let’s rewrite the previously written method using <strong>BeginTransaction()</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a6624965073ff60a284024282f95bd1/href">https://medium.com/media/3a6624965073ff60a284024282f95bd1/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CZNIddXAQw8LS6sY91g1Kg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ctQxePtmsRzZyDQ67-lLA.png" /></figure><p>In the above code snippet, we are creating a Transaction by <strong>BeginTransaction()</strong>, doing all the DB operations within it and finally Committing it by <strong>Commit().</strong></p><p>If we look at the console, we can see that DB connection is opened only once and committed only once as well, and the two insert operations are done within this one transaction.</p><p>Voila, so this is what we wanted to achieve, handling multiple DB requests within a single transaction.</p><p>But is that all?</p><p>Not really.</p><p>What if, there are multiple transaction and any one of them gets failed?<br>Ideally the whole transaction should be reverted or rolled back.</p><p>Now the interesting part is, we can also achieve that as well in the same approach.</p><p>Let’s add a forceful <strong>Exception </strong>in the above code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7213bd99622301e74446bf46e9c3386/href">https://medium.com/media/e7213bd99622301e74446bf46e9c3386/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6iFl4Sukw-KbUan8_qEOvg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PDGxYYvWGpfKIlj4Lo0FbQ.png" /></figure><p>In the <strong>try</strong> section of the above snippet, we are triggering a foreceful <strong>Exception, </strong>and in the <strong>catch </strong>section the <strong>Rollback() </strong>method does its trick which we can see from the console.</p><p><strong>Note</strong>: You can specify different isolation levels in the DbContext.Database.BeginTransaction() method. Click here to learn more about <a href="https://msdn.microsoft.com/en-us/library/system.data.isolationlevel(v=vs.113).aspx">isolation levels</a>.</p><p>So, that’s how we can handle multiple DB request within a single transaction using EF Core in an efficient manner.</p><p>Hope you enjoy reading it and find it interesting. Have a great day folks!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80042b263d07" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementation of Outbox pattern using CAP with .Net 6, SQL Server & RabbitMQ]]></title>
            <link>https://medium.com/@malikmutasim2121/implementation-of-outbox-pattern-using-cap-with-net-6-sql-server-rabbitmq-8d6e51515cf3?source=rss-c11b1f1ce0e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d6e51515cf3</guid>
            <category><![CDATA[rabbitmq]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[distributed-messaging]]></category>
            <category><![CDATA[message-queue]]></category>
            <category><![CDATA[message-broker]]></category>
            <dc:creator><![CDATA[Mutasim Malik]]></dc:creator>
            <pubDate>Fri, 29 Apr 2022 04:18:35 GMT</pubDate>
            <atom:updated>2022-05-16T22:06:35.421Z</atom:updated>
            <content:encoded><![CDATA[<h3>Implementation of Outbox pattern using CAP with .Net 6, SQL Server &amp; RabbitMQ</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*-ic0goiUiYMJ6EloG2PotA.png" /></figure><p>If your system demands or already has asynchronous messaging, that uses a message broker; then you should start thinking about how efficiently you want to deal with the message broker. Today, we are going to discuss about a library called <strong>CAP</strong>, that provides <strong>Outbox pattern</strong> out of the box, and we are going to use it as an <strong>Event Bus</strong> for <strong>distributed messaging</strong>.</p><p><strong>What is a Distributed Transaction?</strong></p><p>Whenever messages or events are used to communicate between services, it is necessary sometimes to save the data in database and then publish an event in the message broker which will be then used by other services.</p><p>Two interesting scenarios might occur in this case:</p><ul><li>Data is saved in database, but event publishing gets failed.</li><li>An event gets published perfectly in the message broker, but failure happens while saving data in database.</li></ul><p>In the above-mentioned scenarios, there will be inconsistencies between what is saved in database vs. what events the message broker has published. So, in scenarios like these, we need one atomic transaction which will be dependent on each other. Like, if one fails, the other will roll back. This is what we call a <strong>Distributed Transaction</strong>.</p><p><strong>Outbox Pattern</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*lm0tRptFQxLekNOuTtD5mw.png" /></figure><p>Outbox pattern solves these scenarios using one single transaction to handle both cases. What it proposes includes, rather than publishing an event directly to any message broker, serialize the events and persists them in database.</p><p>Once persisted, then it will be published to message broker. If the message broker is unavailable or somehow the publishing fails, it will be retried for publishing again. That means, <strong>Outbox Pattern provides the reliability that the message you need to publish will not be lost.</strong></p><p><strong>CAP</strong></p><p>While trying to implement Outbox Pattern, I get to know about CAP and the simplicity of CAP’s configuration seems attractive. CAP supports multiple Database including SQL &amp; No SQL DB, and also most of the popular message brokers or messaging queues out there.</p><p>Here, I am going to use <strong>SQL Server &amp; RabbitMQ</strong> for the demo. Though you can manually configure SQL Server, but I am using <strong>EF Core</strong> here to configure SQL Server.</p><p>Here is the list of the relevant packages:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab18f4bb706d0c04492f7534c27893fb/href">https://medium.com/media/ab18f4bb706d0c04492f7534c27893fb/href</a></iframe><p>Now, let’s create a <strong>Context</strong> class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d673cc83df11db4fe03881497e4920c3/href">https://medium.com/media/d673cc83df11db4fe03881497e4920c3/href</a></iframe><p>Then, configure the context class in Program class.</p><p>Within the <strong>ConfigureServices </strong>method we need to use <strong>AddCap </strong>method and its various options to configure the Database and Message Broker. Remember that, configuring both DB and Message Broker is mandatory here. As I am Using <strong>EF Core</strong> and <strong>RabbitMQ </strong>so I used these (check the Program.cs class below) options within <strong>AddCap </strong>method.</p><p>Plus, I used <strong>UseDashboard()</strong> in <strong>ConfigureServices </strong>method and <strong>app.UseCapDashboard()</strong> in Configure method to have a GUI provided by CAP which shows message and event subscriptions.</p><p>Here is the complete Program class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0220d3b8235c232675d782dcbc95fe2e/href">https://medium.com/media/0220d3b8235c232675d782dcbc95fe2e/href</a></iframe><p>Now that CAP is configured, we need to publish an event. For doing so we need to use <strong>ICapPublisher. The parameters will be name and content.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/372b8d608c4e0296f4bd70638726e840/href">https://medium.com/media/372b8d608c4e0296f4bd70638726e840/href</a></iframe><p>The most interesting thing here is that the <strong>BeginTransaction()</strong> is an extension method from CAP that starts the SQL transaction and also passes it through the <strong>CapPublisher </strong>so they are using the same transaction. Using this transaction <strong>CapPublisher </strong>writes the published and received events to two tables within the database we configured earlier.</p><p>And most importantly Cap creates these tables automatically, <strong>no extra configuration is required</strong>.</p><p>Here are the two tables CAP creates after running the app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*4f425kTUAqvvZmIG-DSF5g.png" /></figure><p>Finally, we will create a Subscribe/Receiver event to subscribe the published events. For that we will implement<strong> ICapSubscribe</strong> and use <strong>CapSubscribe attribute </strong>to a method.</p><p>Remember, the <strong>argument needs to be the exact match of the published event</strong>.</p><p>Here is the <strong>Receiver</strong> class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e859f0a51626893f21f87d59aabb58e5/href">https://medium.com/media/e859f0a51626893f21f87d59aabb58e5/href</a></iframe><p>Now, before running the application we must configure RabbitMQ, otherwise the receiver service will fail. And in this case I use Docker for this purpose.</p><p>Just run the following command and voila:</p><blockquote>docker run -d — hostname rabbitmq — name rabbitmq -p 5672:5672 rabbitmq:3</blockquote><p>So, now that everything is set, let’s run the app and after hitting the API endpoint several times, as it publishes the event, and the subscriber subscribes it; the dashboard shows the events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*vtn0XQgH9h5KmRekacdN1g.png" /></figure><p>Also, the Published and Received category shows the events.</p><p>Here are the published events:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*SBrSxYxSvDgtWqwfXpLhFQ.png" /></figure><p>Here are the received events:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*f9txd51mAGOXSIldCs97tQ.png" /></figure><p>We can also see the details of each event by clicking on the id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*FIukYEeKJ1xWfYuCjVoOdg.png" /></figure><p>Similarly, if you check the <strong>Published &amp; Received</strong> tables, you can see data is saved in both tables.</p><p>As both tables have mostly common rows I am showing data from the <strong>Published </strong>Table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*JWuii5MefUemo9Ufl1rEKw.png" /></figure><p>TL;DR</p><p>So, I hope this article gives you a clear understanding of <strong>Outbox Pattern</strong> and how you can implement it using <strong>CAP</strong>. The full source code is available <a href="https://github.com/MutasimMalik/CAP-Demo">here</a>.</p><p>To see how can you configure CAP with MySQL DB, check <a href="https://codeopinion.com/cap-event-bus-outbox-pattern/">this</a> out, this article helps me to get a clear understanding about CAP.</p><p>Also check out CAP’s Git <a href="https://github.com/dotnetcore/CAP">repo</a> and Readme file.</p><p>Cheers!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d6e51515cf3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Performance analysis of EF/EF Core read operation with or without AsNoTracking() using Benchmark.net]]></title>
            <link>https://medium.com/@malikmutasim2121/performance-analysis-of-ef-ef-core-read-operation-with-or-without-asnotracking-using-benchmark-net-dd88ced3f6f1?source=rss-c11b1f1ce0e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd88ced3f6f1</guid>
            <category><![CDATA[entity-framework]]></category>
            <category><![CDATA[entity-framework-core]]></category>
            <category><![CDATA[benchmark]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <dc:creator><![CDATA[Mutasim Malik]]></dc:creator>
            <pubDate>Wed, 12 Jan 2022 12:36:48 GMT</pubDate>
            <atom:updated>2022-01-12T12:36:48.918Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*9KqPTr8nX5vp8eVQPbR_5A.png" /></figure><p>There are some tricks which can make EF/EF Core performs better. Today we are going to focus on one of those tricks.</p><p><strong>AsNoTracking()</strong> is one such powerful method and it belongs to <strong>DbExtensions</strong> Class.</p><p><strong>Why should it be used?</strong></p><p>Well, the answer lies within how EF Core works.</p><p>In standard scenario, EF or EF Core tracks all the entities selected from the Database via EF. This tracking means, the context actually monitors whether the selected object is changed or not.</p><p>Now, you might ask why EF does that.</p><p>Well, because of this tracking/monitoring of EF, we can use context.SaveChanges()/SaveChangesAsync() without any fear or without mentioning on which entity we are going to apply the change. EF keeps track of it on its own and works behind the scene.</p><p>Like, EF places the objects in the cache and monitors them, until SaveChanges()/SaveChangesAsync() is called.</p><p>Now, what happens when we use<strong> AsNoTracking()</strong>?</p><p>As the name suggests, it is pretty simple, when we use this method, the context simply stops the tracking or caching. So, the more records we retrieve from Database, EF does not do any additional processing for those data as well as does not allocate additional space for them in the memory, so the queries become faster and the amount of RAM get spared.</p><p>Okay then, let’s see the practical explanation.</p><p><strong>Note:<br>I use .Net 6, SQL Server, Benchmark.Net and EF Core to demonstrate the claim.</strong></p><p>Let’s create a simple console application. Here are the package list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*0kPgvkFS1YDWohoku-eUaA.png" /><figcaption>Packages in .csproj</figcaption></figure><p>Suppose we have this following DbContext and model class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2552891081a14ab7408387d9e1a34593/href">https://medium.com/media/2552891081a14ab7408387d9e1a34593/href</a></iframe><p><strong>Note: There are 50,000 rows in the Reading Table.</strong></p><p>Now let’s get all 50,000 rows from DB using both <strong>AsNoTracking() &amp; Default.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/952e149525cd92f68b10a858e0b2e8d4/href">https://medium.com/media/952e149525cd92f68b10a858e0b2e8d4/href</a></iframe><p>After running the application, this is the result in the console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BsKoPbl99zW60AfqO3iWCg.png" /><figcaption>Summary of the benchmark</figcaption></figure><p>From the result we can clearly see that the method with <strong>AsNoTracking() </strong>is performing significantly better and also the allocated memory for it is significantly lower than the method without AsNoTracking().</p><p><strong>Remember, If you use AsNoTracking(), the context will stop tracking the objects, therefore, you can not update the retrieved data with SaveChanges(). So, be sure that you are using it only for data reading purpose.</strong></p><p>However, there is always a way around, right? let’s see that now.</p><p>So, if you are using <strong>AsNoTracking(), </strong>and you still want to save data in the DB, this is the way (In Mandalorian voice :smirk: )</p><p>All it needs, is just using an additional line.</p><p><strong>context.Attach(reading).State = EntityState.Modified, </strong>just like the following code snippet.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5556f87f6b1bb2d5b33d2f3b3869a68c/href">https://medium.com/media/5556f87f6b1bb2d5b33d2f3b3869a68c/href</a></iframe><p>However for EF (non core), you have to use <strong>context.Entry()</strong> instead of <strong>context.Attach().</strong></p><p>Also one can also change the default tracking behaviour in the context instance level, like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd63ff9ae22b6d467aba0a71e77a60d5/href">https://medium.com/media/cd63ff9ae22b6d467aba0a71e77a60d5/href</a></iframe><p>So, let’s wrap it up by suggesting to <strong>use AsNoTracking() when the concern is only data reading, not updating or saving.</strong></p><p>Thanks!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd88ced3f6f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Return multiple result sets from Stored Procedure using EF Core]]></title>
            <link>https://medium.com/@malikmutasim2121/return-multiple-result-sets-from-stored-procedure-using-ef-core-a30eecb215e5?source=rss-c11b1f1ce0e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a30eecb215e5</guid>
            <category><![CDATA[ef-core]]></category>
            <category><![CDATA[dot-net-core]]></category>
            <dc:creator><![CDATA[Mutasim Malik]]></dc:creator>
            <pubDate>Tue, 16 Nov 2021 09:59:34 GMT</pubDate>
            <atom:updated>2021-11-16T10:38:16.430Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w-AI3Q8sR7WjAycKIWX29g.png" /></figure><p>If you are working in .Net Core and use relational databases, then you might be very much familiar with Entity Framework Core. Now, you might already know that EF Core is performance wise superior to Entity Framework or EF6, but there is one key feature I miss very much while working with EF Core and stored procedures.</p><p>Sometimes it is necessary to return multiple result sets from any stored procedures.<br>Why?<br>Because it saves multiple Database calls.</p><p>Suppose, you need to populate data for a dashboard in your system. Now you need nine tables from which you retrieve data, then that’s nine times you are hitting the database. That’s when returning multiple result sets from one SP call comes in handy as it saves you from additional DB calls.</p><p><strong>No Translate in EF Core!!</strong></p><p>One of the key features of pre-Core EF was the ability of translating a DBDataReader into any Entity, which was done by the Translate&lt;T&gt; method.</p><p>However, in EF Core, the Translate&lt;T&gt; method is not available.</p><p>So, we had to write our own method for translation and thanks to Mr. Jonathan “JD” Danylko’s <a href="https://dzone.com/articles/aspnet-core-with-entity-framework-core-returning-m">Blog</a>, we were able to make it.</p><p>Let’s call the new class, <strong>Materializer</strong>.<br><br>The materializer will have to satisfy the following requirements:</p><p># If an entity&#39;s property references another entity, bypass it.</p><p># If an entity&#39;s property references a collection, bypass it.</p><p># If an entity&#39;s property has a [NotMapped] attribute attached to it, bypass it.</p><p>Our main goal is to map an IDataRecord to an Entity’s native types.</p><p>Let’s dive into coding now.</p><p>Suppose we have a SP that returns multiple result sets.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc0f9268d6b9a6a4c64dd55d4cfc2115/href">https://medium.com/media/dc0f9268d6b9a6a4c64dd55d4cfc2115/href</a></iframe><p><strong>Let’s create the Materializer</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*oQiXpZ-W9-PVpEEOzMKEWg.png" /><figcaption>Materializer workflow</figcaption></figure><p>Next, convert the workflow into a class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ccfcd3314d237d74e66f9694e56b35f4/href">https://medium.com/media/ccfcd3314d237d74e66f9694e56b35f4/href</a></iframe><p>Let’s focus on the DataRecord now.</p><p>As the DbDataReader is an IDataRecord, let’s create extension methods.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b716dbd2ebb4ed4860997bfaa869710b/href">https://medium.com/media/b716dbd2ebb4ed4860997bfaa869710b/href</a></iframe><p>If you check the above code, you can see that <strong>ConcurrentDictionary </strong>is used for thread safety.</p><p>Now that we have the alternative to Translate&lt;T&gt;, let’s perform a Translate&lt;T&gt;</p><p><strong>Performing the Translate&lt;T&gt;</strong></p><p>Now, take the SP above as an example and consider we have a class BlogsNPosts.cs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/332d91463af472a91b26d74183e75645/href">https://medium.com/media/332d91463af472a91b26d74183e75645/href</a></iframe><p>Now, calling the method (from repo) would be like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff1c17aa175b7538cf74538ccb6bf230/href">https://medium.com/media/ff1c17aa175b7538cf74538ccb6bf230/href</a></iframe><p><strong>Few things to keep in mind</strong></p><p><strong>Here, we use TransletList() method as in the BlogsNPosts class both properties are IEnumerable&lt;&gt;. For single properties, we have to use Translate() method instead.</strong></p><p><strong>Final words</strong></p><p>So, that’s it. Now EF Core is also able to return multiple result sets. All you need to do is to follow what lies above.</p><p>If you find any better approach, please don’t forget to mention that in comment section.</p><p>Happy coding!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a30eecb215e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is middleware and how to deal with it in .Net 5]]></title>
            <link>https://medium.com/@malikmutasim2121/what-is-middleware-and-how-to-deal-with-it-in-net-5-be52eae9d403?source=rss-c11b1f1ce0e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/be52eae9d403</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[middleware]]></category>
            <dc:creator><![CDATA[Mutasim Malik]]></dc:creator>
            <pubDate>Thu, 18 Mar 2021 13:29:29 GMT</pubDate>
            <atom:updated>2021-03-18T13:38:03.315Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is middleware and how to deal with it in .Net 5</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*1Omb1DpcKLzbWkNXvb7MwQ.jpeg" /></figure><p>In .Net 5, middleware plays a vital role to handle the request-response pipeline. In here we are going to discuss the concept of middleware pipeline and how we can make our own custom middleware and plug in to the pipeline.</p><p><strong>The background story:</strong></p><p>In classic asp.net model, the request and response objects are bigger and tightly coupled with the IIS. Even some of the values of these objects are filled by IIS request-response pipeline and thus unit testing of such objects is a challenge.</p><p>To decouple the applications from the IIS or web servers, .Net followed the standards defined by OWIN, and there have been many implementations over the years from Katana to this day, and we are going to see how the implementation looks like in .Net 5.</p><p><strong>How middleware works:</strong></p><p>OWIN defines that, the requests coming from the web server to any web application, have to pass through multiple components. And these components actually build the request-response pipeline.</p><p>These components can inspect, modify, redirect or generate response for any incoming request and then the response get back to the web server passing through the same pipeline but in the reverse order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JmAiR1lcxZfxxS3E28lEQQ.png" /></figure><p>There are three sorts of methods we can use to run the custom middleware.</p><p>· Run()</p><p>· Use()</p><p>· Map()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*mcsOksS50ef1wb6r668j2w.png" /><figcaption>Run, Use, Map and their responsibilities.</figcaption></figure><p><strong>Run() </strong>intercepts requests and generate response without chaining it to any other pipeline. Run delegates do not receive a <strong>next</strong> parameter.</p><pre>app.Run(async context =&gt;</pre><pre>{</pre><pre>await context.Response.WriteAsync</pre><pre>(&quot;I will generate the response&quot;);</pre><pre>});</pre><p>Middleware component generates with <strong>Run </strong>generates a response.</p><p><strong>Use() </strong>chains multiple<strong> </strong>request delegates where <strong>next </strong>parameter represents the next delegate of the pipeline. The pipeline can be short-circuited by not calling the next method and actions can be performed both before and after next delegate.</p><pre>app.Use(async (context, next) =&gt;</pre><pre>{</pre><pre>//logic before next middleware here</pre><pre>await next.Invoke();</pre><pre>//logic after next middleware here</pre><pre>});</pre><p>Middleware registered with <strong>Use</strong> can forward the request onto the next delegate.</p><p><strong>Map() </strong>is used for branching the pipeline, it branches the request pipeline based on matches of the given request path. <strong>Map</strong> also supports nesting.</p><pre>app.Map(&quot;/hello-world&quot;, SayHello);</pre><pre>//a method outside of configure method</pre><pre>private static void SayHello(IApplicationBuilder app)</pre><pre>{</pre><pre>app.Run(async context =&gt;</pre><pre>{</pre><pre>await context.Response.WriteAsync</pre><pre>(&quot;Hi, the request was mapped here.&quot;);</pre><pre>});</pre><pre>}</pre><p>In the code, if the incoming request matches the “hello-world”, the <strong>SayHello </strong>method will be executed, and the <strong>SayHello </strong>method here will generate response using <strong>Run </strong>method.</p><p><strong>Implementation:</strong></p><p>There are 2 ways to define custom middleware:</p><p>· Custom middleware class</p><p>· Inline custom middleware</p><p>We will be trying both ways here.</p><p><strong>Custom middleware class:</strong></p><p>Let’s start with a custom middleware class containing our middleware logic.</p><pre>public class justValidator</pre><pre>{</pre><pre>public RequestDelegate _next { get; }</pre><pre>public justValidator(RequestDelegate next)</pre><pre>{</pre><pre>_next = next;</pre><pre>}</pre><pre>public async Task InvokeAsync(HttpContext context)</pre><pre>{</pre><pre>StringValues authorizationToken;</pre><pre>context.Request.Headers.TryGetValue(&quot;x-id&quot;, out authorizationToken);</pre><pre>if (authorizationToken.Count &gt; 0 &amp;&amp; authorizationToken[0] == &quot;confusing21&quot;)</pre><pre>await _next(context);</pre><pre>else</pre><pre>context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;</pre><pre>await context.Response.WriteAsync(&quot;Invalid header token&quot;);</pre><pre>return;</pre><pre>}</pre><pre>}</pre><p>This class will get the call when the request will hit this middleware. The <strong>InvokeAsync</strong> method will be called and the current <strong>HttpContext</strong> will be passed to it. Using the <strong>context </strong>we can execute our custom logic and then the <strong>next </strong>method will call the next middleware.</p><p>Here this class will be looking for a header value like an authentication token, if it gets the desired value which is a static value for this demo, the next middleware will be called otherwise it will send a message.</p><p>For the middleware to get into the pipeline we need to put it into the <strong>Configure </strong>method of the <strong>Startup </strong>class.</p><pre>app.UseMiddleware&lt;justValidator&gt;();</pre><p>Let’s test it in <strong>Postman </strong>now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MHx-Bv286NF7JSqk0SN9LA.png" /><figcaption>Request-response checking using Postman without x-id</figcaption></figure><p>In the above picture, the Header does not contain <strong>x-id </strong>so the response is <strong>Invalid header token.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zzVu7PtIbJ3v-zgk76MpHw.png" /><figcaption>Request-response checking using Postman with x-id</figcaption></figure><p>Now, after giving the proper <strong>x-id </strong>value, we can see the data in <strong>Postman</strong> now.</p><p><strong>Inline custom middleware:</strong></p><p>The inline custom middleware can be directly defined in the <strong>Configure</strong> method like this:</p><pre>public void Configure(IApplicationBuilder app, IWebHostEnvironment env)</pre><pre>{</pre><pre>app.UseMiddleware&lt;justValidator&gt;();</pre><pre>app.Use(async (context, next) =&gt;</pre><pre>{</pre><pre>DateTime startTime = DateTime.Now;</pre><pre>await next();</pre><pre>DateTime endTime = DateTime.Now;</pre><pre>TimeSpan processTime = endTime - startTime;</pre><pre>await context.Response.WriteAsync($&quot;Total Process Time {processTime}&quot;);</pre><pre>});</pre><pre>if (env.IsDevelopment())</pre><pre>{</pre><pre>app.UseDeveloperExceptionPage();</pre><pre>}</pre><pre>app.UseRouting();</pre><pre>app.UseAuthorization();</pre><pre>app.UseEndpoints(endpoints =&gt;</pre><pre>{</pre><pre>endpoints.MapControllers();</pre><pre>});</pre><pre>}</pre><p>The inline middleware here to show/log any request execution time.</p><p>Let’s test again on Postman.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0sUDH61nK6X-fn3EXEHBzw.png" /><figcaption>The request execution time</figcaption></figure><p>From the screenshot we can see the request execution time (marked with yellow ink).</p><p><strong>Note </strong>: Even though middleware is discussed here in the context of .Net 5, the concept of middleware is same in all MVC implementations that maintains the OWIN standards.</p><p>For the source code, please check <a href="https://github.com/MutasimMalik/net5Middleware">GitHub</a>.</p><p><strong>References:</strong></p><ul><li><a href="http://owin.org/html/spec/owin-1.0.1.html">owin: open web server interface for .net</a></li><li><a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-2.1">asp.net core middleware</a></li><li><a href="https://docs.microsoft.com/en-us/azure/architecture/patterns/pipes-and-filters">pipes and filters pattern</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be52eae9d403" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Background Task Scheduler with ASP.NET & Quartz.NET — Do it once, it will do further]]></title>
            <link>https://medium.com/@malikmutasim2121/background-task-scheduler-with-asp-net-quartz-net-do-it-once-it-will-do-further-fbf33aa959a7?source=rss-c11b1f1ce0e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbf33aa959a7</guid>
            <category><![CDATA[task-scheduler]]></category>
            <category><![CDATA[quartz]]></category>
            <category><![CDATA[aspnet]]></category>
            <dc:creator><![CDATA[Mutasim Malik]]></dc:creator>
            <pubDate>Wed, 18 Mar 2020 04:51:15 GMT</pubDate>
            <atom:updated>2020-03-18T04:51:15.954Z</atom:updated>
            <content:encoded><![CDATA[<h3>Background Task Scheduler with ASP.NET &amp; Quartz.NET — Do it once, it will do further</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*KqyDpT0VT8b2tOAy9yaGXQ.jpeg" /></figure><p>While developing an application it is sometimes needed to run a task in the background that is to be scheduled at some point in future.</p><p>We are going to create one of those type of tasks today with the help of ASP.NET and Quartz.NET. In case if you are not familiar with Quartz.NET, do not worry, we’re starting with it.</p><h4><strong>What is Quartz.NET?</strong></h4><p>According to their <a href="https://www.quartz-scheduler.net/">website</a>:</p><blockquote>Quartz.NET is a pure .NET library written in C# and is a port of very popular open source Java job scheduling framework, <a href="http://www.quartz-scheduler.org/">Quartz</a>.</blockquote><p>Quartz.NET has two major concepts:</p><ul><li><strong>Job</strong>: This is the task we want to run in background based on a schedule.</li><li><strong>Scheduler</strong>: This is what runs the jobs based on triggers.</li></ul><p>Quartz.NET provides features more than just running timed background tasks; as by using a <a href="https://www.quartz-scheduler.net/documentation/quartz-3.x/tutorial/crontriggers.html">Cron trigger</a> one can choose specific times of specific days or only specific days or any combination.</p><p>However, we are not using Cron trigger in this example, like I mentioned, there are other features as well, which we are going to explore.</p><p>Before starting let me share what I am using for this demo:</p><ul><li><em>NET Framework 4.7.2</em></li><li><em>Quartz.NET 2.3.3</em></li></ul><p><strong>Action</strong></p><p>Let’s <strong>install Quartz.Net from NuGet manager</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*Tj5O67AY3ALNOuu2ukBRiw.png" /><figcaption>Intalling Quartz.Net from NuGet manager</figcaption></figure><p>Now, make a class and <strong>implement IJob interface </strong>which has one method to be implemented</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*_eauJ7vleA1JW8dRFTGFnA.png" /><figcaption>Implementing IJob() interface</figcaption></figure><p>Then, it is time to build the trigger to run the <strong>Job </strong>in a regular interval.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*jpgC3PrFUybC77P1Gn09AQ.png" /><figcaption>Creating a trigger for running the ‘Job’</figcaption></figure><p>The<em> </em>WithIntervalInSeconds(20)<em> will run the job after every 20 seconds.</em></p><p>There are other methods as well for running at any desired time and as mentioned earlier with the help of <em>Cron trigger </em>we can make different time combinations as well.</p><p>Lastly, we can start the task at the start of the application.</p><p>(In this demo project I took a ASP.NET web application and thus I called it in Application_Start() method in <em>Global.asax</em>.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*MYLahhTZOP3lFUqMhK2Gmw.png" /><figcaption>Starting at Application_Start()</figcaption></figure><p>By running the application we can now get the output with an interval of 20 seconds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*ZlNZ8Xqwegm4ZHdNePGmxA.png" /><figcaption>Output</figcaption></figure><p>Take a look at <a href="https://github.com/MutasimMalik/BackgroundTaskScheduler">GitHub</a> if you need the code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbf33aa959a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>