11 JEE application integration styles with diagrams

One of the very frequently asked open-ended interview questions is – Can you describe the high-level architecture of a recent application you had worked on?

1) to draw an architectural diagram on a white board and
2) to provide a brief description of the architecture, and
3) to elaborate on decisions, pros, cons, challenges, risks, etc ….

Q1. What are the different application integration styles?
A1. Enterprise systems don’t stand-alone. They integrate with many other corporate systems to provide mission critical services to the clients. There are a number of different integration styles like

Integration Styles

Integration Styles

#1 Shared database

where multiple applications share the same database. This approach is simple, but has disadvantages such as

1) More likely to hit performance & bottlenecks and scalability issues. SQL Databases don’t really scale.

2) Any adjustments (e.g. version upgrade) to the database for one application will have side effects on other applications. Complicates indexing and table partitioning as different applications have different needs.

3) Concurrency & timing issues as there could be chronological dependencies among processes that share the database. What about different applications working on the same tables concurrently? What if one application modifies the data that should have been altered by another application first?

#2 Batch file transfers

Applications will have their own databases, and the data from one application will be copied into another application’s database via an over-night or regular interval batch jobs with an ETL (i.e. Extract Transform & Load) process. Extract from one database and transform them into feed files (e.g. CSV or TAB delimited). These feed files are then loaded or ingested into another application’s database.

Why make copies of the data? An order placement application will require customer or product information. Only one application will be the source of truth and can create or modify the data, and the other applications will use the data as read only.

A typical industrial example would be that a Java & Spring based online ordering application requiring data from a legacy mainframe system. You can also bring in data from external organizations.
Disadvantages of ETL are:

1) Not ideal for near real-time (i.e. NRT) or on-demand data access that requires fast response.

2) Not only takes lots of considerations & time to develop, but also difficult to keep up with changing requirements.

[ ETL architecture & process interview Q&As | ETL/ELT on BigData Interview Q&As]

#3 Invoking Remote Procedure Calls (i.e. RPC)

RPC is an inter-process communication that allows one program to directly call procedures in another program either on the same machine or another machine on the network. An RPC is initiated by the client, which sends a request message to a known remote server to execute a specified procedure (i.e. a block of code) with supplied parameters. The remote server sends a response to the client, and the application continues its process.

RPC is the earliest & simplest form of API using the “request–response” protocol. When this is implemented over HTTP or AMQP it becomes a Web API. You build Web APIs using REST, GraphQL, gRPC, and SOAP. A Web API is an Application Programming Interface for either a web server or a web browser. Web APIs expose service(s) via endpoints on a server where clients can connect via HTTP to use that service(s). Clients can be a browser, mobile device or a web service client on another web server.

