0% found this document useful (0 votes)
143 views

Producer and Consumer: Java EE Enterprise Edition

The document discusses producer and consumer activities. Producer activities include composing music, developing software, and cooking food. Consumer activities include listening to music, watching movies, eating, and buying clothes.

Uploaded by

FuadNaserAl-deen
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
143 views

Producer and Consumer: Java EE Enterprise Edition

The document discusses producer and consumer activities. Producer activities include composing music, developing software, and cooking food. Consumer activities include listening to music, watching movies, eating, and buying clothes.

Uploaded by

FuadNaserAl-deen
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Producer and Consumer

Listening to music, watching movies, eating, buying clothes are all consumer
activities. ‫ צרכן‬-
On the other hand, composing music, developing a software, cooking food are
producer activities. ‫– יצרן‬

 Front End
The developer should have the knowledge of HTML, basic CSS & JavaScript.
Besides these fundamental technologies, companies prefer to use frameworks
such as React, Angular, Vue etc. to write their front end module.

Engineering teams pick front end frameworks to –

 Give a structure to their front-end module


 Leverage features that these frameworks offer such as breaking up the
page into components, re-usability of those components, dynamic loading and
so on.
 Dodging the need to write boilerplate code, as a result speeding up the
development process
 Maintain the code efficiently
 Have a standard look and feel on the UI

 Back End - It is also known as server-side development


To develop the application backend, the developer should have the knowledge
of Core Java, Java EE Enterprise Edition that entails Servlets, REST, JSON
API, Asynchronous, Server-Sent events, JPA & so on.
These are the fundamentals that every Java dev should be thorough with.
Besides the fundamentals, we need Spring framework.
HTTP (Hypertext Transfer Protocol)
HTTP is a protocol that clients and servers use on the web to communicate.
It is similar to other internet protocols such as SMTP(Simple Mail Transfer
Protocol) and FTP(File Transfer Protocol) but there is one fundamental
difference.
HTTP is a stateless protocol i.e HTTP supports only one request per
connection. This means that with HTTP the clients connect to the server to
send one request and then disconnects. This mechanism allows more users to
connect to a given server over a period of time.
The client sends an HTTP request
and the server answers with an HTML
page to the client, using HTTP.

 DELETE — Removes specified


resource
 GET — Fetches data from server
 POST — Sends data to server
 PUT — Replaces current representation of target resource with uploaded
content

What is different between web server and application server?

Web Server: it can handle HTTP from client browsers and respond the request
with an HTTP Response.
A web server understands HTTP language and runs on HTTP protocol.

Apache Web Server is kind of a web server and then we have specific
containers that can execute servlets and JSPs known as the servlet container,
for example, Tomcat.
Apache Tomcat Server

