Code Monkey home page Code Monkey logo

service-gateway-bootless's Introduction

Spring MVC + Spring Data + Apache Camel (Service Gateway Using Eureka)

In this demo you see how we can use Apache Camel alongside Eureka Service Discovery in order to implement a service gateway in a Spring MVC environment (Boot-less). You are able to map eureka services with custom context paths and relegate the requests come to camel, to the appropriate eureka service. So, basically you just know about camel and are able to send requests to it and in the back-end, camel relegate your request to the appropriate eureka-service and then return the response to you.

Libraries and Tools

  • [Framework] Spring MVC
  • [Integration Framework] Apache Camel which uses Spark Java for REST API
  • [ORM] Hibernate under abstraction of Spring Data JPA
  • [Database] Oracle on port 1521

Prerequisite

In order to test this demo you should already have the followings:

  • An Oracle database connection and consequently changing database.properties for it. In addition you should update enums/Schema.java file with your schema name

  • An Eureka server starting for registry/discovery of services. In this case you can use other repository of mine named service-gateway and just start config-server, eureka-server and account-service modules in order. This will start an Eureka server on localhost:8090 and registers a REST service named account-service on it. In case you want to change the Eureka port, you should update eureka.properties file with your own configs.

  • Port 8089 should be open for camel REST API. You are able to configure it in application.properties file.

How to run

You need to run this demo on a tomcat server. For the rest of the article lets assume this demo is started on localhost:8082.

How it works

  • To get all the services: Http.GET to http://localhost:8082/service-gateway/services
  • To add a mapping for a pair of context path and eureka service: Http.POST to http://localhost:8082/service-gateway/services with the following json as request body:
{
    "contextPath": "accounts",
    "eurekaServiceName": "account-service",
    "eurekaServiceStatusEntity": {
        "id": 1,
        "eurekaServiceStatusType": "PUBLISHED",
        "description": "published status"
    },
    "subSystemCategoryEntity": {
        "id": 1,
        "subSystemCategoryType": "ARZI",
        "description": "arzi category"
    }
}

After adding the mapping of accounts context path for account-service eureka service, you are able to call camel with Http.GET on http://localhost:8089/services/accounts to get the list of accounts comes from account-service eureka service.

service-gateway-bootless's People

Contributors

hamedmirzaei avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.