30 May, 2022

distributed messaging system and some common messaging scenarios

 

What is Distributed Messaging System?


Distributed messaging is based on the concept of reliable message queuing. Messages are queued asynchronously between client applications and messaging systems. A distributed messaging system provides the benefits of reliability, scalability, and persistence.

Most of the messaging patterns follow the publish-subscribe model (Pub-Sub) where the senders of the messages are called publishers and those who want to receive the messages are called subscribers.

Once the message has been published by the sender, the subscribers can receive the selected message with the help of a filtering option. 

Type of filtering

  •  topic-based filtering
  •  content-based filtering.

Note that the pub-sub model can communicate only via messages. It is a very loosely coupled architecture; even the senders don’t know who their subscribers are. Many of the message patterns enable with message broker to exchange publish messages for timely access by many subscribers. 

A real-life example is Netflix, amazon prime video, which publishes different channels like sports, movies, music, etc., and anyone can subscribe to their own set of channels and get them whenever their subscribed channels are available.


Some common messaging scenarios are:

Messaging. Transfer business data, such as sales or purchase orders, journals, or inventory movements.

Decouple applications. Improve reliability and scalability of applications and services. Client and service don't have to be online at the same time.

Topics and subscriptions. Enable 1:n relationships between publishers and subscribers.

Message sessions. Implement workflows that require message ordering or message deferral.

Here is an example of Azure Bus Service:



17 May, 2022

Angular-npm ERR cb() never called

 Angular-npm ERR cb() never called

Here is easy steps to solve this problem?

while installing a node package from the package.json file and the package-lock.json file is corrupted due to some reasons like  the node.js version is updated to the latest,  you may see an error like this in our terminal.

Following are the possible solutions to this problem, I trust, you may try one of them will work for you.

Solution 1:

npm config set registry https://registry.npmjs.org/

Solution 2:

npm cache clean

Or

npm cache clean --force

You might also manually remove the node_modules folder and try again in case the command above failed.

If still doesn't work, the global cache might be broken, try running npm cache clean --force and then do a clean install.

Solution 3:

npm install -g npm

Just globally installed the newest version of NPM and my guess Clearing npm cache is optional.



24 April, 2022

Azure Web Application Firewall?

 

Azure Web Application Firewall?

Azure Web Application Firewall (WAF) on Azure Application Gateway provides centralized protection of your web applications from common exploits and vulnerabilities. Web applications are increasingly targeted by malicious attacks that exploit commonly known vulnerabilities. SQL injection and cross-site scripting are among the most common attacks.

WAF on Application Gateway is based on Core Rule Set (CRS) 3.1, 3.0, or 2.2.9 from the Open Web Application Security Project (OWASP).

What problem it'll solve for your application( Features)?

  • SQL-injection protection.
  • Cross-site scripting protection.
  • Protection against other common web attacks, such as command injection, HTTP request smuggling, HTTP response splitting, and remote file inclusion.
  • Protection against HTTP protocol violations.
  • Protection against HTTP protocol anomalies, such as missing host user-agent and accept headers.
  • Protection against crawlers and scanners.
  • Detection of common application misconfigurations (for example, Apache and IIS).
  • Configurable request size limits with lower and upper bounds.
  • Exclusion lists let you omit certain request attributes from a WAF evaluation. A common example is Active Directory-inserted tokens that are used for authentication or password fields.
  • Create custom rules to suit the specific needs of your applications.
  • Geo-filter traffic to allow or block certain countries/regions from gaining access to your applications.
  • Protect your applications from bots with the bot mitigation ruleset.
  • Inspect JSON and XML in the request body

https://docs.microsoft.com/en-us/azure/web-application-firewall/media/ag-overview/waf1.png

Image Source: https://docs.microsoft.com/en-us/azure/web-application-firewall

Protection

  • Protect your web applications from web vulnerabilities and attacks without modification to back-end code.
  • Protect multiple web applications at the same time. An instance of Application Gateway can host up to 40 websites that are protected by a web application firewall.
  • Create custom WAF policies for different sites behind the same WAF
  • Protect your web applications from malicious bots with the IP Reputation ruleset
  • read more on MSDN

09 January, 2022

Fund Transfer from WazirX to Binance and Vice Versa Free

 

How To Transfer Cryptocurrency, Coins From WazirX To Binance? A Step-by-step Procedure

WazirX was acquired by Binance, a worldwide cryptocurrency exchange, in November 2019. Binance is one of, if not the largest, cryptocurrency exchanges in the world. Binance has a number of innovative crypto trading capabilities that no other Indian crypto exchange has. Furthermore, Binance offers the largest cryptocurrency collection on their site, with more than 500 coins and tokens accessible for purchase. Users of WazirX who want to acquire more cryptocurrencies that aren't available on their platform but are available on Binance can do so by linking their Binance and WazirX accounts.


You should have account on both exchanges with same email id and/Or Mobile Number

Login to Binance

Go to Wallet >> Valina Options >> WazirX,  Below is the Binance Screen shot


Once you logged over WazirX using Binance  your both app will be connected to each other(No Cost so nothing to worried, both are the same company now)

then you will click, you will find following screen


Now you can transfer token or USDT or other allowed crypto between screen writhing few second with Zero Cost.

Transfer WazirX to Binance

Login to WazirX

 Go to my walled and Selected UDT pairs crypto like INR/USDT  click on withdraw, screenshot for the same



