Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is correct path for creation of micro services in Java? Spring Boot or OSGI

I found a book "Spring DM in action". When I started to check the latest release of Spring for OSGI, I found out that Spring has discontinued this project.

As I have some experience of developing in Spring, I would like to understand should I continue to read about Spring and OSGI or switch to Spring Boot as way of creating modular applications?

like image 476
Valters Rostoks Avatar asked Mar 02 '15 10:03

Valters Rostoks


People also ask

Is spring boot used only for microservices?

Spring Boot in itself has nothing to do with microservices. It's a Spring module which simply makes the configuration of your app easier. As such, it absolutely can be used in a monolithic app.

Is spring boot and microservices same?

Spring Boot is an open-source Java-based framework used to create microservices and production-ready standalone Spring MVC applications.

What is difference between spring boot and spring Cloud?

Spring Boot is a Java-based open-source framework for developing services. Its major goal is to cut down on development and testing time. Their apps don't need as much Spring setup as other Spring applications. Spring Cloud is a tool for centralizing form management.


2 Answers

I've wanted to write a comment, but it didn't give me enough characters.

If you need the modularization and dynamic of OSGi, spring DM (now Gemini Blueprint) is a nice technology. We used it to create a high performance message oriented middleware with a plugin-infrastructure. The plugin-infrastructure was needed, cause the customer wanted to be able to add/replace/update modules and change routes via a web-interface at runtime. Each message also was transformed via 0-N groovy-scripts (stored in db, changeable on runtime). The processing engine was based on spring batch and spring integration.

So if you have a real use cases for OSGi, it can be a nice technology.

But most of the time people tried to use it, to separate the layers of a monolithic webapplication, which is not useful and gives you more work than profit. Once i saw an approach where a developer used OSGi to separate each group of his domain-model into a small module. This harms your application-design more than you can profit from, cause the profit is null.

Also, the book might be a nice idea to give you a different approach on "how to develop" software.

like image 151
Martin Baumgartner Avatar answered Oct 01 '22 23:10

Martin Baumgartner


to the title question: "OSGi" for sure. An OSGi service is a very (the most?) natural candidate for the microservice moniker.

to the content of your post:

I have to jump in here, and say "both." OSGi, IMHO, is the best thing to happen to Java, since... well, maybe ever. Why? It begs you to follow better design practices, by facilitating the production of smaller, more modular pieces of code.

I love spring-boot as well, but I find it more suited to (read, "awesome for") writing client-side applications.

To the point about your experience with Spring--don't be afraid. If you're accustomed to spring XML configurations, you'll find that the blueprint syntax is, in most cases, identical... and you can still make extensive use of the various spring pieces within an OSGi-leveraging system.

FYI - I'm speaking from the standpoint of having developed several large-scale systems rooted in OSGi (and also a few forays into the wilds of the typical WAR/servlet deployments)

like image 25
Hans Avatar answered Oct 02 '22 01:10

Hans