return (exchange, chain) -> { ServerHttpRequest request = exchange.getRequest(); ServerHttpResponse response = exchange.getResponse(); log.info("Custom PRE filter: request id -> {}", request.getId() ); // Custom Post Filter return chain.filter(exchange).then(Mono.fromRunnable(() -> { log.info("Custom POST filter: response code -> {}", response.getStatusCode()); })); }; //return null; 강사님. 안녕하세요. 좋은 강의 잘 듣고 있어요. 이전에 devops 강의 너무 좋아서 이 강의도 듣게 되었습니다. 다름이 아니라 위의 람다코드는 getId 이후에 statusCode 부분을 비동기 방식으로 찍는 것 같은데 서버에서 Filter 적용시 비동기로 찍는 것은 아무래도 성능 때문인지 궁금하여 글 남깁니다. 감사합니다. !!!
일단 제 환경은 윈도우구요 apigateway-service 내의 application.yml 파일의 url를 일반 ip 어드레스가 아닌 loadbalancer 방식으로 변경하여 테스트하면 진행되지 않습니다; 트러블슈팅에 장시간이 걸렸는데 혹시나 해서 제 피씨 네임을 인식하지 못하나 해서 hosts 파일에 본인 pc 네임과 127.0.0.1을 추가해주면 됩니다. 만약 네 pc가 '뽀로로'인 경우 뽀로로 127.0.0.1을 'C:\Windows\System32\drivers\etc'의 파일에 추가해줍니다.
여러 서비스가 Kafka에 메시지를 전달해서 이를 단일 서버에서 저장하는 것은 이해가 갑니다! 그렇다면 조회할 때는 어떤 식으로 흐름이 발생하는건가요? 기존에 어플리케이션이 직접 DB와 커넥션이 되어있는 상태라면 조회문 날리면 그만인데 조회의 경우엔 조회 이벤트가 발생할 때마다 조회 이벤트를 보내면 DB가 카프카에 쿼리를 실행한 결과값을 저장하고, 어플리케이션에서는 또 컨슈머를 만들어서 그값을 가져오는 형태인가요?
UserCase가 많은데... 그러니까 일반적인 Layered Architecture에서는 Service 기능으로, 현재 결국에는 RentalCard 관련해서 작업을 하니까 RentarCardService라는 interface파일에 모든 기능을 넣어서 사용할 수 가 있는데 현재 헥사고날 공부하면서 UseCase는 InqueryUsecase를 제외하고 기능 하나에 usecase하나로 작성이 되었더라고요. 이 이유와 이로 인한 장점이 무잇인지 잘 모르겠습니다. 설명 부탁드립니다!
Microservcie간 통신 강의를 보다가 궁금하게 있어서 질문드립니다. user-service에서 order-service를 요청할때 인증은 필요가 없는건가요? order-service를 요청할때 따로 헤더에 토큰을 담지 않고 요청을 하고 있어서요. order-service를 IP로 지정하지 않고 유레카에 서비스 이름으로 지정해서 요청할때도 gateway를 통해서 요청이 들어 가는것인가요?
찾아보니 비슷한 질문이 있었던 거 같은데 현재 실습환경과 100% 일치하지 않아 도움을 구합니다. 실행환경은 다음과 같습니다 인텔리제이 : Build #IU-241.14494.240, built on March 28, 2024 JDK : 17 스프링부트 : 3.2.4 아시다 시피 최신 인텔리제이에서는 실습환경으로 제시되는 2.X 버전의 스프링부트 지원이 되지 않습니다. POM.XML로 강제로 버전을 내리거나 JDK 버전을 내리는 경우 서비스 기동이 제대로 되지 않습니다. 아마 스프링부트 3 버전에서는 JDK 특정 버전 이상을 강제하는 느낌입니다. 현재 pom.xml 설정은 다음과 같습니다. <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.2.4</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>user-serivce</artifactId> <version>0.0.1-SNAPSHOT</version> <name>user-serivce</name> <description>user-serivce</description> <properties> <java.version>17</java.version> <spring-cloud.version>2023.0.1</spring-cloud.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <excludes> <exclude> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </exclude> </excludes> </configuration> </plugin> </plugins> </build> </project> 명렁어 실행 시 에러는 다음과 같이 발생합니다. [ERROR] Unknown lifecycle phase ".run.jvmArguments=-Dserver.port=9003". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-vers ion>]:<goal>. Available lifecycle phases are: pre-clean, clean, post-clean, validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sou rces, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy. -> [Help 1] 동일한 명렁어를 윈도우즈 cmd에서 실행하면 다음과 같습니다. [WARNING] Error injecting: org.springframework.boot.maven.RunMojo java.lang.TypeNotPresentException: Type org.springframework.boot.maven.RunMojo not present at org.eclipse.sisu.space .URLClassSpace.loadClass ( URLClassSpace.java:147 ) (중략) Caused by: java.lang.UnsupportedClassVersionError: org/springframework/boot/maven/RunMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0 본 문제 때문에 강의 진행이 안되고 있습니다. 꼭 해결해 주셨으면 합니다.
apigateway의 application.yml을 보면 get요청에는 authorizationHeaderFilter를 적용시키고 있습니다. authenticFilter는 그저 로그인 요청시 attempthAuthentication메소드와 successfulAthentication메소드를 통해 인증을 처리하고 response헤더에 토큰을 추가하는 역할입니다. 따라서 로그인 요청에만 적용하면 될 것 같은데, 깃허브의 최신코드 버전을 보면 거의 모든 요청에 authenticationFilter를 적용하고 있습니다. 왜 로그인요청이 아닌 다른 요청에다가 AthenticFilter를 적용할까요? apiGateway-service에서 GET요청만 AuthoriztionFilter를 적용하면 되지않나요?? http.authorizeHttpRequests((authz) -> authz .requestMatchers(new AntPathRequestMatcher("/actuator/**")).permitAll() .requestMatchers(new AntPathRequestMatcher("/h2-console/**")).permitAll() .requestMatchers(new AntPathRequestMatcher("/users", "POST")).permitAll() .requestMatchers(new AntPathRequestMatcher("/h2-console/**")).permitAll() // .requestMatchers(new AntPathRequestMatcher("/welcome/**")).permitAll() // .requestMatchers("/**").access(this::hasIpAddress) .requestMatchers("/**").access( new WebExpressionAuthorizationManager("hasIpAddress('127.0.0.1') or hasIpAddress('172.30.1.48')")) .anyRequest().authenticated() )
안녕하세요. 깃허브에서 spring boot 3.2 브랜치통해 코드를 작성했습니다. 그런데 회원가입, 로그인까지 해서 jwt토큰까지는 잘 받아오는데, 그 이후에 /welcome으로 헤더에 토큰으로 추가해서 요청을 보내도 403 forbidden에러가 뜹니다. 코드는 spring boot 3.2 브랜치와 동일합니다.
안녕하세요 로그인시에는 인증이 필요하지가 않는데 자꾸 인증 해주는 AuthorizationHeaderFilter 클래스에서 apply 메소드에서 header 값이 없다고 걸립니다. 그래서 아래와 같이 401 오류로 로그인이 안됩니다. application.yml 파일은 문제없는거 같은데 뭘 더 확인해봐야 할까요,,,? 아래는 Users application.yml 파일입니다.
강사님 안녕하세요. 강의를 다 듣고 배운 내용을 개인 프로젝트를 통해 구현하는중입니다. 제가 CQRS에 대한 오해가 있는 것 같아 질문 드립니다. CQRS는 도메인을 도메인 답게 유지하기 위해 비지니스 로직에 query가 침투하는 것을 막는다. 즉 command, query를 역할에 따라 분리한다. 라고 이해했는데요. 그렇다면, command만 수행하는 서버, query만 수행하는 서버로 분리하는게 맞을까요? 로직상 command를 통해 데이터를 저장 혹은 업데이트하려고 하면, db에서 해당 데이터에 대한 조회가 필수적이라고 생각하는데 이러한 조회도 command의 한 종류라고 생각하면 되는걸까요?