Implementation Guidelines With Java - by Hussain
Implementation Guidelines With Java - by Hussain
with Java
Hushen Savani
What does it take to effectively
implement the systems?
To implement the system effectively, it is important not
only to learn the basics, but also you need to be PRO at
using the right tools and tech provided by Java or Java
Frameworks to do the implementation on the smart
manner with the right technique.
Purpose of this program
...is not to teach you Java, but to coach you how to
effectively implement the systems with the help of tools
& tech available with Java .
UI
UI
Gateway
Service
Microservice Microservice Microservice
1 2 3
Database
Database Database Database
Microservice Design Patterns
• Event Driven Architecture
• SAGA Design Pattern
• REST API Style Architecture
• API Gateway Pattern
• CQRS (Command Query Responsibility Segregation)
• Circuit Breaker Pattern
Event Driven Architecture
• Asynchronous Communication
• Two Messaging Models:
• P2P – Messaging Queue – Events processed by one consumer
• Publish Subscribe – Topic – Different consumer can subscribe to events
• Use case: eCommerce, IoT etc.
• Challenges: Network Failure, Out of order processing.
• Brokers: Kafka, ActiveMQ, RabbitMQ, Radis Streams, SQS etc.
Consumer / Subscriber 1
A
Producer / Publisher 1 A
A+B Consumer / Subscriber 2
B Event Broker
B
Producer / Publisher 2
Consumer / Subscriber 3
Event Driven Architecture
Subscribe
Front End Billing Service
Consume
Event
Produce
Order Service Create Order Event Broker
Subscribe
Shipping
Service
Consume
Event Driven Architecture
Choreography Orchestration
REST Architecture Style
• Stateless communication between a client and server.
• REST/HTTP works for synchronous request/reply patterns.
• 5 Aspects of REST: Contract first approach, Uniform Resource identifiers,
Statelessness, Client-Server model, Caching, Layered architecture.
• Step-1:
• Client sends request to server, including following items • Step-2:
• Header: Content Type. Authentication, Authorize tokens, version
• Server sends response to client,
• Message Body: Its optional
including following items,
• HTTP Methods
• Header: Content Type
• GET
• POST • Response Code
• PUT • Response Body (optional)
• DELETE
API Gateway Pattern
Clent
• Message gateway between client and server.
• Variation of Aggregator service.
• Key functionalities include,
• Reverse Proxy API Gateway
• Authentication and Authorization
• Load Balancing
• IP Black/White Listing
• Circuit Breaker
• Caching Microservice 1 Microservice 2 Microservice..N
• Centralized Logging
• Rate Limiting/Throttling
• Transformation
• Examples: Kong, Apache APISIX, AWS API Gateway, Zuul (Nettlix API Gateway)
Eventual Consistency (CQRS)
• Segregation of read (query) and write/updates (command) operations in a data store.
• Read operations have near real-time or eventual consistent nature.
• Common practices,
• RDBMS for write,
• NoSQL DB for read operations like MongoDB, Elasticsearch, Cassandra etc.
• CQRS pattern is often used together with the Event Sourcing Pattern.
Circuit Breaker Pattern
• Works like and electric circuit breaker - MCB.
• After a certain number of failures, circuit breaker trips for a particular duration.
• It has three states: closed, open and half-open.
• Half-open: It makes a trial call to remote service periodically.
• Popular libraries for fault tolerance in JAVA: Nettlix's Hystrix, Resilience4j.
https://www.jhipster.tech/
Database Changeset Management
https://www.liquibase.com
Project Structure Practices
https://www.sonatype.com/products/nexus-repository
Distributed Locking
https://betterprogramming.pub/multi-tenancy-support-with-spring-boot-liquibase-and-
postgresql-d41942dc0639
Functional Programming - Common Usage
Java Generics Basics
Distributed Logging
https://iamhussa.in/logging-with-context
Performance / Memory Issues Debugging
https://www.baeldung.com/java-heap-dump-capture
Performance / Memory Issues Debugging
https://heaphero.io
Performance / Memory Issues Debugging
https://www.ibm.com/support/pages/ibm-heapanalyzer
Deployment Practices
Azilen Notification Service - Overview
https://github.com/Azilen/notification-service
Clean Code
Slides
Code Review Guidelines
LINK
What's next?
• CQRS Design Pattern with Event Sourcing – Use Case
• Java Design Patterns
• Principles: OOPS, SOLID Principles etc.
• Detailed Functional Programming in Java
• Common Java Tips – Equals, Hashcode, Comparator, Money Datatype etc.
• Exception Handling Best Practices
• Detailed Spring AOP
• Interceptors 2.0
• Entity Caching
• Spring Security
• Spring Transactional Application Event Listeners
• Additional Deployment Practices
• Latest Java Features and it's usage - Overview
• Hibernate / JPA Cascade Types in detail
• Concurrency / Multi-threading
Thank You
Questions?
@hussainsavaani