What is Asynchronous Messaging Design Pattern?

What is Asynchronous Messaging Design Pattern?

What is Asynchronous Messaging Design Pattern?

Previously we saw about What is Microservice? and the principles followed while developing MSA and the available design patterns. also, we saw an API Gateway design pattern.

Today we will see what is Asynchronous Messaging Design Pattern is.

What is Asynchronous Messaging Design Pattern?

Previously we saw about Chained or Chain of responsibility design pattern which makes the client wait for a long time, It also breaks the chain if any one service goes down and cause a bad experience for the clients.

To avoid such bad experiences for the client, The Asynchronous design pattern can be used, which communicate with the available services using message queue or event driven approach and not sequentially.

Yes, Messaging or events, The Asynchronous design pattern uses the Messaging Queue (MQ) or Event driven like ActiveMQ, RabbitMQ, Kafka and other tools for its communication with other services.

Example:

Consider we have Cart, Product, Stock, Order & Shipping services.

When the Product is added to the Cart, Stock must be updated accordingly, So the Product calls stock via Message Queue.

And then Order calls shipment via Message Queue to prepare a label for shipment.

This way the client need not wait for the flow of service to be completed to get the response immediately.

what is Asynchronous design pattern?

 

In the next article, we will see Shared Database or Shared Data design pattern.

 

LIKE | SHARE | SUBSCRIBE

WeCanCode-Author

WeCanCode-Author

November 11, 2021

Senior Developer | Java & C#.NET | 10++ years of IT experience.

Planning to learn ReactJS or Angular or Flutter.!

What is API Gateway Design Pattern?

What is API Gateway Design Pattern?

What is API Gateway Design Pattern?

Previously we saw about What is Microservice? and the principles followed while developing MSA and the available design patterns. also we saw an Aggregator design pattern.

Today we will see what is API Gateway Design Pattern is.

What is API Gateway Design Pattern?

Microservice is built in such a way that each service acts differently on its own. So, when a web application is drilled down into smaller pieces there could be problems we face.

The problems are as follows.

  1. How to get data from various microservices?
  2. A different front-end application is required to manage the same database, just that it uses multiple web services.
  3. How to respond with the data for different consumer to satisfy their requirement. So that we can have reusable microservices.
  4. Handle multiple protocol requests.

Seems the list is small here, but in reality, it is even wider. The solution for these problems is to use the API Gateway design pattern. The API Gateway design pattern addresses many other problems apart from the ones mentioned above. We can also use this design pattern as a proxy service for routing the request.

 API Gateway acts as the entry point for all the endpoints of the microservice, it can help in converting the various protocol request from one type to another. Also, it can disburden the responsibility of authentication/authorization in the microservice.

 So, once the client sends the request, requests are passed through the API gateway which manages the entry point and re-routes the client’s request to the appropriate microservice. Then with the help of the load balancer, it distributes the client’s request to the microservice.

Microservice uses the service discovery which maintains the available microservices and their available entry points to communicate with each other

What is API Gateway Design pattern?

API Gateway Design pattern

 

 

In the next article, we will see Chained or Chain of Responsibility design pattern.

 

LIKE | SHARE | SUBSCRIBE

WeCanCode-Author

WeCanCode-Author

November 06, 2021

Senior Developer | Java & C#.NET | 10++ years of IT experience.

Planning to learn ReactJS or Angular or Flutter.!

Know Aggregator Microservice Design Pattern

Know Aggregator Microservice Design Pattern

Aggregator Microservice Design Pattern

Previously we saw about What is Microservice? and the principles followed while developing MSA and the available design patterns.

Know about Microservice Aggregator Design Pattern.

Know Aggregator Microservice Design Pattern

The Aggregator is something that collects related items or data and displays them (combining and merging of data).

In MSA aggregator is a basic web service that internally invokes various services to get the required information that needs to be aggregated and send back to the requestor.

This pattern helps when you have the requirement of collecting data from various different services and merging the collected information.

aggregator microservice

Example:

We have two different services namely Student and Address which has their own database, and we need to gather the data from both the service/database.

Which uses a Unique ID as a reference in both databases, thus allowing us to fetch the data from both databases via the web service endpoint and combine or aggregate them with help of the new service Student’s Address which is the aggregator service.

 

 

In the next article, we will see in API Gateway design pattern.

 

LIKE | SHARE | SUBSCRIBE

WeCanCode-Author

WeCanCode-Author

November 05, 2021

Senior Developer | Java & C#.NET | 10++ years of IT experience.

Planning to learn ReactJS or Angular or Flutter.!

How to create a file in unix – 3Minutes: Tutorial

In this video, I have explained How to create a file in unix?

(Create, edit, view and save text file using unix terminal.)

This video covers the below listed commands

  1. pwd – present working directory
  2. cd – change directory
  3. touch – to create file
  4. cat – view content of the file
  5. less – same as cat command, but opens in editor
  6. mkdir – make or create directory
https://youtu.be/xDe6OLATxQc

How to create a file in unix ?

aryanz_co_in@pop-os:~/dev/folder1$ touch hello.txt
aryanz_co_in@pop-os:~/dev/folder1$ vi hello.txt
[Edit the file] to save press Esc + :wq (w is for save and q is for quit)
aryanz_co_in@pop-os:~/dev/folder1$ cat hello.txt

Keep the learning short, not to waste your precious time.

How to create a file in unix - 3Minutes: Tutorial
Java Programming: Why do we have main method ? can this method name be changed ?

Java Programming: Why do we have main method ? can this method name be changed ?

I was wondering always, why it is always main method is the starting point for the Java program.

Well When i was matured enough to read the Java Specification i learnt why and whether can it be changed ? Okay Lets See !!

Why main method ?

Main method is the starting point for the java program, JVM initialize the class and invokes main method, having below listed specifications (reference 12.1.4). 

  • Should be named as main 
  • Should be public 
  • Should be static 
  • Should accept String array as argument. 
  • Return type is void 

As based on the above specification, we can conclude that we cannot rename the main method. 

Some Additional Info.!

public static void main(String[] args)  // this is valid

public static void main(String… args)  //String…  this is also valid where it is available from the java 5

public static void main(String args[]) //This is valid but not recommended because the array brackets in the variable)

String Java Program: Palindrome

String Java Program: Palindrome

Interview Questions

Refer this for preparing yourself on how to write java program to check given string is a Palindrome or not.

Palindrome

public class PalindromeApp {
	public static void main(String[] args) {
		String input = "dad";
		if (PalindromeApp.isPalindrome(input)) {
			System.out.println(String.format("%s is palindrome", input));
		} else {
			System.out.println(String.format("%s is NOT palindrome", input));
		}
	}

	private static Boolean isPalindrome(String input) {
		char[] inputArr = input.toLowerCase().toCharArray();
		char[] reverse = new char[inputArr.length];

		for (int i = 0; i < inputArr.length; i++) {
			reverse[i] = inputArr[(inputArr.length - 1) - i];
		}
		String r = new String(reverse); // String.copyValueOf(reverse);
		return (input.equals(r));
	}
}

Please disable your adblocker or whitelist this site! We Provide Free content and in return, all we ask is to allow serving Ads.

Pin It on Pinterest