{"id":19595400,"url":"https://github.com/meta-magic/microservice-sample","last_synced_at":"2026-06-11T06:31:14.301Z","repository":{"id":100692333,"uuid":"82802384","full_name":"meta-magic/microservice-sample","owner":"meta-magic","description":null,"archived":false,"fork":false,"pushed_at":"2017-02-23T15:14:15.000Z","size":111,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-26T14:25:40.585Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meta-magic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-22T12:35:17.000Z","updated_at":"2017-02-22T12:39:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"dfeed4fd-5ecb-4321-913a-dd530e62490f","html_url":"https://github.com/meta-magic/microservice-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/meta-magic/microservice-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meta-magic%2Fmicroservice-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meta-magic%2Fmicroservice-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meta-magic%2Fmicroservice-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meta-magic%2Fmicroservice-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meta-magic","download_url":"https://codeload.github.com/meta-magic/microservice-sample/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meta-magic%2Fmicroservice-sample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34186385,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T08:46:46.000Z","updated_at":"2026-06-11T06:31:14.285Z","avatar_url":"https://github.com/meta-magic.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# microservice-sample\n\nThis is a proof-of-concept application, which demonstrates [Microservice Architecture Pattern](http://martinfowler.com/microservices/) using Spring Boot, Spring Cloud, Spring Config.\n\n\u003chr/\u003e\n## Functional services\n\nDecomposed into two core microservices. All of them are independently deployable applications, organized around certain business capability.\n\n#### Login service\n\nMethod: POST\u003cbr/\u003e\nPath : /authenticate\u003cbr/\u003e\nDescription: Validate userid password.\u003cbr/\u003e\nCurl Command: curl -H \"Content-Type: application/json\" -X POST -d '{\"loginId\":\"xyz\",\"password\":\"xyz\"}' http://localhost:1112/loginservice/authenticate\u003cbr/\u003e\n\nNote: Business logic is hard coded, If userid/password are sample its authenticated.\n\n\u003chr/\u003e\n\n## Edge Server\n\nThis is entry point to outside world.\n\nIn theory, a client could make requests to each of the microservices directly. But obviously, there are challenges and limitations with this option, like necessity to know all endpoints addresses, perform http request for each peace of information separately, merge the result on a client side. Another problem is non web-friendly protocols, which might be used on the backend.\n\nIt can be used for authentication, insights, stress and canary testing, service migration, static response handling, active traffic management.\n\n\u003cb\u003eWith Spring Cloud we can enable it with one @EnableZuulProxy annotation\u003c/b\u003e\n\n@EnableZuulProxy\npublic class Config {\n}\n\n\u003cb\u003eRoute requests to appropriate microservices, defined in application.properties\u003c/b\u003e \n\nzuul.prefix=/api\u003cbr/\u003e\nzuul.ignoredServices='*'\u003cbr/\u003e\nzuul.routes.auth-service.path=/auth-service/**\u003cbr/\u003e\nzuul.routes.auth-service.serviceId=AUTH-SERVICE\u003cbr/\u003e\nzuul.ribbon.restclient.enabled=true\u003cbr/\u003e\nhystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=60000\u003cbr/\u003e\n\nNote: Detail code for edge server can be found in edge-server project\n\u003chr\u003e\n\n## Service Discovery\n\nThe key part of Service discovery is Registry. I use Netflix Eureka in this project. Eureka is a good example of the client-side discovery pattern, when client is responsible for determining locations of available service instances (using Registry server) and load balancing requests across them.\n\nWith Spring Boot, you can easily build Eureka Registry with spring-cloud-starter-eureka-server dependency, @EnableEurekaServer annotation and simple configuration properties.\n\n@EnableEurekaServer\n@SpringBootApplication\npublic class EurekaServerApplication {\n\n\tpublic static void main(String[] args) {\n\t\tSpringApplication.run(EurekaServerApplication.class, args);\n\t}\n}\n\nEvery service will get register to Eureka server on its starup and provide all required info like URL, Host etc.\n\napplication.properties for eureka server.\n\nspring.application.name=eureka-service\u003cbr/\u003e\nserver.port=1111\u003cbr/\u003e\neureka.instance.client.register-with-eureka=false\u003cbr/\u003e\neureka.instance.client.fetch-registry=false\u003cbr/\u003e\nlogging.level.com.netflix.eureka=OFF\u003cbr/\u003e\nlogging.level.com.netflix.discover=OFF\u003cbr/\u003e\n\nNote: Detail code for eureka server can be found in eureka-server project\n\n\u003chr/\u003e\n\n##Load balancer, Circuit breaker and Http client\n\n####Ribbon\n\nRibbon is a client side load balancer which gives you a lot of control over the behaviour of HTTP and TCP clients. Compared to a traditional load balancer, there is no need in additional hop for every over-the-wire invocation - you can contact desired service directly.\n\nOut of the box, it natively integrates with Spring Cloud and Service Discovery. Eureka Client provides a dynamic list of available servers so Ribbon could balance between them.\n\n####Hystrix\n\nHystrix is the implementation of Circuit Breaker pattern, which gives a control over latency and failure from dependencies accessed over the network. The main idea is to stop cascading failures in a distributed environment with a large number of microservices. That helps to fail fast and recover as soon as possible - important aspects of fault-tolerant systems that self-heal.\n\nBesides circuit breaker control, with Hystrix you can add a fallback method that will be called to obtain a default value in case the main command fails.\n\n####Feign\n\nFeign is a declarative Http client, which seamlessly integrates with Ribbon and Hystrix. Actually, with one spring-cloud-starter-feign dependency and @EnableFeignClients annotation you have a full set of Load balancer, Circuit breaker and Http client with sensible ready-to-go default configuration.\n\npublic interface LoginService {\u003cbr/\u003e\n\t@RequestMapping(value=\"/authenticate\", method=RequestMethod.POST, produces=\"application/json\")\u003cbr/\u003e\n\tpublic MessageWrapper\u003cObject\u003e authenticate(@RequestBody Object loginBean);\u003cbr/\u003e\n}\u003cbr/\u003e\n\n@FeignClient(value=\"login-service\", fallback=LoginServiceFallBack.class)\u003cbr/\u003e\npublic interface LoginServiceClient extends LoginService\u003cbr/\u003e\n{\u003cbr/\u003e\n}\u003cbr/\u003e\n\nNOTE: PLEASE LOOK INTO AUTH-CLIENT PROJECT FOR FEIGN\u003cbr/\u003e\n\n\n\u003chr\u003e\n\n## Notes\nOnce you download code and its setup in standard ID starts the application in following sequence.\n\n1 - Eureka Server - You might get error at console saying replica server is not configure, we can ignore for development purpose.\u003cbr/\u003e\n2 - Login Service\u003cbr/\u003e\n3 - Auth Client\u003cbr/\u003e\n4 - Edge Server\u003cbr/\u003e\n\nUse following curl command to test\u003cbr/\u003e\n\ncurl -H \"Content-Type: application/json\" -X POST -d '{\"loginId\":\"xyz\",\"password\":\"xyssssz\"}' http://localhost:1114/api/auth-service/login/authenticate\u003cbr/\u003e\n\ncurl -H \"Content-Type: application/json\" -X POST -d '{\"loginId\":\"xyz\",\"password\":\"xyz\"}' http://localhost:1114/api/auth-service/login/authenticate\u003cbr/\u003e\n\nIf you want to check FALLBACK mechanism, stop login/token service and execute above commands again.\u003cbr/\u003e\n\nOnce fallback scenario is tested start the login/token service and execute above commands. Wait for 1 Minute once server are started as hystrix default isolation for thread is set to 1min.\n\n\u003chr/\u003e\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeta-magic%2Fmicroservice-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeta-magic%2Fmicroservice-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeta-magic%2Fmicroservice-sample/lists"}