πŸ’»
Albert's Til
GitHub
  • 맀일맀일 μ‘°κΈˆμ”© μ„±μž₯ν•˜κΈ°
    • README
    • CS
      • Network
      • HTTP
        • NO-CACHE
      • 였λ₯˜ μ½”λ“œ
      • ORM 도ꡬ
      • Design Pattern
        • CQRS Pattern
          • Event Sourcing and CQRS pattern
        • Builder Pattern
    • DB
      • MySQL
        • Timeline
        • Pagination
        • Index
        • Database Performance Optimization Strategies
        • B+ tree
        • MySQL Connectors VS MySQL Shell(Scripting) VS MySQL Workbench
        • MySQL Storage Engine Architecture
      • Normalization & Denormalization
      • JPA
        • @Transactional
        • Why JPA?
        • About JPA
        • N+1 Issue
        • Index
        • ElementCollection&CollectionTable
        • orphanRemoval
        • CascadeType
        • Use Subselect
        • Dynamic Instance Creation
        • Paging
        • Order
        • Spefication
        • mappedBy
      • MongoDB
        • ObjectId
      • Why MySQL?
      • ACID properties of transactions
      • Between JPA and JDBC
      • Identifiers in Hibernate/JPA
    • Java
      • Jackson de/serialize
      • Collections.singletonList() vs List.of()
      • Manage dependencies in Gradle
      • Logging Level
      • Bean Validation
      • JVM Internals
        • Threads
          • Frame
        • Shared Between Threads
          • Classloader
            • Class Loader Hierarchy
            • Loading Linking Initialization
      • Java Collection Framework
      • Annotation
      • Generic
      • λ””λ―Έν„° 법칙
    • Spring
      • Caching
      • Spring Integration Overview
        • ThreadPollTaskExecutor
        • Messaging Bridge
        • Channel Adapter
        • Poller
        • Configuration and @EnableIntegration
        • Message Endpoints
        • Message Channels
      • HATEOAS
      • @Autowired vs Constructor Dependency Injection
      • Spring Security
        • JWT 토큰 μ‚¬μš©ν•œ 인가
        • OAuth 2 Login
        • OAuth 2 인증
        • 인가
        • 인증
        • PasswordEncoder
      • IoC Container
      • Filter,Interceptor,AOP,Argument Resolver
      • Spring Annotation
      • About Spring
    • Kafka
      • Error Channel
    • Infra
      • Scale Up || Scale Out
      • Docker
        • Dockerfile
        • Docker Hub Deploy
        • Command
      • Cloud μœ ν˜•
        • Infrastructure as a Service
        • Platform as a Service
        • Software as a Service
      • 무쀑단 배포
        • μ—”μ§„μ—‘μŠ€(Nginx)
      • μ½”λ“œ μžλ™ 배포
        • Technical
      • AWS EC2
        • PEM(Privacy Enhanced Mail) ν‚€
      • AWS RDS
      • AWS S3
    • CodeSquad
      • Spring Boot Project 1μ£Όμ°¨ 회고
      • Spring Boot Project 2μ£Όμ°¨ 회고
      • Spirng Boot Project 3μ£Όμ°¨ 회고
      • Spring Boot Project 4μ£Όμ°¨ 회고
    • Foody Moody ν”„λ‘œμ νŠΈ
      • Query Performance Comparison
      • HeartCount Asynchronous Issue
      • DeferredResult
      • ResponseBodyEmitter
      • SseEmitter (Spring)
      • Server-Sent Events (SSE)
      • 기술 μŠ€νƒ 적용 이유
      • NO-CACHE(HTTP)
      • Transactional
    • DDD
      • AggregateId
    • Test
      • RestAssured
    • Coding and Algorithmic Problems
      • 819. Most Common Word
      • 344. Reverse String
      • 125. Valid Palindrome
      • 937. Reorder Data in Log Files
    • Node
      • Async... Await...
      • Custom Transactional Decorator Challenger
    • Python
      • Python Basic Grammar
        • Comments and Input/Output
        • Variable
        • Data type
        • Operations and syntax
        • List,Tuple,Dictionary,Set
        • Function
        • Conditional statement
        • Loop
    • HTML
      • HTML Basic
      • HTML Basic Tags
      • HTML Form Tags
      • HTML Table Tags
    • CSS
      • CSS Basic
      • CSS Practice
Powered by GitBook
On this page
  • μ£Όμš” κΈ°λŠ₯ 및 νŠΉμ§•
  • μ˜ˆμ‹œ

Was this helpful?

  1. 맀일맀일 μ‘°κΈˆμ”© μ„±μž₯ν•˜κΈ°
  2. Foody Moody ν”„λ‘œμ νŠΈ

