<?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 SpiritualTech on Medium]]></title>
        <description><![CDATA[Stories by SpiritualTech on Medium]]></description>
        <link>https://medium.com/@spiritualtech?source=rss-75a1a5a4c54a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qMwJabQO6RwbLDcAf9GvsQ.jpeg</url>
            <title>Stories by SpiritualTech on Medium</title>
            <link>https://medium.com/@spiritualtech?source=rss-75a1a5a4c54a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 14:17:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@spiritualtech/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[In the fast-paced world of e-commerce, where every second counts, providing timely notifications…]]></title>
            <link>https://medium.com/@spiritualtech/in-the-fast-paced-world-of-e-commerce-where-every-second-counts-providing-timely-notifications-19ded0be56e5?source=rss-75a1a5a4c54a------2</link>
            <guid isPermaLink="false">https://medium.com/p/19ded0be56e5</guid>
            <category><![CDATA[dbms]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[SpiritualTech]]></dc:creator>
            <pubDate>Sun, 21 May 2023 16:27:30 GMT</pubDate>
            <atom:updated>2023-05-31T06:46:22.051Z</atom:updated>
            <content:encoded><![CDATA[<h3>Transactional Outbox Pattern</h3><p>In the fast-paced world of e-commerce, where every second counts, providing timely notifications to customers is paramount. Take, for instance, the scenario of an order being placed on a platform like Flipkart. The challenge lies in designing a system that ensures reliable delivery of notifications without compromising the overall stability of the system.</p><p>Traditionally, two approaches have been employed to handle this notification process: synchronous and asynchronous. The synchronous approach involves making a synchronous call to the notification service as soon as the order is placed and the payment is deducted. However, this immediate dependency on the response from the notification service introduces a potential vulnerability. If the notification service experiences a delay or failure, the entire order could be compromised, leading to cascading failures throughout the system.</p><p>To overcome these limitations, the asynchronous approach, utilizing the Transactional Outbox pattern, emerges as a more robust and resilient solution. By adopting an event-driven communication model, services need not be available at all times. Instead, they can operate autonomously with the data they have already replicated. When a failure occurs, the message flow halts temporarily, but once the failure is resolved, the system seamlessly picks up where it left off, ensuring no critical data or processes are lost.</p><p>The Transactional Outbox pattern acts as an additional arrow in our architectural quiver, safeguarding against the pitfalls of synchronous communication and offering greater flexibility, scalability, and fault tolerance.</p><p>In this blog, we will delve deeper into the Transactional Outbox pattern, exploring its core principles, implementation strategies, and real-world use cases. By understanding this pattern’s power to enhance system reliability, you’ll be well-equipped to architect event-driven systems that can gracefully handle challenges while keeping your customers satisfied.</p><p>So, let’s embark on a journey to unlock the potential of the Transactional Outbox pattern and revolutionize how we handle notifications in our systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*TJV4IOUKvrf-c1Yu4dtYLA.png" /></figure><p>In our scenario, we have two separate systems that need to be updated when an order is placed: the order state and the notification service. The problem is that if one of these operations fails, our systems will be out of sync. <em>This is called the dual-write problem,</em> and it can cause consistency issues in event-driven systems.</p><p>To solve this problem, we can use the Transactional Outbox pattern. This pattern ensures that both the order state and a log of events are saved in the same database, within the same transaction. This way, they are always consistent. If both operations succeed, the changes are saved together. If either operation fails, both changes are rolled back. We call the log of events our “Outbox Table,” as it keeps track of all the events we need to publish to our message queue.</p><p>But how do we get these events from the database to our message queue? We do this by using a separate process. This process, often a service or a job, reads the events from the Outbox Table and publishes them to the message platform.</p><p>The great thing about this approach is that even if a message fails to publish for some reason, we don’t lose any data. All the event data is safely stored in our database, so we can retry publishing it later. This ensures that every message will be published at least once.</p><p>By using the Transactional Outbox pattern, we can eliminate the dual-write problem and ensure that our systems remain consistent, even in the face of failures. It provides a reliable way to update multiple systems while keeping data integrity intact, making it a valuable technique in building robust event-driven systems.</p><h3><strong>Summary :-</strong></h3><ul><li>The Transactional Outbox pattern offers a robust solution to ensure reliable delivery of notifications in event-driven systems.</li><li>By persisting both the order state and event log in the same database transaction, it eliminates the dual-write problem, maintaining data consistency.</li><li>Messages from the event log are then consumed and published to the message queue, providing fault tolerance and at-least-once message delivery.</li><li>This pattern enhances system reliability and enables smooth handling of notifications in fast-paced environments like e-commerce.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19ded0be56e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Transactions What,Why and How ?]]></title>
            <link>https://medium.com/@spiritualtech/transactions-what-why-and-how-49f71426fc6?source=rss-75a1a5a4c54a------2</link>
            <guid isPermaLink="false">https://medium.com/p/49f71426fc6</guid>
            <category><![CDATA[transactions]]></category>
            <category><![CDATA[databse]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[SpiritualTech]]></dc:creator>
            <pubDate>Sun, 22 Jan 2023 14:55:21 GMT</pubDate>
            <atom:updated>2023-01-22T14:58:22.518Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Transactions What, Why and How ?</strong></h3><p>In this article, we will talk about transactions and the acronym ACID. So let’s first understand what and why transactions ?</p><p>Q)<strong><em>What is a transaction</em></strong> ?</p><p>It is a way for an application to group several reads and writes together into a logical unit.</p><p>Q)<strong><em>What is the purpose of transactions</em></strong> ?</p><p>Transactions aim to simplify the programming model for apps accessing a DB. It just means that certain potential errors and concurrency issues will be taken care by DB and not by app(also called <strong><em>safety guarantees</em></strong>).</p><p>Q) What are the <strong><em>safety guarantees</em></strong> that transactions provide ?</p><p>It’s well known by the acronym <strong><em>ACID</em></strong>. So, let’s dig deeper into each one of them one by one.</p><ol><li><strong><em>Atomicity/Abortability</em></strong> -&gt; It describes what happens if a client wants to make several writes, but a fault occurs midway. Some of the faults that can occur are as given below :-</li></ol><p>a)A process crashes.</p><p>b)Integrity constraint violates.</p><p>c)Network interrupted etc.</p><p><strong>Ability to abort a transaction</strong> on error and have all the writes from that transactions discarded is <strong>atomicity/abortability</strong>. One problem that can happen if an error occurs halfway during a transaction is when we retry after a failure. As we do not have the mechanism to detect what changes have already occured we can have duplicate data.</p><p><strong><em>2. Consistency</em></strong> -&gt; Certain statements about the data that must always be true(also called invariants). It is <strong>a property of the application not DB.</strong> The apps define what data is valid or invalid, the database only stores it.</p><p><strong><em>3. Isolation</em></strong> -&gt; Concurrently executing transactions cannot step on each other’s toes. The basic example for this is 2 threads reading the same counter variable and incrementing it also popularly referred as the <strong><em>Counter problem</em></strong>.</p><p><strong><em>4.Durability</em></strong> -&gt; Promise that once a transaction is committed successfully, even if there is a hardware fault or system crash the data will not be lost. 100% durability does not exist, what would happen if hardware and backup all are destroyed at the same time. So writing to disk, replicating to remote machines and backups should be used together.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49f71426fc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Collections Factory Methods]]></title>
            <link>https://medium.com/@spiritualtech/collections-factory-methods-1470791341d?source=rss-75a1a5a4c54a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1470791341d</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[collections-in-java]]></category>
            <category><![CDATA[collections-framework]]></category>
            <dc:creator><![CDATA[SpiritualTech]]></dc:creator>
            <pubDate>Wed, 23 Feb 2022 14:07:35 GMT</pubDate>
            <atom:updated>2022-02-25T06:29:19.109Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, we will try to understand the building of non-empty collections and maps. In the old days of Java let’s see how we used to create a list with elements:-</p><pre>List<em>&lt;</em>String<em>&gt; </em>stringList = new ArrayList<em>&lt;&gt;()</em>;<br>stringList.add<em>(</em>&quot;A&quot;<em>)</em>;<br>stringList.add<em>(</em>&quot;B&quot;<em>)</em>;<br>stringList = Collections.<em>unmodifiableList(</em>stringList<em>)</em>;</pre><p>Now let’s pause here for a moment and talk about the problems with this approach:-</p><ol><li>For a simple thing, this is a lot of code calling add each time.</li><li>Collections.unModifiableList(List list) is not efficient as it always returns a new list even though the list passed in param itself is unModifiableList, the same was the case with Set and Maps. Below is the proof:-</li></ol><pre>public static &lt;T&gt; List&lt;T&gt; unmodifiableList(List&lt;? extends T&gt; list) {<br>    return (list instanceof RandomAcces ?<br>            new UnmodifiableRandomAccessList&lt;&gt;(list) :<br>            <strong>new UnmodifiableList&lt;&gt;(list)</strong>);<br>}</pre><p>Now you can write much simpler code:-</p><pre>List<em>&lt;</em>String<em>&gt; </em>stringList = List.of(&quot;one&quot;,&quot;two&quot;,&quot;three&quot;);</pre><p>The above line has benefits as given below:-</p><ol><li>It gives us an immutable list.</li><li>The list we get does not allow for null values. Who likes NullPointerExceptions?</li><li>List.of() with no params gives you a singleton list.</li><li>This implementation is serializable.</li></ol><pre>Set<em>&lt;</em>String<em>&gt; </em>stringSet = Set.of(&quot;one&quot;,&quot;two&quot;,&quot;three&quot;,&quot;two&quot;);</pre><p>Adding “two” again gives us IllegalArgumentException as it does not make sense to have duplicates in a set.</p><pre>Map<em>&lt;Integer,</em>String<em>&gt; </em>stringList = Map.of(1,&quot;one&quot;,2,&quot;two&quot;);<br>//Here 1st param is key and 2nd param is value</pre><p>In the map, we can keep 10 key-value pairs if we want to add more than that we can do as given below:-</p><pre>List&lt;String&gt; stringList = ...;<br>stringList = strings.stream().map(String::toUpperCase).toList();</pre><p>So this is the most interesting part as we think <strong>Stream.toList()(Type A)</strong>is the same as<strong> Collectors.toList()(Type B) </strong>but it is not.<strong>Type A </strong>produces an immutable list whereas <strong>Type B </strong>produces a good old ArrayList. In Certain cases we have better performances when using <strong>Type A </strong>for example when we know the list size beforehand Stream has a SIZED property which Type A list reads and creates a list of the same size if possible, otherwise every time list is getting full it will be copied to a bigger array which has its overhead which happens internally.</p><p>Another way to create a list is:-</p><pre>List&lt;String&gt; stringList = Arrays.asList(&quot;One&quot;,&quot;two&quot;,&quot;three&quot;);<br>stringList.add(&quot;four&quot;); //UnsupportedOperationException<br>stringList.replaceAll(String::toUpperCase); //Correct</pre><p>You will think that this list is immutable but that is not correct. The way to look is it as a wrapper to an array. Once we create an array the size is fixed we cannot add or remove elements but we can change the existing element of Arrays.asList(). We can put null values also.</p><p>Let’s summarise what we have learnt:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a5GbS3rnBXepfb6P" /><figcaption><strong>Memory Table</strong></figcaption></figure><p>Do not forget to clap and share if you like the content and be in touch for more tech and spiritual blogs. Meditate and be at peace :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1470791341d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding Anger]]></title>
            <link>https://medium.com/@spiritualtech/dissectinganger-e077c339ed94?source=rss-75a1a5a4c54a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e077c339ed94</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[spirituality]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[spiritual-growth]]></category>
            <category><![CDATA[mindfulness]]></category>
            <dc:creator><![CDATA[SpiritualTech]]></dc:creator>
            <pubDate>Fri, 04 Feb 2022 15:17:47 GMT</pubDate>
            <atom:updated>2022-03-31T08:12:34.139Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, we will try to understand the root cause of anger is it something in the outside world some person said something or some circumstances because of which you are feeling anger or it has to do something with your inner world i.e. the mind playing the tricks. In ancient <strong><em>Vedic scriptures,</em></strong> anger is said to be one of the <strong><em>Manas Rog</em></strong> along with greed, desire and many others. So what do you do when you are angry either we say something or do something that we lament in future. Do not worry in this blog we will try to understand anger in-depth root cause of anger and how we can overcome it. So as I am a programmer will give it a programming touch to understand anger fused with ancient wisdom.</p><p>Let’s start with a simple flowchart as this is the first step a programmer dissects any problem in his mind like knowing all things business-wise what he needs to do and then code it and ship it(haha not that easy practically).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*AdQ76CGpipq75smOMaJ0zw.png" /><figcaption><strong>AngerFlowChart</strong></figcaption></figure><p>Okay, now those who understood it great they will get to know more and for those who did not please just read along and everything will be crystal clear at the end. So, I will tell you a story I had a neighbour let’s call him X and he had a dog Y (programmers bad at naming variables hahaha).</p><p>So every day X feeds Y in the morning and after keeping food and water for the afternoon and evening for Y he goes to his office. So what he is thinking when he is coming back home is that dog will have to eat his food and pooped at the right place but when he comes and sees everything is a mess in the house he becomes angry and beats the dog. So what is causing anger in X is it the dog or his desire from the dog that he will behave like humans and keep the room tidy btw some humans also do not behave like this(hahaha), so what has gone wrong X’s desire was not fulfilled he desired for a tidy room but he got a mess. Let’s dive further, what would have happened if the room was tidy when X comes home will he be satisfied for that day, yes but he will become greedy and want it every day but life is uncertain, so when the room is tidy X is greedy when not he is angry. So now we understood what is causing anger unfulfilled desires we can say but what is causing desire? When the mind is attached to a memory of a tidy place, thing or people it experiences the desire for it. What is the cause of attachment? By repetitive thinking, the mind attaches <strong><em>happiness</em></strong> to a place, people or thing and gets attached to it. But why does everyone seeks happiness? Because the urge for happiness is as natural to the soul as thirst is to the physical body. So make your anger your friend the way to do is to channel this anger to the right direction and the right direction is to learn good knowledge which is how we can get it, how we can help people now also you will get the anger that you are not able to do it but you are in the right direction and it will pave your way towards god.<strong><em> Happiness is the real cause of</em></strong> <strong><em>Attachment and Attachment causes desire, unfulfilled desires lead to anger and fulfilled desires lead to greed.</em></strong></p><p>So now it’s coding time:-</p><pre>boolean wantHappiness = true, desireFulfilled = false, isAttached = true; //Change desireFulfilled to switch between anger and greed<br>if <em>(</em>wantHappiness<em>) {<br>    </em>if <em>(</em>isAttached<em>) {<br>        </em>if <em>(</em>desireFulfilled<em>) {<br>            </em>System.<em>out</em>.println<em>(</em>&quot;GREED&quot;<em>)</em>;<br>        <em>} </em>else <em>{<br>            </em>System.<em>out</em>.println<em>(</em>&quot;Anger&quot;<em>)</em>;<br>        <em>}<br>    }<br>}</em>else<em>{<br>    </em>System.<em>out</em>.println<em>(</em>&quot;Pure Bliss&quot;<em>)</em>;<br><em>}</em></pre><pre>Stay connected for more blogs on tech and spirituality until we meet next meditate and be at peace. :)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e077c339ed94" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>