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.!

Micro service and Design Patterns

Micro service and Design Patterns

Things about Micro service and Design Patterns 

In this article, we will see Micro service and Design Patterns.

Micro service and Design Patterns

Micro service aka MSA has become the go-solution for most of the Enterprise to build or migrate the applications. They are known to solve various snags.

In order to build effective Microservice. We need to weld on to the design patterns, which helps us to improve the performance of the application.

Let us see the below topics as part of this article:

  1. What are  Microservices?
  2. Ethics followed while Designing Microservice Architecture
  3. Microservice Design Pattern

What are Microservices?

Microservices, aka MSA aka microservice architecture, is an style that structures an application as small collection of autonomous services which is surrounded around Business domain or models.

Ethics followed while Designing Microservice Architecture

  1. Independent & Autonomous services
  2. Scalability
  3. Decentralization
  4. Robust Services
  5. Real-Time Load balancing
  6. Availability
  7. Continuous delivery through DevOps integration
  8. Seamless API integration and continuous monitoring
  9. Isolation from Failures
  10. Auto-provisioning

In the next article we will see in detail about all the design patterns one by one.

LIKE | SHARE | SUBSCRIBE

WeCanCode-Author

WeCanCode-Author

November 04, 2021

Developer | Java, C#.NET & Python 

Planning to learn ReactJS or Angular or Flutter.!

Make WordPress as Android App

Make WordPress as Android App

Make WordPress as Android App

In this article, let discuss on

Make WordPress as Android App

Make WordPress as Android App. Yes, follow the article from top to bottom and do not miss out anything. In the end you will see your website or WordPress blog in Android phone as an application.

You can also publish the app in Google Play Store or any eco-system for Android apps (Such as Amazon app store, Samsung galaxy app store, Honor/Huawei App Gallery and So on).

How to Make WordPress as Android App?

Converting WordPress blog or Website is easy if you have hands-on with Android Studio and Android SDKs.

               Yes, you need to know little bit of java coding knowledge and basics of Android application development. Do not worry if you have very little knowledge on these both should also be fine. If you follow this article carefully.

WeCanCode-Author

WeCanCode-Author

October 20, 2021

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

Planning to learn ReactJS or Angular or Flutter.!

Java 8: Streams – Part 1

What is Streams?

Stream is a new abstract layer introduced in Java 8, It represents a sequence of objects from a source, which supports aggregate operations.

To understand better, lets take basic sql function distinct.

SELECT DISTINCT(USER_TYPE_ FROM [MYSCHEMA].[USER];

In the above SQL script, we perform Distinct operation using the DISTINCT method. which actually performs operation on the retrived data/rows.

Similarly Java8:Streams also performs operation or action on collective data.

Follow are the characteristic of Java8:Streams

  • Sequence of elements − Stream provides a set of elements of specific type in a sequential manner. A stream gets/computes/manipulated the elements/data. It never stores the manipulated elements/data.
  • Source − Stream accepts Collections, Arrays, or I/O resources as input source.
  • Aggregate operations − Stream supports aggregate operations such as filter, map, limit, reduce, find, match, & so on.
  • Pipelining − Most of the stream operations return stream itself so that their result can be pipelined. These operations are called intermediate operations and their function is to take input, process them, and return output to the target. collect() method is a terminal operation which is normally present at the end of the pipelining operation to mark the end of the stream.
  • Automatic iterations − Stream operations do the iterations internally over the source elements provided, in contrast to Collections where explicit iteration is required.

Lets continure in the next part..

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));
	}
}
JAVA PROGRAM TO PRINT PATTERNS

JAVA PROGRAM TO PRINT PATTERNS

Interview Questions

Refer this for preparing yourself on how to write java program to print patterns (Note: NOT Design Patterns)
  • Start Pattern
  • Number Pattern

Star Pattern

 Print pattern like below, By giving the max length of the print.  (max. length is 5)
(max. length is 5)
public class StarPatternApp {
	public static void main(String[] args) {
		StarPatternApp.printPattern("*", 5);
	}
	private static void printPattern(String pattern, int size) {
		StringBuilder patternBuilder = new StringBuilder();
		for (int i = 1; i <= size; i++) {
			patternBuilder.append(pattern);
			System.out.println(patternBuilder.toString());
		}
		for (int i = size; i > 1; i--) {
			System.out.println(patternBuilder.deleteCharAt(i - 1).toString());
		}
	}

	private static String addSpaceAndPrint(int spaceCount, String printStr) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < spaceCount; i++) {
			sb.append("" + i);
		}
		sb.append(printStr);
        	return sb.toString();
	}
}

Number Pattern

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class NumberReducingPatternApp {

    public static void main(String[] args) {
       int n = 5;
       int length = 1;
       List<Integer> numberPatternItems = new ArrayList<>();
       for(int i=n; i>0;i--){
           numberPatternItems.add(listRangeInReverse(n,length));
           length++;
       }

       //This line actually reverst the entire list, so that the expected number pattern is printed
       Collections.reverse(numberPatternItems);
        for(Integer x: numberPatternItems){
            System.out.println(x);
        }
    }

    private static Integer listRangeInReverse(int k, int count) {
        StringBuilder sb = new StringBuilder();
        for (int c = k; c >=count;c--){
            sb.append(c);
        }
        return Integer.parseInt(sb.toString());
    }
}

Just a Note

There are N-ways of writing the above codes, please feel free to explore by playing around it.

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