<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sajid ☁️</title>
    <description>The latest articles on Forem by Sajid ☁️ (@sajid_nazeer).</description>
    <link>https://forem.com/sajid_nazeer</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F229696%2Fcdde3e80-ea7c-43fb-8755-7d3664debf85.jpg</url>
      <title>Forem: Sajid ☁️</title>
      <link>https://forem.com/sajid_nazeer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sajid_nazeer"/>
    <language>en</language>
    <item>
      <title>Do you have a mentor?</title>
      <dc:creator>Sajid ☁️</dc:creator>
      <pubDate>Sat, 03 Apr 2021 01:23:49 +0000</pubDate>
      <link>https://forem.com/sajid_nazeer/do-you-have-a-mentor-1f62</link>
      <guid>https://forem.com/sajid_nazeer/do-you-have-a-mentor-1f62</guid>
      <description>&lt;p&gt;Cross-posted at &lt;a href="https://www.msajid.cloud/2021/04/03/do-you-have-a-mentor/"&gt;https://www.msajid.cloud/2021/04/03/do-you-have-a-mentor/&lt;/a&gt; and &lt;a href="https://sajid-nazeer.medium.com/do-you-have-a-mentor-4969b0012dc0"&gt;https://sajid-nazeer.medium.com/do-you-have-a-mentor-4969b0012dc0&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As James Clear said &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“We imitate the habits of three groups in particular: The close. The many. The powerful.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Among these groups, the only group we can control is the close.&lt;/p&gt;

&lt;p&gt;According to the &lt;strong&gt;Self-expansion&lt;/strong&gt; model theory in psychology, we often achieve self-expansion through close relationships (family, friends, colleagues, etc) which allow the inclusion of the other in ourselves usually by imitating their habits and vice versa. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Self-expansion can be a growth or a failure both.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example, you might notice that you start reading books if you have a partner or a close friend who always reads and recommends books to you. Similarly, those who have friends and/or parents who smoke are more likely to start smoking than those who don’t.&lt;/p&gt;

&lt;p&gt;You might also have heard about the &lt;strong&gt;Pygmalion effect&lt;/strong&gt;, the idea behind the Pygmalion effect is that increasing the leader’s expectation of the follower’s performance will result in better follower performance.&lt;/p&gt;

&lt;p&gt;High-performing mentors have high expectations from their mentees, which might result in better mentee performance.&lt;/p&gt;

&lt;p&gt;Remember both success and failure is contagious, surround yourself with people who you look up to, or want to be like.&lt;/p&gt;

&lt;p&gt;Go get a mentor if you don’t have one already.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Leveraging full ACID transaction in Cosmos DB using Transaction Batch support in .NET SQL SDK</title>
      <dc:creator>Sajid ☁️</dc:creator>
      <pubDate>Mon, 20 Jan 2020 21:26:52 +0000</pubDate>
      <link>https://forem.com/sajid_nazeer/leveraging-full-acid-transaction-in-cosmos-db-using-transactional-batch-support-in-net-sql-sdk-3o58</link>
      <guid>https://forem.com/sajid_nazeer/leveraging-full-acid-transaction-in-cosmos-db-using-transactional-batch-support-in-net-sql-sdk-3o58</guid>
      <description>&lt;p&gt;&lt;a href="https://www.msajid.cloud/2020/01/20/leveraging-full-acid-transaction-in-cosmos-db-using-transactionbatch-support-in-net-sql-sdk/"&gt;Originally posted at msajid.cloud&lt;/a&gt;&lt;br&gt;
In this post you will learn&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is TransactionBatch?&lt;/li&gt;
&lt;li&gt;Sample scenario and demo&lt;/li&gt;
&lt;li&gt;TransactionalBatch or Stored procedure?&lt;/li&gt;
&lt;li&gt;Limitations&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With the release of .NET SQL SDK version 3.4, The Cosmos DB team has released support for TransactionalBatch, With TransactionalBatch, it is now possible to save multiple documents in a single batch operation. &lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  What is TransactionBatch?
&lt;/h1&gt;

&lt;p&gt;Documents in the batch will either all succeed atomically, or all be rolled back together. &lt;br&gt;
Yes, you guessed it right, it is a full ACID transaction support within the same logical partition key, straight from the SDK. Previously you had to write and call server-side stored procedures written in JavaScript to achieve the same functionality. &lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Sample scenario and demo
&lt;/h1&gt;

&lt;p&gt;Banks use &lt;a href="https://www.msajid.cloud/2018/02/16/event-sourcing-as-an-evolutionary-architectural-pattern/"&gt;Event sourcing&lt;/a&gt; to store events (bank transactions). These events are immutable and banks maintain a complete log of changes (transactions) as Events in an Event store. Some possible events in a bank scenario could be AccountCreated, DepositPerformed, and WithdrawPerformed, etc. &lt;/p&gt;

&lt;p&gt;When you visit a bank for opening a new bank account, you might have a requirement to deposit a minimum amount in order to activate your account. Think of it as two Events, one for creating an account and the second one is performing a sufficient deposit. If you save two documents via separate calls to the Cosmos DB one for the account creation and second for a deposit, you risk the second call to fail and you end up in a situation where you have an invalid account. You want to make sure both Events either saved successfully or none of them gets saved. In such situations, you might want to use TransactionBatch support to create a batch with both AccountCreated and DepositPerformed events and then commit the transaction. See the following code sample &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  TransactionBatch or Stored procedure?
&lt;/h1&gt;

&lt;p&gt;You might ask what’s wrong with writing a server-side stored procedure. Nothing wrong as such, but there are many reasons to prefer TransactionalBatch over authoring stored procedures&lt;/p&gt;

&lt;h2&gt;
  
  
  Better testability
&lt;/h2&gt;

&lt;p&gt;Since it is just like any other code you write, you can use your favorite mocking framework or other familiar techniques for testing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The preferred choice of language
&lt;/h2&gt;

&lt;p&gt;At the time of writing, this feature is available only in .NET SDK but Cosmos DB product team is planning to release this support for many other languages like Node, Python, and Java &lt;/p&gt;

&lt;h2&gt;
  
  
  Easier version control
&lt;/h2&gt;

&lt;p&gt;With Server-Side stored procedures, you always had to update your stored procedure before deploying your new code, and imagine if things don’t work out as you expected, how painful a rollback could be, Similarly In the world where CI/CD it is crucial to have everything as Code. &lt;/p&gt;

&lt;h2&gt;
  
  
  Better performance
&lt;/h2&gt;

&lt;p&gt;According to Microsoft, a 30% reduction in latency has been experienced when compared to Stored procedures for equal operations. Other than comparing it with Stored procedures, Saving documents as a batch reduces the number of round trips as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Content serialization flexibility
&lt;/h2&gt;

&lt;p&gt;With TransactionBatch support directly in your code, you have complete control of the way you want to serialize your object.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Limitations
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Maximum payload size is 2MB&lt;/li&gt;
&lt;li&gt;Maximum number of operations are 100 per TransactionalBatch&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;If there is anything difficult in a distributed database, that is support for the transaction. Cosmos DB product team has done a tremendous job by providing this feature directly in the SDK. Transactions are a very useful feature when you need an all or nothing behavior.  Please let me know in the comments what situations you think this feature would be useful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://devblogs.microsoft.com/cosmosdb/introducing-transactionalbatch-in-the-net-sdk/"&gt;Check Matias Quaranta blog for more details&lt;/a&gt;&lt;/p&gt;

</description>
      <category>transactionbatch</category>
      <category>cosmosdb</category>
      <category>azure</category>
    </item>
  </channel>
</rss>