ResponseBodyEmitter

ResponseBodyEmitterλŠ” Spring MVCμ—μ„œ μ‚¬μš©λ˜λŠ” 클래슀둜, 비동기 μš”μ²­ μ²˜λ¦¬μ—μ„œ ν•˜λ‚˜ μ΄μƒμ˜ 객체λ₯Ό 응닡에 μ“Έ λ•Œ μ‚¬μš©λ©λ‹ˆλ‹€.

이 ν΄λž˜μŠ€λŠ” 컨트둀러 λ©”μ†Œλ“œμ˜ λ°˜ν™˜ νƒ€μž…μœΌλ‘œ μ‚¬μš©λ˜λ©°, 단일 κ²°κ³Όλ₯Ό μƒμ„±ν•˜λŠ” DeferredResultμ™€λŠ” 달리 μ—¬λŸ¬ 객체λ₯Ό 보낼 수 있게 ν•΄μ£ΌλŠ”λ°, 각 κ°μ²΄λŠ” ν˜Έν™˜λ˜λŠ” HttpMessageConverterλ₯Ό μ‚¬μš©ν•˜μ—¬ μž‘μ„±λ©λ‹ˆλ‹€.

μ£Όμš” κΈ°λŠ₯ 및 νŠΉμ§•

  • Asynchronous Processing: ResponseBodyEmitterλ₯Ό μ‚¬μš©ν•˜λ©΄ 데이터λ₯Ό λΉ„λ™κΈ°μ μœΌλ‘œ μŠ€νŠΈλ¦¬λ°ν•  수 있으며, ν•œ λ²ˆμ— 전체 응닡을 λ³΄λ‚΄λŠ” λŒ€μ‹ μ— μ‹œκ°„μ΄ 지남에 따라 데이터λ₯Ό μ—¬λŸ¬ 쑰각으둜 보낼 수 μžˆμŠ΅λ‹ˆλ‹€.

  • Multiple Sends: μ—¬λŸ¬ 개의 send ν˜ΈμΆœμ„ 톡해 μ‹œκ°„μ΄ 지남에 따라 데이터 쑰각을 보낼 수 μžˆμŠ΅λ‹ˆλ‹€. μ΄λŠ” ν΄λΌμ΄μ–ΈνŠΈμ—κ²Œ μ‹€μ‹œκ°„ μ—…λ°μ΄νŠΈλ₯Ό μ œκ³΅ν•˜λŠ” 데 μœ μš©ν•©λ‹ˆλ‹€.

  • Timeout Management: μƒμ„±μžμ— νƒ€μž„μ•„μ›ƒ 값을 μ„€μ •ν•˜μ—¬ ResponseBodyEmitter의 νƒ€μž„μ•„μ›ƒμ„ μ œμ–΄ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

  • Error Handling: completeWithError λ©”μ†Œλ“œλ₯Ό 톡해 μ—λŸ¬κ°€ λ°œμƒν–ˆμ„ λ•Œμ˜ 처리λ₯Ό μ •μ˜ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

  • Completion Callbacks: onCompletion, onTimeout, onError λ©”μ†Œλ“œλ₯Ό 톡해 ν•΄λ‹Ή μ΄λ²€νŠΈκ°€ λ°œμƒν–ˆμ„ λ•Œ 호좜될 μ½œλ°±μ„ 등둝할 수 μžˆμŠ΅λ‹ˆλ‹€.

μš”μ²­μ„ μ²˜λ¦¬ν•˜λŠ” 도쀑에 μ–Έμ œλ“ μ§€ emitter.send(foo)λ₯Ό ν˜ΈμΆœν•˜μ—¬ ν΄λΌμ΄μ–ΈνŠΈμ— 데이터λ₯Ό 전솑할 수 있고, 데이터 전솑이 λλ‚˜λ©΄ emitter.complete()λ₯Ό ν˜ΈμΆœν•˜μ—¬ μš”μ²­ 처리λ₯Ό μ™„λ£Œν•  수 μžˆμŠ΅λ‹ˆλ‹€.

μ˜ˆμ‹œ

  @RequestMapping(value="/stream", method=RequestMethod.GET)
  public ResponseBodyEmitter handle() {
  	   ResponseBodyEmitter emitter = new ResponseBodyEmitter();
  	   // Pass the emitter to another component...
  	   return emitter;
  }
 
  // in another thread
  emitter.send(foo1);
 
  // and again
  emitter.send(foo2);
 
  // and done
  emitter.complete();

Last updated 1 year ago

Was this helpful?