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.
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.
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:
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
Independent & Autonomous services
Scalability
Decentralization
Robust Services
Real-Time Load balancing
Availability
Continuous delivery through DevOps integration
Seamless API integration and continuous monitoring
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.
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.
Refer this for preparing yourself on how to write java program to print patterns (Note: NOT Design Patterns)
Start Pattern
Number Pattern
Star Pattern
(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.