I am new to gRPC and I am building a microservice application using Spring Boot. The plan is to use gRPC to create shared entity classes across the microservices. I would like to ask, are the classes generated by gRPC annotated with #Entity annotation and other JPA annotations?
If the above is possible, will I also be able to selectively choose to exclude the JPA annotations? this is because some microservices do not need the entity of other microservices.
Furthermore, what are the best practices for gRPC in Spring Boot? E.g. the libraries available etc.
Related
I already have an application using Java EE deployed in Glassfish and I want to add multi-tenancy so that it can support many tenants.
I'm using the following technologies: EJB, JPA (EclipseLink) and JSF
during my research I found three approaches for managing multi-tenant data (persistence layer):
Separate databases
Shared Database, Separate Schemas
Shared Database, Shared Schema
Which approach do you recommand and how can other layers be affected by multi-tenance?
I want to implement Container Managed persistence using Websphere and OpenJPA.
Can anyone provide some insights ?
Is there a way to achieve this without using EJB3 or Spring ?
EJBs and Spring (along with some other Dependency Injection frameworks like Google Guice) implement the Container Managed EntityManager. If you don't want to use the technology that provides the hooks for the container to handle the transactions and entity managers for you, then you would have to roll your own which is the application managed route.
I am new to spring RESTful web services. can anyone tell me how to create RESTful web services in spring with annotations and what all jars to be included in the project? also how do i test it whether my web service is working fine. do we have a small demo example which serves the same purpose.
http://www.mkyong.com/spring-mvc/spring-3-rest-hello-world-example/ is a very good and useful tutorial. It goes through how to set up the Spring MVC project from scratch using Maven as your build tool and then it goes through a Spring MVC controller that uses the URL to perform REStful Web Services. Although it may seem small, the tutorial is very useful in getting you started and provides you with a platform to carry out more complex tasks. The following reference may be useful as a reference. http://static.springsource.org/spring/docs/3.0.0.M3/reference/html/ch18s02.html
I have implemented a RESTful web service using jersey and deployed it on Tomcat, I have used DAO classes to manipulate database operations, entities to wrap database records. and did the processing in separate package. I want to make this system distributed using EJB. First of all would it be easy to do this change. or i need to rewrite things from scratch. Second, I still need to have the REST WS, so would it be possible to expose the EJB as a REST WS and how? would the REST WS be in the same EJB project or in a different one?
You can definitely do it as an EJB and REST WS. Upgrade your Tomcat install to TomEE Plus, then just add #Stateless or #Singleton to the existing REST service.
You won't need Jersey in there anymore as the Java EE version of Tomcat (TomEE) includes CXF for JAX-RS support.
This example is not well documented, but shows a functional application that combines both EJB and JAX-RS.
http://tomee.apache.org/examples-trunk/rest-on-ejb/README.html
Had anybody attempted to use MyBatis as their persistence library for a JBoss 7.1 /Java EE6 application?
I'm wondering what are the best approaches to handling connections, transations, rollbacks etc?
How about CDI support? Looking around online it seems at this time MyBatis only supports two Dependency Injection (JSR-330) frameworks, Google Guice and Spring. I did run into CDI Extensions which may be something look into.
My idea would be to have the container handle all of the above however it may be difficult getting to that point.
Any tips, hints, experiences?
There is a new mybatis-cdi module. It is not released yet, but you can try the snapshot, it is at github: https://github.com/mybatis/cdi
There is no CDI support at all but as you said, if you want DI go Spring or Guice.
With JBoss you have mainly two chances:
- EJB 3
- Spring
If using EJB 3 transactions are handled automatically by them. MyBatis just ignores transactions and lets the container commit/rollback.
When using Spring, MyBatis ties to Spring transactions using the integration module MyBatis-Spring.
I would create my own CDI bean - use #Produces for a factory, and #Inject to get the session.
Here is old iBatis Spring factory, that might be the producer, after some changes:
SqlMapClientFactoryBean