REST API [Source: https://phpenthusiast.com/blog/what-is-rest-api]

REST Vs. GraphQL Vs. gRPC [Source: https://sensedia.com/en/api/apis-rest-graphql-or-grpc-who-wins-this-game/]

For example: JSON, XML, or protobuf (i.e. efficient binary format) data can be exchanged between App1 and App2 in language agnostic manner.

App1 (REST client aka consumer) ==> JSON ==> App2 (REST service provider)

App1 (i.e. gRPC stub) ==> protobuff ==> App3 (i.e. gRPC Server)

Spring supports inter-process communication via Web Services JAX-RS (i.e. RESTful web service) & JAX-WS (i.e SOAP Web service), which are successors of JAX-RPC. gRPC is an open source remote procedure call library with best practices patterns, and uses HTTP/2 for transport and protocol buffer as the interface definition language (i.e. IDL). gRPC provides features such as authentication, bidirectional streaming and flow control, blocking or nonblocking bindings, and cancellation and timeouts. It generates cross-platform client and server bindings for many languages.

gRPC overview & workflow

gRPC overview & workflow

One of the biggest differences between REST and gRPC is the format of the payload. REST messages typically contain JSON, whereas gRPC accepts and returns Protobuf (aka Proto) messages, which are binary. Microservices is where gRPC really shines since it enables low-latency and high-throughput communication as well as strong API contracts. Whilst gRPC is better than REST for most of the things, there’s one thing that REST is still better, which is the browser support. REST is fully supported by all browsers, and the support for gRPC is limited and requires gRPC-web with a proxy layer to convert between HTTP/1 and HTTP/2. gRPC is a great choice for a network-constrained environment such as mobile applications (i.e. android/ios) due to its light-weight message format.

When creating RESTful web services backed by a formal contract, you can choose between two approaches: contract-last and contract-first. gRPC is strictly contract-first. Services and messages are defined in “.proto” files and the relative server and client stubs are auto-generated using the gRPC toolset in any of the supported languages including Java.

GraphQL is a Web API works with a one endpoint with only “POST” verb, and exchanges JSON data. It is stateless like REST APIs. In REST APIs the designers decide which URL Paths as GET/Users, GET/Users/1, GET/Addresses, GET/Addresses/2, etc, what verbs as in GET/users/1, POST /users/1, PUT /users/1, DELETE /users/1, etc and optionally what request body as in JSON payload, etc use.

But in GraphQL, you only have one endpoint and only POST request with the request body containing the query to retrieve the required data.

Requesting GraphQL API to return user name:


You can use https://graphql.buildkite.com/explorer to explore more on GraphQL. In GraphQL you can instruct it to bring back only the data you need. In the above example it only brings back user name. There are other operation types like “mutation” to update existing data or add new data & “subscription” for live subscriptions where server informs client of any events via WebSockets in addition to the “query” operation type. WebSocket uses HTTP as the initial transport mechanism, but keeps the TCP connection alive after the HTTP response is received.

REST API Vs. Graph API [Source: ACADE Mind – https://www.youtube.com/watch?v=PeAOEAmR0D0]

There are other protocols like RMI, Spring’s HTTP Invoker, Hessian, and Burlap for inter process communication.

#4 Messaging (i.e. events driven) via MOM (i.e. Message Oriented Middleware)

This is also an inter-process communication whereby exchanging messages asynchronously over a message oriented middleware (MOM) like Apache Kafka, Websphere MQ, Rabbit MQ, etc. MOM is useful for asynchronous request-reply or publish-subscribe messaging because a request may take a long time to complete or several parties may be interested in the actual message.

Spring supports both JMS and AMQP. [ Asynchronous processing in Java real life examples.]

A real world example is that of a web application that is used to place orders or trades for customers. Your application taking orders on-line will save the order to a database & publish a message onto a JMS queue. Another application listening to the queue will respond to the event by taking the order and then placing that order with another third party system (e.g. a trading system). The third application may be responsible for taking the order and sending emails on order statuses such as confirmation and completion. All these events take place asynchronously. [ Asynchronous processing in Java real life examples]

Monolithic Vs. SOA Vs. Micro Services

#3 & #4 can be architected as a

1) Monolithic application where all the business capabilities like managing products, placing orders, shipping orders, invoicing customers, etc will be using the same database, infrastructure & similar/same technologies.

OR as a 2) SOA (i.e. Service Oriented Architecture)

Monolithic Vs SOA Vs Microservice

Monolithic Vs SOA Vs Microservice

3) Micro services architecture where each business capability will be an independent service having its own database, infrastructure & programming language. This has the advantages of being able to independently scale an individual service, independently deploy a service more frequently, looser coupling of services, separate teams can manage & specialise in different services, parallel development, independent testing of services and if a service is down the site can still function with the other services.

Monolith Vs Microservices

This flexibility of micro services architecture comes at a price of more complexity due to more moving parts in the architecture. Also, it requires good architects & designers to set the right boundaries & granularity for the services. Eric Evans’s Domain Driven Design principles are very useful to define the granularity of a service. A number of patterns & best practices need to be applied to make the services resilient (i.e. handling failures & monitoring).

There are two approaches for developing modern applications using microservices:

1) Start a new application using microservices architecture right away, or

2) Start with a monolith and then gradually split and migrate to microservices. This is because

a) Setting up the initial base infrastructure for microservices from scratch can be time-consuming,

b) As the monolith application grows in size, it becomes much clearer and easier to identify functional boundaries for potential refactoring into microservices with minimal effort.

