묻고 답해요
158만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
gateway 예외처리
안녕하세요!강사님 강의를 듣고 msa 적용하는 프로젝트를 진행중인데, 프로젝트 controller단 전역에서 발생하는 예외를 처리하고 싶어 @@RestControllerAdvice를 활용하려고 생각중입니다.msa에서 예외를 전역으로 처리하려면 gateway에서 @RestControllerAdvice를 활용해야 될까요? 아니면 각각의 마이크로서비스마다 @RestControllerAdvice를 활용해야 될까요?둘중 어떤 설계가 더 효율적일지 답변주시면 감사하겠습니다🙏🙏
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
spring boot 3 버젼애선, grafana Spring Cloud Gateway가 값을 못읽어옵니다.
https://grafana.com/grafana/dashboards/11506-spring-cloud-gateway/내용: Spring Cloud Gateway Dashboard provided by: https://github.com/spring-cloud/spring-cloud-gatewayA Gateway built on Spring Framework 5.x and Spring Boot 2.x providing routing and morespirng boot 3 이상이신 분들은 참고 바랍니다.
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
springboote 3 관련 : zipkin 관련 로그에 traceId, spanid가 안나오는 문제가 있습니다.
안녕하세요강의에서는 zipkin 명령어창에서 실행시 접속로그가 나오며, orderservice에 주문 요청시traceid,spanid가 나오지만,저의 경우에는 zipkin 설치시 sl4fj 바인딩 오류가 있더라고요.혹시 이 사항이 orderservice에서 로그와 관련된 문제인지 아니면 gradle 설정에 관한 부분인지 어떤 부분을 확인해봐야 될까요?혹은 스프링부트 3.0버젼부터 되지 않는 부분인가요? *gradle 의존성 설정은 강의와 똑같습니다. **아래는 zipkin설치시 sl4fj 관련된 내용 입니다!SLF4J(W): No SLF4J providers were found.SLF4J(W): Defaulting to no-operation (NOP) logger implementationSLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.SLF4J(W): Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.SLF4J(W): Ignoring binding found at [jar:nested:/C:/Users/son/zipkin.jar/!BOOT-INF/lib/log4j-slf4j-impl-2.21.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J(W): See https://www.slf4j.org/codes.html#ignoredBindings for an explanation.
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
오타발생 관련 카프카 특정 레코드 삭제가 윈도우 기반에서는 가능한가요?
안녕하세요! 강의 잘 보고 있습니다. topic에 입력시,오타가 있는 스크립트를 입력했는데,해당 오타가 있는 레코드가 지속적으로 남아 있더군요,또한 이로 인해 jsonParser 오류가 발생해서,topic을 삭제할까 하다가, 윈도우 기반에서는 오류가 발생할 수 있다고 (https://www.inflearn.com/questions/644825)하여, topic의 오타가 있는 레코드를 삭제하고자 합니다. 혹시 방법이 있을까요??
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
kafka connect status - tasks가 빈 배열
안녕하세요,kafka source connect 등록할 때 mariadb가 연결이 잘 안되서 h2 db로 진행을 했습니다.등록 후 kafka connect status를 보면 tasks가 빈 배열로 나오네요,,CLI에서는 마지막에 tables were not found라고 나오는데 테이블이 있는데도 없다고 하는데 혹시 이런 증상 해결하신 분 계실까요?
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
예외처리시 포스트맨에 출력안되는 문제
안녕하세요 ! 강사님좋은 강의 잘 보고 있습니다.Feign의 예외처리에서 강의와 다른부분이 발생하여 질문 남깁니다. FeignErrorDecoder를 통해 예외 처리시 .[user-service] [-auto-1-exec-10] .w.s.m.a.ResponseStatusExceptionResolver : Resolved [org.springframework.web.server.ResponseStatusException: 404 NOT_FOUND "사용자의 주문이 비었습니다"] 위 로그가 user-service에서 error catch를 통해 잘 나오는 것을 확인했습니다.(09:36)강의영상에서는 404 Error를 전달하여 포스트맨 응답에서 Error msg까지 출력이 되었지만, 저의 경우에선 APIGatgeway에서의 로그및 포스트맨응답에Global Filter End : response id -> 403 FORBIDDEN으로 응답이 보내집니다. 이전 강의 부분(정상 응답)에서 해당 문제가 없었지만, 에러 응답시 403응답으로 처리되어지는 부분에 대해서 추가적으로 ApiGateWay에 대해서 github에서는 따로 handling이 없어서 추가적으로 handler를 등록하여 적용되어야하는 부분인지 여쭤봅니다 .++해당부분 user-service의 WebSecurity특정 ip 통과부분에 실제 ip(자신의 ip)를 누락하였네요.Error에 대한 부분도 응답이 됩니다.추가적으로 error에 대해서 403으로 응답이 되는부분은https://colabear754.tistory.com/182해당글을 참고하시면 될것같습니다.
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
Filter의 로그가 출력되지 않습니다.
gateway에 의해서 api는 정상적으로 호출이 되는데 로그가 출력되지 않습니다.customFilter, globalFilter 모두 출력이 되지 않았습니다. 코드에 혹시 누락된 부분이 있을까요.Global Filterpackage com.example.springgateway.filter; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.springframework.cloud.gateway.filter.GatewayFilter; import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.stereotype.Component; import reactor.core.publisher.Mono; @Component @Slf4j public class GlobalFilter extends AbstractGatewayFilterFactory<GlobalFilter.Config> { public GlobalFilter() { super(Config.class); } @Override public GatewayFilter apply(Config config) { // Custom Pre Filter return (exchange, chain) -> { ServerHttpRequest request = exchange.getRequest(); ServerHttpResponse response = exchange.getResponse(); log.info("Global Filter baseMessage : {}", config.getBaesMessage()); if (config.isPreLogger()) { log.info("Global Filter Start : request id -> {}", request.getId()); } else { log.info("preLogger is false"); } // Custom Post Filter return chain.filter(exchange).then(Mono.fromRunnable(()-> { if (config.isPostLogger()) { log.info("Global Filter End : request id -> {}", response.getStatusCode()); } else { log.info("postLogger is false"); } })); }; } @Data public static class Config { //put the configuration properties private String baesMessage; private boolean preLogger; private boolean postLogger; } } application.ymlspring: application: name: gateway-service cloud: gateway: routes: - id: first-service uri: http://localhost:8081/ predicates: - Path=/first-service/** filters: - CustomFilter - id: second-service uri: http://localhost:8082/ predicates: - Path=/second-service/** filters: - CustomFilter # - AddRequestHeader=second-request, second-request-header2 # - AddResponseHeader=second-response, second-response-header2 - id: user-service uri: http://localhost:8083/ predicates: - Path=/user-service/** filters: - CustomFilter # filters: # - AddRequestHeader=user-request, user-request-header2 # - AddResponseHeader=user-response, user-response-header2 - id: catalog-service uri: lb://CATALOG-SERVICE predicates: - Path=/catalog-service/** - id: order-service uri: lb://ORDER-SERVICE predicates: - Path=/order-service/** default-filters: - name: GlobalFilter args: baseMessage: Spring Cloud Gateway Global Filter preLogger: true postLogger: true eureka: client: register-with-eureka: true fetch-registry: true service-url: defaultZone: http://localhost:8761/eureka server: port: 8000 Filter Configpackage com.example.springgateway.config; import org.springframework.cloud.gateway.route.RouteLocator; import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; //@Configuration public class FilterConfig { // @Bean public RouteLocator gatewayRoutes(RouteLocatorBuilder builder) { return builder.routes() .route(r -> r.path("/user-service/**") .filters(f -> f.addRequestHeader("user-request", "user-request-header") .addResponseHeader("user-response", "user-response-header")) .uri("http://localhost:8083/")) .route(r -> r.path("/second-service/**") .filters(f -> f.addRequestHeader("second-request", "second-request-header") .addResponseHeader("second-response", "second-response-header")) .uri("http://localhost:8082/")) .build(); } } Postman 실행 결과
-
미해결냉동코더의 알기 쉬운 Modern Android Development 입문
Coroutine, Flow 질문
안녕하세요. 강의 잘 듣고 있습니다!아래 질문이랑 거의 비슷한 질문이긴한데 확실히 하고싶어 문의드립니다 import kotlinx.coroutines.*import kotlinx.coroutines.flow.*fun main() = runBlocking<Unit> { // Launch a concurrent coroutine to check if the main thread is blocked launch { for (k in 1..3) { println("I'm not blocked $k") delay(100) } } // Collect the flow simple().collect { value -> println(value) } // println("test") }fun simple(): Flow<Int> = flow { // flow builder for (i in 1..3) { delay(100) // pretend we are doing something useful here emit(i) // emit next value }} runBlocking{} 내부에서 launch {} 로 코루틴이 생성그다음 simple().collect{} 코드가 실행되는데 이것도 코루틴으로서 생성launch 로 생성한 코루틴이 실행 -> println("I'm not blocked $k") 코드 출력flow 코루틴 실행-> collect 된 value 출력3,4 반복이해한게 맞을까요? 그리고 타이밍에 따라서 결과값이1I'm not blocked 12I'm not blocked 2 3I'm not blocked 3 이렇게 나올수도 있나요? 챗지피티는 타이밍 때문에 출력 순서가 바뀔수 있다고 해서요 ..
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
spring config bus에 actuator 안쓰는거같은데 설치하는 이유있나요?
궁금힌ㅂ니다
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
kafka producer/consumer test
해당 예제를 통해 주키퍼를 먼저 실행을 해볼려하지만 계속해서 해당 classpath를 찾지 못하고 있습니다. 비슷한 상황을 겪은 사람들의 경우 바이너리 파일이 아닌 소스 파일을 다운 받아 해당 문제를 겪었다고 했지만 저의 경우 알맞은 파일을 설치하여 압축을 해제하였는데 어떤게 원인일까요
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
안녕하세요 싱크 커넥터로 DB에 적용이 안되어 질문드리게 되었습니다.
좋은강의 잘듣고있습니다! 다름아니라 현재 싱크 커넥터등록후 DB에 데이터가 등록되지 않고 있습니다.먼저 아래사진처럼 post요청을 통해 커넥터 등록을 하였습니다.토픽은 예제를 똑같이 따라하였을 때도 안되었어서 my-topic-orders로 새로 바꿔서 등록하였습니다.이에 맞게 테이블도 아래 사진처럼 생성하였습니다. post요청을 한 후 주문이 해당 토픽으로 전달했음에도 아래 사진처럼 DB에 적용이 되지않아 어디가 문제일지 커뮤니티를 뒤져도 잘모르겠어서 질문드립니다 ㅠㅠ (토픽도 "my_topic_orders"로 지정하였습니다.)현재 커넥터 등록상태입니다.추가로 kafka confluent에서 발생한 로그입니다
-
미해결냉동코더의 알기 쉬운 Modern Android Development 입문
Transformations import 안됨
androidx.lifecycle 패키지에 Transformations 가 없어서 참조가 안됩니다! Unresolved reference라고 하네용..Deprecated 된것 같진 않은데 사용방법이 달라진걸까요?val userLD : LiveData<User> = ...; val userFullNameLD: LiveData<String> = userLD.map { user -> user.firstName + user.lastName }공식문서에 보니 이것처럼 먼저 생성한 LiveData나 MutableLiveData 를 참조해서 map 을 사용하는데 이런식으로 사용해야할까요?+) 그리고 transformations 를 사용하는 이유나 언제 사용해야하는지? 이해가 잘 안되는데, 예시처럼 prefix나 suffix 가 필요할 때 사용하기 좋은가요?MainActivity 에서 myViewModel.liveCounter.value = myViewModel.liveCounter.value?.plus(1) 이건 원본 데이터를 조작한게 아닌건가요?
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
유저서비스의 yml파일 관련 profile 설정방법이 궁금합니다.
안녕하세요 강의를 듣던중 profile이 어떻게 적용되는지 궁금하여 질문드리게 되었습니다. 현재 dev관련 설정파일이 왼쪽공통 항목 테스트를 위한 application.yml 파일이 오른쪽입니다.모두 같은 common이라는 환경변수로 어떤 .yml파일의 값을 사용하는지 확인하였는데요user-service의profile설정은 아래 사진처럼 하였습니다.health-check를 보내서 common값을 확인했을 때,아래사진 처럼 application.yml파일의 common값을 사용하는 것을 확인하였습니다. 공통으로 가져오는 application.yml파일의 common값과 ecommerce-dev.yml의 common값이 겹칠 때 profile을 dev라 설정했기 때문에health-check로 요청시common값에 common-dev 로 찍힐것이라 생각했었습니다. 혹시 common-dev로 안찍히는 이유가 공통으로 가져오는 application.yml값과 환경변수가 겹친다면 공통으로 가져오는 yml파일의 환경변수로 찍히는 것인지 제가 profile설정을 잘못한 것인지 궁금해 질문드렸습니다 ㅠㅠ
-
미해결냉동코더의 알기 쉬운 Modern Android Development 입문
moshi관련 질문입니다.
plugins { id("com.android.application") id("org.jetbrains.kotlin.android") id("kotlin-kapt") id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin") } android { namespace = "com.example.booksearchapp" compileSdk = 34 defaultConfig { applicationId = "com.example.booksearchapp" minSdk = 23 targetSdk = 34 versionCode = 1 versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) } } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = "1.8" } buildFeatures { buildConfig = true viewBinding = true } } dependencies { implementation("androidx.core:core-ktx:1.12.0") implementation("androidx.appcompat:appcompat:1.6.1") implementation("com.google.android.material:material:1.11.0") implementation("androidx.constraintlayout:constraintlayout:2.1.4") implementation("androidx.legacy:legacy-support-v4:1.0.0") // Retrofit implementation("com.squareup.retrofit2:retrofit:2.9.0") implementation("com.squareup.retrofit2:converter-moshi:2.9.0") // Okhttp // define a BOM and its version implementation(platform("com.squareup.okhttp3:okhttp-bom:4.12.0")) // define any required OkHttp artifacts without version implementation("com.squareup.okhttp3:okhttp") implementation("com.squareup.okhttp3:logging-interceptor") // Moshi implementation("com.squareup.moshi:moshi-kotlin:1.14.0") kapt("com.squareup.moshi:moshi-kotlin-codegen:1.14.0") // Lifrcycle implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0") implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:2.7.0") // Coroutines implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3") // Coil implementation("io.coil-kt:coil:2.5.0") // RecyclerView implementation("androidx.recyclerview:recyclerview:1.3.2") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") } 위처럼 설정을 하고 빌드를 할때 아래와 같은 에러가 발생합니다.Execution failed for task ':app:kaptDebugKotlin'.> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction > java.lang.reflect.InvocationTargetException (no error message)jdk는 17을 사용하고 있습니다.11로 설정하면 아래와 같은 에러가 나옵니다.is project is configured to use an older Gradle JVM that supports up to version 11 but the current AGP requires a Gradle JVM that supports version 17. 어느 부분을 수정해야될 지 모르겠습니다.. ㅜㅜ
-
미해결냉동코더의 알기 쉬운 Modern Android Development 입문
searchBooks() 에서 북 검색 입력을 너무 빨리 할 경우 마지막 글자로 검색이 안돼요.
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 아래 코드를 private fun searchBooks() { var startTime = System.currentTimeMillis() var endTime: Long binding.etSearch.text = Editable.Factory.getInstance().newEditable(searchViewModel.query) binding.etSearch.addTextChangedListener { text: Editable? -> endTime = System.currentTimeMillis() if (endTime - startTime >= SEARCH_BOOKS_TIME_DELAY) { text?.let { val query = it.toString().trim() if (query.isNotEmpty()) { searchViewModel.searchBooksPaging(query) searchViewModel.query = query } } } startTime = endTime } }아래처럼 바꿔봤는데 입력 시마다 runnable을 매번 생성하는데 문제 되진 않을까요? 코틀린에 익숙치 않아서 더 좋은 방법이 있다면 알고 싶습니다. private var handler: Handler = Handler(Looper.getMainLooper()) var runnable: Runnable? = null private fun searchBooks() { binding.etSearch.addTextChangedListener { text: Editable? -> if (runnable != null) { handler.removeCallbacks(runnable!!) } // 텍스트 입력 후 N 초 간 입력 없으면 검색 실행 runnable = Runnable { text?.let { Log.d(TAG, "text:$it"); val query = text.toString().trim() if (query.isNotEmpty()) { bookSearchViewModel.searchBooks(text.toString()) bookSearchViewModel.query = query } } } handler.postDelayed(runnable!!, Constants.SEARCH_BOOKS_TIME_DELAY) } }
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
method patch 설정시 404에러
- id: user-service uri: lb://USER-SERVICE predicates: - Path=/user-service/** - Method=PATCH filters: - RemoveRequestHeader=Cookie - RewritePath=/user-service/(?<segment>.*), /$\{segment} - AuthorizationHeaderFilter 이렇게 작성했는데요@postmapping("/user/test")@patchmapping("/user/test")포스트는 잘동작하는데 패치는 404가 납니다뭐가 문제일까요?
-
미해결냉동코더의 알기 쉬운 Modern Android Development 입문
안드로이드에서 아키텍처 패턴
안녕하세요. 강의 잘 듣고 있습니다.안드로이드 패턴에 대해서 몇 시간동안 듣고 검색도 해보면서 이해하는 중인데 어려움이 있어 질문을 드립니다. MVC에서 그림에서 이해가 안되는 부분이 있습니다. [1] 안드로이드에서 버튼은 결국 View가 가지고 있고 이벤트는 View에 있는 버튼을 눌러서 발생하기 시작할 것 같습니다. 그럼 뷰는 입력 받은 이벤트에 대해 컨트롤러에게 전달을 해줘야할 것이고 컨트롤러는 전달 받은 이벤트에 대한 작업을 수행하고 모델에 전달 후 모델의 변경을 다시 뷰에게 전달해주는 것인데 이런 생각으로 인풋은 뷰쪽으로뷰와 컨트롤러는 쌍방향 화살표가 되어야한다고 생각했습니다. [2] MVP에 경우에 View와 Model사이 간접적 화살표가 사라졌는데, MVP에 경우에도 프레젠트를 사이에 두고 모델에 데이터가 뷰쪽으로도 이동해야만 한다고 생각이 들고 그렇다면 간접적으로 이동하는 것은 똑같으니 MVC에서 M->V 점선 화살표가 유지되어야 하는 거 아닌가 하는 생각이 들었습니다. [3] MVP에서 프레젠트가 인터페이스를 통해 뷰와 모델을 거치게 되는데[MVC] V <-> C[MVP] V <-> Interface <-> Presenter한 단계를 추가해서 의존성 주입(관심사를 세분화)라고 이해해도 될까요? 혹시나 시간이 되신다면 설명 부탁드립니다.
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
ReWritePath필터의 세그먼트 식은 정규식일까요??
안녕하세요 선생님!강의를 잘 듣던 와중에 궁금증이 생겨 질문 드립니다. 게이트 웨이에 설정한 필터 중,요청 uri를 재정의 하기 위해서 RewritePath 라는 필터를 사용하잖아요. 이때 /user-service/(?<segment>.*), /$\{segment}는 정규식인가요??... 정규식표현에 segment라는 것이 찾아봐도 나오지 않아서요!!
-
해결됨Microservice 설계(with EventStorming,DDD)
VO 관련 궁금한점
VO Money 에서 add(money:Money) 함수에 대해서 궁금합니다.VO는 불변인데 Money를 초기화 해서 값을 재할당 하는건지 어떤식으로 이해하면 좋을지 궁금합니다.
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
instance_id 설정이 적용되지 않고 있습니다.
안녕하세요 위 사진처럼 인스턴스의 ID가 아래의 yml파일로 설정한데로 적용되지 않고 있어 질문드렸습니다. 커서를 두었을 때 포트번호도 확인해서 해당 인스턴스인것도 확인하였습니다. 원인이나 해결방법을 알 수 있을까요 ㅠㅠ