This repo is for all POC which I does and learning’s I learnt Below are the projects that I have completed POC
-
mongodb-redis-integration → adding fault tolerant caching layer to MongoDB.
-
reactive-mongodb-redis-integration → adding fault tolerant reactive caching layer to reactive MongoDB.
-
spring-boot-rest-webmvc → Enterprise application integrated with spring data, datasource-proxy, JPA, ActiveMQ(for demostration)
If you encounter any bug, please file an issue here.
To suggest a new feature or changes that could be made, file an issue the same way you would for a bug.
Pull requests are welcome. To open your own pull request, click here. When creating a pull request, make sure you are pointing to the fork and branch that your changes were made in.
This project is using lombok so you need to prepare your IDE as described here. After Setup import project as a maven project.
Code coverage is a software metric used to measure how many lines of our code are executed during automated tests. JaCoCo reports help you visually analyze code coverage by using diamonds with colors for branches and background colors for lines:
-
Red diamond means that no branches have been exercised during the test phase.
-
Yellow diamond shows that the code is partially covered – some branches have not been exercised.
-
Green diamond means that all branches have been exercised during the test. The same color code applies to the background color, but for lines coverage.
JaCoCo mainly provides three important metrics:
-
Lines coverage reflects the amount of code that has been exercised based on the number of Java byte code instructions called by the tests.
-
Branches coverage shows the percent of exercised branches in the code – typically related to if/else and switch statements.
-
Cyclomatic complexity reflects the complexity of code by giving the number of paths needed to cover all the possible paths in a code through linear combination. To take a trivial example, if there is no if or switch statements in the code, the cyclomatic complexity will be 1, as we only need one execution path to cover the entire code.
Generally the cyclomatic complexity reflects the number of test cases we need to implement in order to cover the entire code.
To assign spring-formatter issue command after adding plugin to pom.xml
mvnw io.spring.javaformat:spring-javaformat-maven-plugin:apply
Release using maven and git flow
-
git checkout -b release master(create branch release from master)
-
mvn --batch-mode release:prepare release:perform -DscmCommentPrefix="bumping versions" -DreleaseVersion=0.0.1 -DdevelopmentVersion=0.0.2-SNAPSHOT(sets comments, release version and development version)
-
git checkout master(get lastest master in local)
-
git merge --no-ff -m "Release Merge release into master" release (merge master with release/0.0.1 branch) or use git merge branchname
-
git branch -D release(delete branch release)
-
git push --all && git push --tags(push master and tags to repository)
-
mvn release:clean(deleted backupfiles from local env)
In the context of imperative programming:
-
List-based functional programming is eagerly evaluated.
-
Stream() introduced in Java 8 and is the seam showing we’re not programming imperatively anymore. Is it required, though?
-
imperative - what and how
-
declarative - what and not how + higher order functions = FP. Code reads like the problem statement, through "internal iteration"/ "iteration on autopilot" Mutability is OK, but shared mutability is not.
-
-
In OOP we encapsulate moving parts - in FP, we eliminate them.
-
Is stream API slow - you don’t want a faster bicycle, but a rocket - EASIER TO PARALLELIZE
-
List is bucket, Stream is pipeline. You don’t store water in a pipeline, you just move it through there.
-
Functional composition (builder pattern) is essential.
-
Lazy evaluation example - removing the terminal (collect) method - functions not being called anymore, as result not needed.
-
Many languages give programming pattern, such as Groovy, but laziness not there, as it depends on implementation.
Limitations of streams:
-
Single use only. Example where a stream is assigned to a variable, printed and then used with different filter condition. Result: IllegalStateException: stream has been operated on or closed.
-
Concept: streams like QTips - use once and throw away.
-
-
Not possible to fork in the middle. Only a single terminal operation.
-
How do you deal with exceptions: sorry :(. Exception handling is an imperative-style idea: call a function, which calls a function, etc. and destroys your callstack.
-
Scala has Mono monads and Either objects - provides safe handling, which is propagated and used in downstream stages. Lacks cohesion!
-
Still good luck - we want pure functions and exceptions normally come from impurity.
-
Reactive systems:
-
Came out of Microsoft research, but just a new name for old concept - system that reacts to stimuli
-
Four pillars of reactive programming:
-
Elasticity
-
Message-driven
-
Responsive
-
Resilience - circuit breakers built in, partial access to application
-
-
Close to the 80’s concept of dataflow computing: d → f → d →f
-
Instructions ready to fire when the data is available
-
Serverless computing (AWS Lambda) == dataflow programming. At the minute computation is ready and prepared it can run on ANY server with predefined affinity
-
-
Reactive programming is FP++ - builds on lazy evaluation and functional composition
-
Example with Flowable and subscribe on it
-
-
Both Java Streams and Reactive ones push data, regular iterators pull. They are similar to Observable, you register to it and it pushes data to you.
-
Both can return 0, 1 or more data.
-
Java 8 Streams deal only with data. RS contain three channels (Data, Err, Complete). In RS error is just another form of data.
-
RS are asynchronous, so you are not locked into parallelism (sync).
-
RS can handle consumer back-pressure.
-
Multiple subscribers in RS, where single pipeline in Java Streams
-
Interface differences:
-
Reactive Stream:
-
Publisher
-
Subscriber
-
Subscription - session between emitter and subscriber, can hold context
-
Processor - publisher + subscriber
-
Implementations: RxJava, Akka, Reactor (Spring 5), RSocket
-
-
Java reactive streams - same interface, since Java 9 - in the java.util.concurrent.Flow.* class
-
-
mvn versions:display-plugin-updates
-
mvn versions:display-property-updates
Java Memory Model Very Important - https://www.youtube.com/watch?v=ZBJ0u9MaKtM - http://tutorials.jenkov.com/java-concurrency/java-memory-model.html - https://walkingtree.tech/design-patterns-microservices/ - https://springframework.guru/gang-of-four-design-patterns/state-pattern/ (State Pattern) - https://techburst.io/microservices-design-patterns-a9a03be3aa5e (Diagram of design pattern) - https://github.com/AnghelLeonard/Hibernate-SpringBoot (Hibernate) - https://www.youtube.com/channel/UCiz26UeGvcTy4_M3Zhgk7FQ (Defog Tech esp Threads) - https://www.youtube.com/channel/UCZCFT11CWBi3MHNlGf019nw (Algorithms) - https://dzone.com/articles/microservices-communication-zuul-api-gateway-1 - https://microservices.io/patterns/microservices.html - https://microservices.io/patterns/data/api-composition.html - https://www.tutorialspoint.com/spring_boot/spring_boot_eureka_server.htm - https://dzone.com/articles/spring-boot-autoscaler - https://www.elastic.co/what-is/elk-stack - https://dzone.com/articles/libraries-for-microservices-development - https://logz.io/blog/kibana-tutorial/ - https://dzone.com/articles/magic-of-kafka-with-spring-boot - https://www.baeldung.com/spring-cloud-rest-client-with-netflix-ribbon - https://jwt.io/introduction/ - https://www.springboottutorial.com/introduction-to-centralized-logging-with-microservices - https://dzone.com/articles/microservices-architectures-centralized-configurat - https://developers.redhat.com/blog/2019/03/12/distributed-microservices-architecture-enterprise-integration-istio-and-managed-api-gateways/ - https://docs.vmware.com/en/VMware-vSphere/6.7/Cloud-Native-Storage/GUID-CF1D7196-E49C-4430-8C50-F8E35CAAE060.html - https://pivotal.io/cloud-native - https://www.loomsystems.com/blog/single-post/2017/01/30/a-comparison-of-fluentd-vs-logstash-log-collector - https://logz.io/blog/fluentd-logstash/ - https://www.callicoder.com/java-8-completablefuture-tutorial/ - https://codete.com/blog/5-common-spring-transactional-pitfalls/