300+ Enterprise Java Interview Q&As
Module 1 Describe the recent Java application that you had worked on from a 100 feet?-
Unit 1 12 High-level JEE architecture overviews at 100 feet with diagrams  - Preview
Unit 2 Describe a typical Java EE architecture?  - Preview
Unit 3 11 JEE application integration styles with diagrams  - Preview
Module 2 JEE Overview+
Unit 1 10 JEE overview interview Q&As
Unit 2 4 JEE bean validation, asynchronous processing & web fragments interview Q&As
Module 3 Web Basics+
Unit 1 4 Http methods, content types, headers, MIME types, cookies, etc Q&As
Unit 2 12 Web development basics interview Q&AS
Unit 3 8 Web development design patterns interview Q&As
Module 4 Java Servlets+
Unit 1 21 Java servlet interview Q&As
Unit 2 5 web.xml, ServletConfig, and ServletContext interview Q&As
Module 5 View Technologies in Java Web applications+
Unit 1 Client-side vs server side view technologies interview Q&As
Unit 2 13 AngularJs interview Q&As
Unit 3 7 JSP interview Q&As
Unit 4 9 JSF interview Q&As
Module 6 Java Web Services+
Unit 1 6 must know Java Web Services Interview Q&As
Unit 2 6 Micro & web services interview Q&As
Unit 3 6 RESTful web services interview Q&As
Unit 4 JAX-RS how to create a RESTFul Web Service in Java?
Unit 5 5 JAXB interview Questions & Answers
Unit 6 RESTful interview question on 12 rules to remember
Unit 7 REST constraints (i.e. design rules) interview Q&As
Unit 8 HATEOAS question on RESTful web service
Unit 9 HATEOAS RESTFul Service with Spring tutorial
Unit 10 11 SOAP web services interview Q&As
Unit 11 SOAP Web Service Styles Interview Q&As
Module 7 Java and Spring Microservices+
Unit 1 10+ Domain Driven Design (i.e. DDD) Interview Q&As
Unit 2 10+ Key Microservices Interview Questions Answered
Unit 3 7 Apache Kafka interview Q&As
Unit 4 DevOps, Kubernetes, Docker & Microservices Q&As
Module 8 Spring Core+
Unit 1 9 Spring framework overview interview Q&As
Unit 2 DIP, DI, Spring IoC and loose coupling in detail Q&As
Unit 3 4 Spring bean lifecycle interview Q&As
Unit 4 17 Spring bean scopes interview Q&As
Module 9 Spring MVC and Spring Boot+
Unit 1 11 Spring MVC interview Q&As
Unit 2 15 Spring boot Interview Q&As
Unit 3 Spring Cloud Microservices interview Q&As
Module 10 JPA and Hibernate+
Unit 1 8 JPA interview Q&As
Unit 2 8 Hibernate basics interview Q&As
Unit 3 8 Hibernate object states, lazy loading & optimistic locking Q&As
Module 11 JDBC, Transaction Management & JTA+
Unit 1 5 JDBC overview interview Q&As
Unit 2 12 JDBC basics interview Q&As
Unit 3 9 Java Transaction Management interview Q&As
Unit 4 8 JTA interview Q&As
Module 12 JMS, JNDI, and JMX+
Unit 1 16 JMS interview Q&As
Unit 2 9 JNDI & LDAP interview Q&As
Unit 3 5 JMX and MBean interview Q&As
Module 13 Database & SQL+
Unit 1 15 Database interview Q&As
Unit 2 15 SQL interview Q&As
Unit 3 3 SQL subqueries interview Q&As
Module 14 Unix & Regex+
Unit 1 14 Unix interview Q&As
Unit 2 Power of regex for string manipulation
Unit 3 9 Regular expressions (aka regex) in Java interview Q&As
Module 15 JSON, XML & XSD+
Unit 1 17 XML interview Q&As
Unit 2 11 XSD interview Q&As
Unit 3 7 Processing XML in Java interview Q&As
Unit 4 5 JAXB interview Q&As
Unit 5 6 JSON interview Q&As
Unit 6 Processing JSON in Java
Module 16 UML & ERD+
Unit 1 12 UML interview Q&As
Unit 2 10 ERD (i.e. Entity-Relationship Diagrams) interview Q&As
Module 17 Maven & Git+
Unit 1 12 Maven build tool interview Q&As
Unit 2 7 Maven, Nexus, and other build tools Q&As
Unit 3 8 Git Source control system interview Q&As
Unit 4 6 Git Q&As on pull requests, rebasing, merging, etc
Module 18 JavaScript+
Unit 1 3 Java Vs. JavaScript interview Q&As
Unit 2 10 JavaScript Interview Q&As on variable scopes & context
Unit 3 10 JavaScript interview Q&As on functions, prototypes, “this” variable, binding, etc
Unit 4 10 JavaScript interview Q&As on functions
Unit 5 7 JavaScript interview Q&As on closures
Module 19 SDLC+
Unit 1 5 SDLC interview Q&As for Java developers
Unit 2 18 Agile development methodology interview Q&As
Unit 3 30+ SDLC activities performed by developers
Module 20 Enterprise Code Quality+
Unit 1 3 Ensuring code quality in Java applications Q&As
Unit 2 6 Unit testing Spring boot applications Q&As
Unit 3 4 Q&As on unit testing the DAO layer
Unit 4 Unit testing Spring controller
Unit 5 BDD development in Java
Module 21 Judging Experience+
Unit 1 3 How would you go about ..." Q&As to judge experience
Unit 2 11 In your Java experience, what are ... Q&As
Unit 3 7 Interview Q&As on debugging skills
Unit 4 18 Java scenarios based interview Q&As
Unit 5 9 SQL scenarios Q&As judge experience
Unit 6 How would you go about designing Java apps with UML diagrams?
Learn by categories on the go...
Learn by categories such as FAQs – Core Java, Key Area – Low Latency, Core Java – Java 8, JEE – Microservices, Big Data – NoSQL, Architecture – Distributed, Big Data – Spark, etc. Some posts belong to multiple categories.