Skip to content

hsnKET/microservices-consul

Repository files navigation

Microservices Architectures with (Spring Cloud Config, Consul Discovery, Consul Config,Vault)

Project Architecture

image

Project Structure

image

Consul

Consul is a powerful service networking tool that enables services to discover and connect with each other.

  • To start the Consul server, you can use the following command:
consul agent -server -bootstrap-expect=1 -data-dir=DATA_FOLDER_HERE -ui -bind=YOUR_IP_HERE

My Result

image

Gateway Service

Start up point

@SpringBootApplication
public class GatewaysServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(GatewaysServiceApplication.class,args);
    }

    @Bean
    DiscoveryClientRouteDefinitionLocator locator(ReactiveDiscoveryClient rdc, DiscoveryLocatorProperties dlp){
        return new DiscoveryClientRouteDefinitionLocator(rdc,dlp);
    }

}

Configuration File

contains config-service and CORS configuration

server:
  port: 9999
spring:
  application:
    name: gateway-service
  config:
    import: optional:configserver:http://localhost:5544
  cloud:
    gateway:
      globalcors:
        cors-configurations:
          '[/**]':
            allowedOrigins: "http://localhost:4200"
            allowedHeaders: "*"
            allowedMethods:
              - GET
              - POST
              - DELETE
              - PUT

Test

order-servie

image

customer-servie

image

inventory-serivce

image

billing-serivce

image

Config Service

This service provides us ability to stores configuration data in a version control system Git, and allows other services to retrieve this data from it at runtime.

server:
  port: 5544
spring:
  application:
    name: config-service
  cloud:
    config:
      server:
        git:
          uri: REPO_PATH
          default-label: master

Test

test customer-service simple configuration

image

Customer Service

Project Structure

image

Test

image

Inventory Service

Project Structure

image

Configuration

server:
  port: 8787
spring:
  application:
    name: order-service
  h2:
    console:
      enabled: true
  datasource:
    url: jdbc:h2:mem:orders-db
  #
  config:
    import: optional:configserver:http://localhost:5544
logging:
  level:
    me.ketlas.orderservice.services.CustomerRestClientService: debug
    me.ketlas.orderservice.services.ProductRestClientService: debug

Test

image

Order Service

Project Structure

image

Test

image

Billing Service

Project Structure

image

Test

image

FrontEnd

Project Structure

image

Products List

image

Customers List

image

Customer Orders List

image

Order Details

image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors