JSCODE Logo
JSCODE 박재성JSCODE 제이온JSCODE 시니
과외유튜브블로그후기
완강 후기 이벤트블로그 리뷰 이벤트AWS SAA 합격 후기 이벤트
회사명 : JSCODE대표 : 박재성사업자 등록번호 : 244-22-01557통신판매업 : 제 2023-인천미추홀-0381 호

서울특별시 구로구 경인로 20가길 11(오류동, 아델리아)

Copyright ⓒ 2026 JSCODE - 최상위 현업 개발자들의 프로그래밍 교육 All rights reserved.

이용약관개인정보처리방침

비전공자도 이해할 수 있는 MSA 입문/실전

MSA 기본 개념

MSA를 왜 배워야할까?
MSA(Microservice Architecture)란?
MSA의 핵심 특징 / MSA의 독보적인 장점
언제 MSA를 도입하는 게 적절할까?
많은 사람들이 MSA가 어렵다고 착각하는 이유
MSA인지 아닌지를 판단하는 기준
MSA를 쉽고 빠르게 배우는 방법

기본적인 마이크로서비스 구축해보기

MSA 프로젝트 요구사항 및 설계
[실습] 각 Microservice에 해당하는 DB 서버 띄우기
[실습] User Microservice 만들기
[실습] Board Microservice 만들기
구현한 MSA 프로젝트를 잘 구현했는 지 전체적으로 검토하기

데이터 조회 API 구현하기 (마이크로서비스 간에 REST API로 통신)

데이터 조회 기능 구현 방식 (모놀리식 vs MSA)
[실습] 다른 마이크로서비스가 사용할 ‘사용자 조회 API’ 만들기
[실습] 특정 게시글 조회 API 만들기
특정 서비스가 장애났을 때, 장애가 전파되지 않게 막는 방법
[실습] 특정 서비스가 장애났을 때, 장애가 전파되지 않게 방어 코드 작성하기
[실습] 게시글 전체 조회 API 만들기 - 1
[실습] 게시글 전체 조회 API 만들기 - 2

데이터 쓰기 API 구현하기 (마이크로서비스 간에 REST API로 통신)

[실습] Point Microservice 만들기 - 1
[실습] Point Microservice 만들기 - 2
[실습] 회원 가입하면 포인트가 적립되도록 만들기
[실습] 사용자 활동 점수 적립 API 만들기
[실습] ‘포인트 차감 → 게시글 작성→ 활동 점수 적립’ 순으로 로직이 처리되도록 만들기

MSA 환경에서 트랜잭션 관리하기

게시글 작성 API 로직 수행 중, 중간에 에러가 발생하면 어떻게 될까?
MSA 환경에서의 트랜잭션 처리 방법
Saga 패턴이란? / 보상 트랜잭션이란?
[실습] 게시글 작성 API에 Saga 패턴 적용시키기 - 1
[실습] 게시글 작성 API에 Saga 패턴 적용시키기 - 2
Eventual Consistency(최종적 일관성)이란?
[참고] Saga 패턴을 구현할 때 고려해야 할 요소 (멱등성, 동시성 이슈 등)

데이터 쓰기 API 구현하기 (마이크로서비스 간에 메시징 기반으로 통신)

MSA 환경에서 언제 메시징 기반(비동기 방식)으로 통신하면 좋을까?
어떻게 구현할 지 설계하기
[실습] 게시글 서비스에서 Kafka로 ‘게시글 작성 완료 이벤트’ 발행하기
[실습] 사용자 서비스에서 Kafka로부터 ‘게시글 작성 완료 이벤트’ 구독하기
[실습] 잘 작동하는 지 테스트하기

‘메시징 기반의 데이터 동기화 방식’으로 데이터 조회 최적화하기

‘데이터 동기화’를 활용한 게시글 조회 API 최적화하기
[실습] 사용자 서비스에서 Kafka로 ‘회원가입 완료 이벤트’ 발행하기
[실습] 게시글 서비스에서 Kafka로부터 ‘회원가입 완료 이벤트’ 구독하기
[실습] 잘 작동하는 지 테스트하기
[실습] 게시글 조회 로직 최적화하기 (

API Gateway를 활용해 클라이언트의 요청을 적절한 서버로 전달하기

API Gateway란?
[실습] Spring Cloud Gateway 셋팅하기 / 라우팅 설정하기
[실습] ‘외부용 API’와 ‘마이크로서비스간 통신용 API’ 구분하기
[실습] API Gateway를 활용해 클라이언트가 접근할 API 제한하기

API Gateway를 활용해 JWT 인증 로직 구현하기

MSA에서 ‘인증 로직’ 구현하는 방법
[실습] 사용자 서비스에 로그인 API 구현하기
[실습] API Gateway에 JWT 인증 로직 구현하기 (
[실습] 게시글 작성 로직 수정하기

마무리

MSA는 꼭 쿠버네티스로 배포해야 할까?
[미션] AWS에 MSA 프로젝트 배포하기
[참고] 완성 프로젝트 Github 주소
← 블로그 목록으로 돌아가기

[실습] Point Microservice 만들기 - 2

JSCODE 박재성
JSCODE 박재성
2026. 03. 18.
author
JSCODE 박재성
category
MSA
createdAt
Dec 6, 2025 05:16 AM
isPublic
isPublic
series
비전공자도 이해할 수 있는 MSA 입문/실전
slug
practice-create-point-microservice-2
type
post
updatedAt
Mar 18, 2026 09:00

✅ Spring Boot 프로젝트 셋팅 & DB 연결

  1. Spring Boot 프로젝트 셋팅
    1. start.spring.io
      https://start.spring.io/
      notion image
      • Artifact와 Name을 point-service라고 지어주자.
      • Package name을 Java 컨벤션에 맞게 pointservice라고 지어주자.
      • Java 21 버전을 선택하자. 아래 과정을 Java 21 버전을 기준으로 진행할 예정이다.
      • Dependencies는 Spring Boot DevTools, Spring Web, MySQL Driver, Spring Data JPA를 선택하자.
       
  1. application.yml 작성하기
    1. 이 프로젝트에서는 application.properties를 지우고 application.yml을 생성했다.
      server: port: 8082 spring: datasource: url: jdbc:mysql://localhost:3308/point-db # DB 주소 username: root # DB 계정 password: password # DB 비밀번호 driver-class-name: com.mysql.cj.jdbc.Driver jpa: hibernate: ddl-auto: update show-sql: true
       
  1. Spring Boot 서버 실행시켜서 DB 연결 제대로 되는 지 확인하기
    1. Spring Boot 실행시켰을 때 아래와 같은 에러 안 뜨고 서버가 실행되면, 정상적으로 DB가 잘 연결된 것이다.
      notion image
 
 

✅ 포인트 적립 API 만들기

  1. Point 엔티티 생성하기
    1. domain/Point
      @Entity @Table(name = "points") public class Point { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long pointId; private Long userId; private int amount; public Point() { } public Point(Long userId, int amount) { this.userId = userId; this.amount = amount; } public Long getPointId() { return pointId; } public Long getUserId() { return userId; } public int getAmount() { return amount; } // 포인트 적립 (나중에 Service 로직 짤 때 사용) public void addAmount(int amount) { this.amount += amount; } // 포인트 차감 (나중에 Service 로직 짤 때 사용) public void deductAmount(int amount) { this.amount -= amount; } }
       
  1. Reposiotry 만들기
    1. domain/PointRepoistory
      public interface PointRepository extends JpaRepository<Point, Long> { // 나중에 Service 로직 짤 때 사용 Optional<Point> findByUserId(Long userId); }
       
  1. Controller 만들기
    1. controller/PointController
      @RestController @RequestMapping("/points") public class PointController { private final PointService pointService; public PointController(PointService pointService) { this.pointService = pointService; } @PostMapping("add") public ResponseEntity<Void> addPoints( @RequestBody AddPointRequestDto addPointRequestDto ) { pointService.addPoints(addPointRequestDto); return ResponseEntity.noContent().build(); } @PostMapping("deduct") // deduct : 빼다 public ResponseEntity<Void> deductPoints( @RequestBody DeductPointRequestDto deductPointRequestDto ) { pointService.deductPoints(deductPointRequestDto); return ResponseEntity.noContent().build(); } }
       
  1. DTO 만들기
    1. dto/AddPointRequestDto
      public class AddPointRequestDto { private Long userId; private int amount; public Long getUserId() { return userId; } public int getAmount() { return amount; } }
       
      dto/DeductPointRequestDto
      public class DeductPointRequestDto { private Long userId; private int amount; public Long getUserId() { return userId; } public int getAmount() { return amount; } }
       
       
  1. Service 만들기
    1. service/PointService
      @Service public class PointService { private final PointRepository pointRepository; public PointService(PointRepository pointRepository) { this.pointRepository = pointRepository; } @Trasnsactional public void addPoints(AddPointRequestDto addPointRequestDto) { Point point = pointRepository.findByUserId(addPointRequestDto.getUserId()) .orElseGet(() -> new Point(addPointRequestDto.getUserId(), 0)); point.addAmount(addPointRequestDto.getAmount()); pointRepository.save(point); } @Transactional public void deductPoints(DeductPointRequestDto deductPointRequestDto) { Point point = pointRepository.findByUserId(deductPointRequestDto.getUserId()) .orElseThrow(() -> new IllegalArgumentException("사용자의 포인트 정보를 찾을 수 없습니다.")); point.deductAmount(deductPointRequestDto.getAmount()); pointRepository.save(point); } }
       
  1. 서버 다시 실행시키기
    1. notion image
       
  1. API 잘 작동하는 지 테스트해보기
    1. [포인트 적립 API 테스트]
      notion image
      notion image
       
      [포인트 차감 API 테스트]
      notion image
      notion image
 
📎
이 글은 비전공자도 이해할 수 있는 MSA 입문/실전 (feat. Spring Boot) 강의의 수업 자료 중 일부입니다.