DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Data Engineering
  3. Data
  4. Why It's Better to Trust in Java EE

Why It's Better to Trust in Java EE

While microservices are getting all the attention nowadays, it's still worthwhile to look to Java EE for architectural inspiration.

Ralph Soika user avatar by
Ralph Soika
·
Sep. 07, 16 · Opinion
Like (59)
Save
Tweet
Share
20.86K Views

Join the DZone community and get the full member experience.

Join For Free

These days it seems to me that everyone blabs about the blessing of microservices and the new architectural style. In most articles about the new glory architecture of microservices, it's generally assumed, that Java EE is slow, dull, and scales poorly. There seems to be a big misunderstanding about what Java EE really is. And I even assume that not many of the young believers in the new world of microservices have engaged much with the concepts of Java EE. I'm taking here three examples each developer is confronted with. And perhaps you will rethink these scenarios in light of Java EE.

Database Pooling

If you are developing an application, in most cases, you will access a database to read or store data. This can be done in Java by using a JDBC Database connection. Every database has a JDBC driver and it's quite easy to use them. But opening a new JDBC connection, selecting some records from the database, and finally closing the connection is a little bit of work in your code. And because those connections are expensive, it's a good idea to reuse them for multiple select or update statements if possible. This is called 'connection pooling', and if you are familiar with those concepts and know how to handle a pool of JDBC connections, you may be happy to implement your own connection manager. But if you are not so familiar with these concepts, you should take care. Or you can take a look at Java EE. A Java EE application server decouples the JDBC database connection from your code. If you need access to a database, you simply inject a JNDI database resource. This database resource is totally managed by the application server in a connection pool. Take a look at the following screen from the admin interface of Wildfly:

java_ee_microservice_01

You can not only manage the pool, but also the validation, timeout settings or the internal cache of shared prepared statements. So you can control in a fine grained way how your database connections should scale. I don't believe that the new practice "let's start a new instance of Tomcat" will be a comparable solution.

Services

The next use case is a simple code block implementing some business logic. Let's assume that this block of code performs a complex calculation which can sometimes take more or less time. Thus, we have the problem that one call with a long execution time blocks other calls. So what can we do? Yes of course we can start some more instances of our Tomcat server, but this is an expensive solution just for this case, and sometimes some calls may need a longer execution time. The other solution would be to build and manage a pool of services, where each service is implementing our business logic (we call this a factory pattern). We would be able to share those services between several calls without the need to re-instantiate them, and that is exactly why EJBs were invented. An EJB is a simple piece of code which is pooled and shared in a multithreaded runtime environment. Again, take a short look at one of the configuration pages of Wildfly:

java_ee_microservice_02

The EJB Container of an application server can be configured in various ways. You can configure the Bean and thread pools, and how these pools should work in a cluster. And there are several kind of EJB types to fit for various problems. So if you have complex business logic, a simple stateless session EJB can solve a lot of your problems of scalability — even if you are running only one instance of an application server.

Transaction

The last use case which I want to discuss here is the transaction management. This is one of the most complex problems in software development. If you have a HTTP request which needs one or more database connections, and has to perform different code blocks of business logic, it can become very hard to tie all things together in one isolated transaction. Transaction management is one of the core concepts of Java EE. It doesn't matter which kind of service EJB you need or what kind of JNDI resources are necessary. Every request can be managed by the server in one or many transactions also among different containers. For most software projects it is nearly impossible to address all the issues of isolation and atomic transactions and implement them in the right way. Again, take a look of one of the configuration pages of the transaction subsystem from Wildfly.

java_ee_microservice_03

Conclusion

So what is the message that I want to convey here? The development of a business application is a complex matter. Many small things must be respected in terms of performance and scalability. But this is known since the beginning of software development and it was not detected in the past two years. Java EE provides a platform to capture a large part of these problems. So just in case you are not the architect for Amazon, Netflix, or Facebook it is not automatically the best way to adapt their strategies. Microservices are a great idea, and I believe that it is worthwhile to package business logic into a single service, but this can happen in most cases also with the help of Java EE.

Java EE Java (programming language) Database connection IT Software development microservice application Application server

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Spring Boot vs Eclipse Micro Profile: Resident Set Size (RSS) and Time to First Request (TFR) Comparative
  • Multi-Cloud Integration
  • The 5 Books You Absolutely Must Read as an Engineering Manager
  • How To Handle Secrets in Docker

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: