I would like to introduce a recommended library to use when implementing microservices in Java
.
This time, I selected the library based on the following three points.
RESTful API
microservices that send and receive via HTTP
Spark Framework
Gson / Jackson
Since microservices operate in cooperation with multiple services, messages are exchanged. In that case, format conversion is important.
I think that there are many conversions between Java
(object) and Json
, but Gson is often used (supported) in other libraries. gson) and Jackson.
Whichever you like, please.
However, for example, a library uses Jackson
as a stack (it has a dependency), but using Gson
includes two types of libraries for the same purpose (format conversion). It is not preferable because it becomes. Looking at the stack as a whole, you should select Jackson
in this case.
Bean Validation
Bean Validation (JSR-303)
that checks the input by adding a special annotation is easy.
Since Bean Validation
is a specification, an implementation library is required to use it.
Hibernate-validator is a well-known implementation library, so we recommend that you use it.
**(Caution)
When running on a Java EE
server, you have the option of not using hibernate-validator
because the implementation of Bean Validation
is also on the server.
This time, we are introducing hibernate-validator
in consideration of microservices that can be operated even in a normal Java process. ** **
(Added 6/10/2018)
Sql2o
Feign
Jedis
I think that the number of cases where KVS (Key Value Store)
is used as a cache has increased.
The most commonly used of KVS
is Redis
, and the famous Java client is Jedis.
Paho
Paho is a well-known client of MQTT
.
We provide libraries for various programming languages such as Java, .net (C #, VB.net), Python
, etc.
(I also use Paho
when using MQTT
in programming languages other than Java
)
Recommended Posts