JSPs, like servlets, are server-side programs run inside a Java-capable HTTP server. Apache Tomcat
Server (@ http://tomcat.apache.org) is the official reference implementation (RI) for Java servlet and JSP,
provided free by Apache (@ http://www.apache.org) - an open-source software foundation.

Application Servers provide additional features such as Enterprise JavaBeans


support, JMS Messaging support, Transaction Management, etc.

So, they are helper applications that resides‫ \מתגורר‬at web server and build
dynamic web pages. A dynamic page could be anything like a page that randomly
chooses picture to display or even a page that displays the current time.

So, we can say that the Application server is a web server with additional
functionalities to help developers with enterprise applications.
 Web Application(webapp): I would refer this as webapp in this guide.
Basically, the project is your web application, it is the collection of
servlets.

Java Web-service/RestFul API- Based on representational state transfer


technology for communication in web services development. It is a standard
API for get, put, post and delete data. This is something you’ll end up
learning if you have to code in java.

RestFul Web Service A RestFul web services


are based on HTTP methods and the concept
of REST. A RestFul web service defines the
base URI for the services, the supported
MIME-types (XML, text, JSON, user-defined,
…). It also defines the set of operations
(POST, GET, PUT, DELETE) which are
supported.

 Easy to learn and universal presence

 OOPs
Object Oriented programming is considered as one of the best programming
paradigms out there. Java is an OOP based language. And using it to create
apps make them more modular, flexible and supports extensions.
 Powerful and awesome tools and APIs
It has a great collection of Open source libraries and APIs. These tools make
development with Java faster, easier and cost-effective as well. The tools
and frameworks and APIs are a good reason for selecting to learn Java.
 Platform independent
Java’s tagline says it all- “write once, run anywhere”. It supports cross-
platform and can run on almost every platform. This is one of the reasons
Java is still in use to write applications for Linux and Windows
environments.

 Java is Portability – ‫ניידת قابلة للتنقل‬


What happens in java is, When you build it, it is compiled into a Byte code
(as opposed to machine code). And the java virtual machine(JVM) interprets
the Byte Code into an instruction that is understandable by the specific
architecture you the program is running on. There is JVM for every major
architecture and operating system so the code you write on windows will be
interpreted and run on MAC-OS or linux without any source level modification
by you. That is why Java is portable and that is where the Write Once Run
Everywhere
 Why do we need a framework for server-side development?
You can design and build a website by writing codes purely using programming
languages. It is possible but takes a longer time. It requires heavy coding
and takes a lot of effort. So, reduce the sheer amount of code written and
make coding for backend applications more simple and approachable, frameworks
are required. Frameworks provide tools, utilities, and libraries that
simplify the overall process of web development. Some of the bac8-end
frameworks offers the below mentioned features which gives them an edge over
the other frameworks as well coding purely with the programming language. --
> Spring boot

Spring- The most famous framework for enterprise java, it is used to create
high functioning, reusable code in java. It is lightweight and can be used to
write any java application.

Spring boot- SpringBoot is a framework built on the Spring framework. It is a


good choice for those who use java as the language of server is written. It
is easy to create applications that runs by itself. It is best for web
applications that are scalable, and large. It is an ideal solution for those
cloud based projects.

 We can build an application without server side-BackEnd- just front end with
the data base , so we can use that when we don’t need to do a lot of
calculations.
 It can be more than server-side – why ?

Data Base

 Data Base – ‫אמצעי לאחסון של נתונים בתוך המחשב בצורה מסודרת ועקבית‬the application development
universe that are Mongo DB & MySQL. Mongo DB is a document-oriented NoSQL
database & MySQL is a relational database.
 DBMS(DATABASE MANAGEMENT SYSTEM) - ( Oracle,NoSQL -> MongoDB, MYSQL..)
‫ – מערכת תוכנה לניהל בסיס נתונים‬client side
‫מקשר בין מסד הנתונים המכיל נתונים גולמיים לבין האפליקציה שצריכה את הנתונים‬
creating and managing databases. The DBMS provides users and programmers with
a systematic way to create, retrieve, update and manage data.

JDBC stands for Java Database Connectivity. It is an API that allows to


connect and execute query to a database.
What is Maven?
helps to organize your project and provide support to build and deploy Java
projects
Maven is a "build management tool", it
is for defining how your .java files get
compiled to .class, packaged into .jar
(or .war or .ear) files,
(pre/post)processed with tools, managing
your CLASSPATH, and all others sorts of
tasks that are required to build your
project. It is similar to Apache Ant or
Gradle or Makefiles in C/C++, but it
attempts to be completely self-contained
in it that you shouldn't need any
additional tools or scripts by
incorporating other common tasks like
downloading & installing necessary libraries etc.

Wars & ears is like compression my code

It not only provides a Maven central library to organize all third-party Java
JAR files but also downloads the dependency for any Java project
automatically at the build time. Which means you don’t need to manually
download your JAR files and deal with several errors related to version
mismatch e.g. UnsupportedClassVersionError.

For example, if your project is dependent on Spring 5 then it will not only
download the Spring 5 JAR files from maven central library but also all
dependent JARs required by Spring itself. This is known as transitive
dependency management.

Monolithic applications
is built as a single unit. Enterprise Applications are built
in three parts: a database (consisting of many tables usually
in a relational database management system), a client-side
user interface (consisting of HTML pages and/or JavaScript
running in a browser), and a server-side application.
 So which app give me the app.ear from the app.java ?
Maven (build tools)
Example : person.java - > compiled to person.class and all this in
archives ‫ קיבוץ‬to person.ear
 In app.ear there is .war files and .jar files
 So there is 2 container’s – (web container and Business container) only and
the one database for both.
 The first container is for .war’s
o a WAR file is an archive that contains all the parts of a web application:
Java class files for servlets and web services, JSPs, HTML pages, images, and
other resources. The WAR file is simply a JAR file (which is itself a fancy
ZIP file) with specified directories for the Java code and one designated
configuration file: the web.xml file, which tells the application server what
to run and how to run it. WAR files always have the extension .war, but they
can be created and read with the standard jar tool.
o Security and Authentication
One of the most powerful features of web app deployment with the Servlet API
is the ability to define declarative security constraints, meaning that you
can spell out in the web.xml file exactly which areas of your web app (URL
paths to documents, directories, servlets, etc.) are login-protected, the
types of users allowed access to them, and the class of security protocol
required for communications. It is not necessary to write code in your
servlets to implement these basic security procedures.\

 The second is for .jar’s – (is like Put Jar file into a folder and package as
zip).
 For each specific .war there is specific .jar
 The request come from the http server\restAPI in form (.xml\Jason) and the
.war can deal with it and change it to java form and send it to the .jar that
belongs to him.
‫ שהיא פורמט‬XML ‫ שהיא בכלל בשפת סי או רוביץ על ידי קבצי‬request ‫ יודע לדבר עם ה‬WAR ‫בקצרה איך קובץ‬
‫ וה‬XML ‫ לכן ה ריקויסט שולח קובץ מה הוא רוצה ב‬.XML ‫הכתובה על ידי תגיות כך שכל השפות שבעולם מוסכם שהם יודעים‬
.JAVA CODE ‫ יודע מה הוא רוצה ומעביר אותו ל‬WAR

‫ כך שהוא יודע לקחת קובץ‬HTTP ‫ וה ריקויסט נשלח על ידי פרוטוקול ה תקשורת‬CUNSUMER ‫ בנויה ב‬REQUEST.XML
‫ ומעביר אותו לצד הנכון‬XML

JAR ‫ ובכך הוא יש לו את הריקויסט בגאווה ויכול לשלוח ל‬XML ->.JAVA. ‫ עושה לו תרגום מ‬, WAR ‫ מגיע ל‬XML ‫הקובץ‬
‫ על תנאי‬DB ‫ יכול לבצע את הפעולה או את הבקשה ואם מבוקש ממנו לקחת משהו או לעדכן משהוא ב‬JAR ‫ ובכך קובץ‬,‫הנכון‬
.‫ לכן הוא עושה‬DB ‫רק שיש לו אישור לגשת ל‬

 So, what if the request from(http\restApi) is in java form ? ,


RMI Remote-Method-Invocation ‫ דרך טכנולוגיה השם שלה‬, WAR ‫ ישירות בלי צורך ל‬JAR ‫אני יכול לקרוא ל‬
! ‫אבל‬
.JAVA ‫ כאילו היא לא שפת‬WAR ‫ אני חייב לעבור דרך ה‬THIERD PARTY ‫אם האפליקצייה שמבקשת ה ריקוויסט היא‬
? ‫למה‬
‫ כי ברגע שאני‬,‫ מטעמי בטיחות (אבטחת קוד) אני לא רוצה לחשוף לה את הקוד שלי‬,‫כי היא שפה חיצונית לא קשורה לחברה שלי‬
.‫ בעיקרון יש לו את כל הקוד‬JAR ‫נותן לה את הגישה ל‬
 What is difference between ear and war file?
Web Archives (WAR) WAR files are similar to JAR files, except that they are
specifically for web applications made from Servlets, JSPs, and supporting
classes. Enterprise Archives (EAR) ”An EAR file contains all of the
components that make up a particular J2EE application.
Strengths of the Monolithic Architecture

 Less cross-cutting concerns. Cross-cutting concerns are the concerns


that affect the whole application such as logging, handling, caching, and
performance monitoring. In a monolithic application, this area of
functionality concerns only one application so it is easier to handle it.
 Easier debugging and testing. In contrast to the microservices
architecture, monolithic applications are much easier to debug and test.
Since a monolithic app is a single indivisible unit, you can run end-to-end
testing much faster.
 Simple to deploy. Another advantage associated with the simplicity of
monolithic apps is easier deployment. When it comes to monolithic
applications, you do not have to handle many deployments – just one file or
directory.
 Simple to develop. As long as the monolithic approach is a standard way
of building applications, any engineering team has the right knowledge and
capabilities to develop a monolithic application.

Weaknesses of the Monolithic Architecture

 Understanding. When a monolithic application scales up, it becomes too


complicated to understand. Also, a complex system of code within one
application is hard to manage.
 Making changes. It is harder to implement changes in such a large and
complex application with highly tight coupling. Any code change affects the
whole system so it has to be thoroughly coordinated. This makes the overall
development process much longer.
 Scalability. You cannot scale components independently, only the whole
application.
 New technology barriers. It is extremely problematic to apply a new
technology in a monolithic application because then the entire application
has to be rewritten.

‫ מה קורה לאפליקצייה שלי ?< היא לא עולה‬,JAR ‫אם יש בעייה באחד מקבצי ה‬ 
‫גאריים לפני שהוא מעלה‬.‫ ברמה קלאסיים‬VALIDATION ‫ עושה‬APPLICATION SERVER ‫למה ? כי ה‬ 
..JAR ‫ שיש שגיאה ב‬EXEPTION ‫ > זורק‬- ‫האפליקצייה‬

Microservices

While a monolithic application is a


single unified unit, a microservices
architecture breaks it down into a
collection of smaller independent
units. These units carry out every application process as a separate service.
So all the services have their own logic and the database as well as perform
the specific functions.

In short, the microservice architectural style  is an approach to developing


a single application as a suite of small services, each running in its own
process and communicating with lightweight mechanisms, often an HTTP resource
API.
Martin Fowler

Within a microservices architecture, the entire functionality is split up


into independently deployable modules which communicate with each other
through defined methods called APIs (Application Programming Interfaces).
Each service covers its own scope and can be updated, deployed, and scaled

independently.

‫ כלומר‬, DOCKER ‫ בתוך ה‬REST API ‫ הפך עכשיו ל‬MONOLITHIC ‫ ב‬WAR ‫ בעיקרון מה שהיא התפקיד של ה‬: ‫בתמונה‬
DB ‫ – וה‬XML. ‫ ספציפי שאחראי על האבטחת קוד שלו ועל התרגום – דרך‬JAR‫ ששייך ל‬API ‫ את‬DOCKER ‫יש לנו בתוך ה‬
.‫ששייכת לו‬

! ‫ גם‬DB ‫ וייתכן שכפול ב‬DB ‫ייתכן שאין לו‬

Strengths of the Microservice Architecture

 Independent components. Firstly, all the services can be deployed and


updated independently, which gives more flexibility. Secondly, a bug in one
microservice has an impact only on a particular service and does not
influence the entire application. Also, it is much easier to add new features
to a microservice application than a monolithic one.
 Easier understanding. Split up into smaller and simpler components, a
microservice application is easier to understand and manage. You just
concentrate on a specific service that is related to a business goal you
have.
 Better scalability. Another advantage of the microservices approach is
that each element can be scaled independently. So the entire process is more
cost- and time-effective than with monoliths when the whole application has
to be scaled even if there is no need in it. In addition, every monolith has
limits in terms of scalability, so the more users you acquire, the more
problems you have with your monolith. Therefore, many companies, end up
rebuilding their monolithic architectures.

For instance, our partner Currencycloud needed to migrate to microservices


due to the growing number of transactions their platform processed. Founded
in 2012, the company offers a global B2B payments platform. Initially, their
monolithic architecture could handle the number of transactions they had. Yet
with the company’s growing success, they needed a more efficient solution
they could scale even further in the future. So they have switched to
microservices.

 Flexibility in choosing the technology. The engineering teams are not


limited by the technology chosen from the start. They are free to apply
various technologies and frameworks for each microservice.
 The higher level of agility. Any fault in a microservices application
affects only a particular service and not the whole solution. So all the
changes and experiments are implemented with lower risks and fewer errors.

Weaknesses of the Microservice Architecture

 Extra complexity. Since a microservices architecture is a distributed


system, you have to choose and set up the connections between all the modules
and databases. Also, as long as such an application includes independent
services, all of them have to be deployed independently.
 System distribution. A microservices architecture is a complex system
of multiple modules and databases so all the connections have to be handled
carefully.
 Cross-cutting concerns. When creating a microservices application, you
will have to deal with a number of cross-cutting concerns. They include
externalized configuration, logging, metrics, health checks, and others.
 Testing. A multitude of independently deployable components makes
testing a microservices-based solution much harder.

So which software architecture suits your solution and your business best?
Choosing a monolithic architecture

 Small team. If you are a start-up and your team is small, you may not
need to deal with the complexity of the microservices architecture. A
monolith can meet all your business needs so there is no emergency to follow
the hype and start with microservices.
 A simple application. Small applications which do not demand much
business logic, superior scalability, and flexibility work better with
monolithic architectures.
 No microservices expertise. Microservices require profound expertise to
work well and bring business value. If you want to start a microservices
application from scratch with no technical expertise in it, most probably, it
will not pay off.
 Quick launch. If you want to develop your application and launch it as
soon as possible, a monolithic model is the best choice. It works well when
you aim to spend less initially and validate your business idea.

Choosing a microservices architecture

 Microservices expertise. Without proper skills and knowledge, building


a microservice application is extremely risky. Still, just having the
architecture knowledge is not enough. You need to have DevOps and Containers
experts since the concepts are tightly coupled with microservices. Also,
domain modelling expertise is a must. Dealing with microservices means
splitting the system into separate functionalities and dividing
responsibilities.
 A complex and scalable application. The microservices architecture will
make scaling and adding new capabilities to your application much easier. So
if you plan to develop a large application with multiple modules and user
journeys, a microservice pattern would be the best way to handle it.
 Enough engineering skills. Since a microservice project comprises
multiple teams responsible for multiple services, you need to have enough
resources to handle all the processes.

Afterword

Adopting a microservices architecture is not a one-size-fits-all approach.


Despite being less and less popular, a monolith has its strong and durable
advantages which work better for many use cases.

If your business idea is fresh and you want to validate it, you should start
with a monolith. With a small engineering team aiming to develop a simple and
lightweight application, there is no need to implement microservices. This
way, a monolithic application will be much easier to build, make changes,
deploy, and provide testing.

The microservices architecture is more beneficial for complex and evolving


applications. It offers effective solutions for handling a complicated system
of different functions and services within one application. Microservices are
ideal when it comes to the platforms covering many user journeys and
workflows. But without proper microservices expertise, applying this model
would be impossible. 

If your development team does not have the microservices expertise, you can
find a software development partner with hands-on experience in building a
microservices architecture. Many successful tech companies already outsource
their microservices development to the foreign IT vendors. If you consider
following their strategy, just contact our experts to learn the details.

You might also like