Giter Site home page Giter Site logo

wuyichen24 / spring-microservices-in-action Goto Github PK

View Code? Open in Web Editor NEW
86.0 9.0 59.0 105.11 MB

The source code of the book "Spring Microservices in Action (John Carnell)" and the personal summary of technical essentials about Spring Boot for microservices.

License: Apache License 2.0

Java 99.79% Shell 0.21%
spring-boot microservices netflix-eureka netflix-zuul netflix-hystrix netflix-ribbon kafka redis netflix netflix-oss

spring-microservices-in-action's Introduction

spring-microservices-in-action

Build Status License

This repository contains the source code of the book "Spring Microservices in Action (John Carnell)" and the personal summary of technical essentials about Spring Boot for microservices.

Overview

This source code was re-organized by the original source code of the book and I make sure each module is runnable.

Structure

  • Servers
    • Config: Provide the configuration parameters for other services.
    • Eureka: Service discovery.
    • Zipkin: Collect tracing data.
    • Zuul: API gateway.
  • Services
    • Licensing: Manage (CRUD) license records.
    • Organization: Manage (CRUD) organization records.
    • Authentication: Issue and validate access tokens, manage clients' and users' credentials and roles.
    • Special Routes: Provide an alternate endpoint for a certain service.
  • Database: Store license and organization records, clients' and users' credentials, alternate routes of any service.
  • Message Queue (Kafka): Notify the licensing service about any organization record modification.
  • Cache (Redis): Cache any organization record which has been loaded before.
  • Log Server
    • Splunk: Collect log information in local.
    • Papertrail: Collect log information in cloud.

Technology Stack

Differences to The Original Source Code

  • Use Gradle as Java build automation tool rather than Maven.
  • Use MySQL as database rather than PostgreSQL.
  • Change the port of the organization service to 8060 to avoid the address conflict with the licensing service.
  • Change the port of the special routes service to 8040 to avoid the address conflict with the licensing service.
  • Change the port of the authentication service to 8901 to make it same with the example in the book.
  • Add the integration of Splunk for log aggregation locally (use both local Splunk and remote Papertrail).
  • Use the original functionality in Logback for sending the log to the log servers (Splunk & Papertrail) rather than the solution in the Book (use Logspout to direct the docker output to the log servers).
  • Replace the user_roles table by the authorities table for storing users' credentials to DB.
  • Change the column name from user_name to username for the user_orgs table and the users table.
  • Add comments to make the code easy to read.

Getting Started

Technical Essentials

Study Notes

spring-microservices-in-action's People

Contributors

wuyichen24 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-microservices-in-action's Issues

Create APIs for managing clients and users in authentication service

Create APIs for managing clients and users in the authentication service. like add, update, delete clients and users. and also encode passwords when add and update clients and users.

The API should be similar with licensing service and organization service for managing licenses and organizations.

java.lang.IllegalArgumentException: Not a managed type: class com.thoughtmechanix.licenses.model.License

When you start a service, it will throw an exception:

Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.thoughtmechanix.licenses.model.License
	at org.hibernate.jpa.internal.metamodel.MetamodelImpl.managedType(MetamodelImpl.java:210) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
	at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:71) ~[spring-data-jpa-1.11.18.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:68) ~[spring-data-jpa-1.11.18.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:184) ~[spring-data-jpa-1.11.18.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:117) ~[spring-data-jpa-1.11.18.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:99) ~[spring-data-jpa-1.11.18.RELEASE.jar:na]
	at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:198) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:277) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:263) ~[spring-data-commons-1.13.18.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:101) ~[spring-data-jpa-1.11.18.RELEASE.jar:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1689) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1627) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
	... 42 common frames omitted

java.lang.NoSuchMethodError: org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.<init>(Lorg/springframework/core/type/AnnotationMetadata;Ljava/lang/Class;Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/Environment;Lorg/springframework/beans/factory/support/BeanDefinitionRegistry;)V

When you start a service, it will throw an exception:

java.lang.NoSuchMethodError: org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.<init>(Lorg/springframework/core/type/AnnotationMetadata;Ljava/lang/Class;Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/Environment;Lorg/springframework/beans/factory/support/BeanDefinitionRegistry;)V
	at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport$1.<init>(AbstractRepositoryConfigurationSourceSupport.java:68) ~[spring-boot-autoconfigure-1.5.14.RELEASE.jar:1.5.14.RELEASE]
	at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.getConfigurationSource(AbstractRepositoryConfigurationSourceSupport.java:67) ~[spring-boot-autoconfigure-1.5.14.RELEASE.jar:1.5.14.RELEASE]
	at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions(AbstractRepositoryConfigurationSourceSupport.java:58) ~[spring-boot-autoconfigure-1.5.14.RELEASE.jar:1.5.14.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:360) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:320) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:272) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:92) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525) ~[spring-context-4.3.18.RELEASE.jar:4.3.18.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.14.RELEASE.jar:1.5.14.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.14.RELEASE.jar:1.5.14.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.14.RELEASE.jar:1.5.14.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.14.RELEASE.jar:1.5.14.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.14.RELEASE.jar:1.5.14.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.14.RELEASE.jar:1.5.14.RELEASE]
	at com.thoughtmechanix.organization.Application.main(Application.java:28) [bin/:na]

full log aggregation

Not only all services send log to splunk, also let splunk track the log of Kafka, Zookeeper, Redis

Errors in book

Correct: http://localhost:8080/v1/organizations/e254f8c-c442-4ebe-a82a-e2fc1d1ff78a/licenses/f3831f8c-c338-4ebe-a82a-e2fc1d1ff78a/rest
Wrong: http://localhost:8080/v1/organizations/e254f8c-c442-4ebe-a82a-e2fc1d1ff78a/licenses/f3831f8c-c338-4ebe-a82a-e2fc1d1ff78a
(This will not get organization record and also will not trigger Redis logic)

Document API

API Documentation Solutions

  • Swagger
  • RAML
  • API Blueprint
  • Apiary

Add javadoc on all java code

Finished module

  • authentication-service
  • authentication-service-jwt
  • config-server
  • eureka-server
  • licensing-service
  • organization-service
  • specialroutes-service
  • zipkin-server
  • zuul-server

How to pass the auth_token to downstream service which is requiring the access token

The organization service is protected. You can hit it only with an access token.

There are several cases for passing the access toke:

The zuul server need to route the service.

The licensing service needs to hit the organization service to retrieve relevant organization data.

Request for instructions to start the application

Hi ,

I did not find any instructions on how to build and start the application and test the application which is deployed on localhost environment. can you please kindly create a document which explain the details.

Thanks,
Herambha Kumar P

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.