you will seed an option to send to Binace, select it and transfer token very fast , secure and absolutely now cost. 


You will get 10% Discount on your trading fee if you join with Below invitation


Binance Joining Link: https://accounts.binance.com/en/register?ref=GW4QZ68E



06 October, 2021

How to Make a Custom URL Shortener Using C# and .Net Core 3.1

C# and .Net Core 3.1:  Make a Custom URL Shortener


Since a Random URL needs to be random and the intent is to generate short URLs that do not span more than 7 - 15 characters, the real thing is to make these short URLs random in real life too and not just a string that is used in the URLs


Here is a simple clean approach to develop custom solutions


Prerequisite:  Following are used in the demo.


Add a class file named ShortLink.cs and put this code: here we are creating two extension methods.

public static class ShortLink
{
    public static string GetUrlChunk(this long key)=> 
        WebEncoders.Base64UrlEncode(BitConverter.GetBytes(key));

    public static long GetKeyFromUrl(this string urlChunk)=> 
        BitConverter.ToInt64(WebEncoders.Base64UrlDecode(urlChunk));
}


Here is the Calling Sample code 
using System;
using System.Text;
using Microsoft.AspNetCore.WebUtilities;

namespace UrlShorten
{
    class Program
    {
        static void Main(string[] args)
        {
              
            string value = "SOME MEANING DYNAMIC/STATIC CONTENT";
            // Convert the string into a byte[].
            byte[] asciiBytes = Encoding.ASCII.GetBytes(value);
            long temp = 0;
            foreach (var item in asciiBytes)
                temp += item;
            // key = Tiks + sub of string bytes: that will be always unique
          var key = DateTime.UtcNow.Ticks + temp;
            Console.WriteLine($"Dynamic Key: {key}");
            var generatedUrl = key.GetUrlChunk();
            Console.WriteLine($"Generated URL: {generatedUrl}");
            Console.WriteLine($"Key From URL: {generatedUrl.GetKeyFromUrl()}");
            Console.ReadKey();
        }
    }
}

Here is the final output


28 September, 2021

c# Copy an Azure Storage blob into Subfolder or Subdirectories

 Copying All Blob of given Container into the same container and under subfolder?

Here are few key points about the copying blob in Azure Storage Account:

  • When you copy a blob within the same storage account, it's a synchronous operation.
  •  When you copy across accounts it's an asynchronous operation.
  • The source blob for a copy operation may be a block blob, an append blob, a page blob, or a snapshot. If the destination blob already exists, it must be of the same blob type as the source blob. An existing destination blob will be overwritten.
  • The destination blob can't be modified while a copy operation is in progress. A destination blob can only have one outstanding copy operation. In other words, a blob can't be the destination for multiple pending copy operations.


To copy a blob, call one of the following methods:

  • StartCopyFromUri
  • StartCopyFromUriAsync

We are using  .Net Core 3.1

Step  1Install-Package Azure.Storage.Blobs -Version 12.10.0

Step 2:  use the following code to move your container (named images)file into the same container  under a subfolder name called 

for example, if your current file store in images/my-pic.png this code will move to images/my-folder/my-pic.png


private static async Task CopyBlobToSubFolderAsync(BlobContainerClient container)
{
    
        // Get the name of the first blob in the container to use as the source.
        string blobName = container.GetBlobs().FirstOrDefault().Name;

        // Create a BlobClient representing the source blob to copy.
        BlobClient sourceBlob = container.GetBlobClient(blobName);

        // Ensure that the source blob exists.
        if (await sourceBlob.ExistsAsync())
        {
            // Lease the source blob for the copy operation 
            // to prevent another client from modifying it.
            BlobLeaseClient lease = sourceBlob.GetBlobLeaseClient();

            // Specifying -1 for the lease interval creates an infinite lease.
            await lease.AcquireAsync(TimeSpan.FromSeconds(-1));

            // Get the source blob's properties and display the lease state.
            BlobProperties sourceProperties = await sourceBlob.GetPropertiesAsync();

            // Get a BlobClient representing the destination blob with a unique name.
            BlobClient destBlob = 
                container.GetBlobClient("my-folder/" + sourceBlob.Name);

            // Start the copy operation.
            await destBlob.StartCopyFromUriAsync(sourceBlob.Uri);

            // Get the destination blob's properties and display the copy status.
            BlobProperties destProperties = await destBlob.GetPropertiesAsync();

         
            // Update the source blob's properties.
            sourceProperties = await sourceBlob.GetPropertiesAsync();

            if (sourceProperties.LeaseState == LeaseState.Leased)
            {
                // Break the lease on the source blob.
                await lease.BreakAsync();

                // Update the source blob's properties to check the lease state.
                sourceProperties = await sourceBlob.GetPropertiesAsync();
            }
        }   
}



15 September, 2021

Challenges of Microservices and When To Avoid Them

 When not to use microservices?


  • Your defined domain is unclear or uncertain
  • Improved efficiency isn’t guaranteed
  • Application size is small or uncomplex


Challenges of Microservices


Microservices could be more expensive than monolithic applications.

A poor design may lead to:
  • Increased latency
  • Reduced speed of calls across different services
  • A cascading failure may overwhelm your server
  • Poorly breaking down a module into microservices 
  • Handling Distributed Transactions in the Microservice

Running overproduction





Disclaimer: following above screenshots from pluralsight.com