2 Replies Latest reply on Jun 13, 2020 11:52 AM by SASWATA MANDAL

    Implementing MicroServices in REST CRUD App

    SASWATA MANDAL

      Hi Experts ,

       

           I have a simple REST CRUD Application for EmployeeManagement . The App has :-

       

      1) EmployeeManagement.jsp :- This allows to Add, Update, Delete and Show employee details .

      2) EmployeeList.jsp :-  This shows a list of all employees present in the DB.

      3) Employee.java :- POJO class to hold employee details

      4) EmployeeDao.java :- Class to perform all employee related DB operations , like addEmployee() , getEmployee() , updateEmp() , getAllEmployees() , deleteEmp().

      5) EmployeeService.java :- Service class that listens request from EmployeeManagement.jsp and calls the specific method of EmployeeDao.java.

       

      Microservice architecture is not implemented in this application as the EmployeeService.java service class handles all the CRUD requests from the EmployeeManagement.jsp.

      I am new to Java Microservices and want to implement Microservice Architecture in this simple EmployeeManagement  application.

       

      Please suggest how can I implement microservice concept in the application.

       

      Thanks & Regards

      Saswata Mandal 

        • 1. Re: Implementing MicroServices in REST CRUD App
          SASWATA MANDAL

          Hi Experts ,  The EmployeeService.java that listens the REST calls from EmployeeManagement.jsp , has the four methods for the employee CRUD operations :-

           

          @Path("/EmployeeService")

          public class EmployeeService

          {

             @GET

             @Path("/employees")  

             public void getEmployees(@Context HttpServletResponse response, @Context HttpServletRequest request)   {  }

           

             @GET

             @Path("/employee/{empid}")  

             public void getEmployee(@PathParam("empid") int empid,@Context HttpServletResponse response, @Context HttpServletRequest request)   {  }

           

             @POST

             @Path("/add")

             public void createEmployee(@FormParam("id") int id, @FormParam("name") String name, @FormParam("skill") String skill, @Context HttpServletResponse response, @Context HttpServletRequest request)   {   }

           

             @POST

             @Path("/employee/{empid}")

             public void updateEmployee(@PathParam("empid") int id, @FormParam("name") String name, @FormParam("skill") String skill,@Context HttpServletResponse response, @Context HttpServletRequest request)   {   }

            

             @POST

             @Path("/employee/delete/{empid}")

             public void deleteEmployee(@PathParam("empid") int empid, @Context HttpServletResponse response, @Context HttpServletRequest request)    {   }

          }

           

          If I keep these 4 methods in 4 separate service classes instead of 1 , will that implement Microservice Architecture ??

           

          Thanks & Regards

          Saswata Mandal

          • 2. Re: Implementing MicroServices in REST CRUD App
            SASWATA MANDAL

            Hi Experts , Please suggest !!