묻고 답해요
156만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
새로운 마이크로서비스가 추가된 경우 클라이언트 배포 여부
1분경, 새로운 마이크로서비스가 배포된 경우에도 API 게이트웨이를 두면 클라이언트는 API게이트웨이만 상대하면 된다고 하셨는데,새로운 마이크로서비스가 생기면 클라이언트는 배포를 하지 않아도 된다는 뜻으로 이해를 했는데,새로운 마이크로서비스와 연결하기 위해서는 클라이언트에도 연결을 위한 코드가 추가될텐데 클라이언트도 배포를 해야 하는 것은 아닌지 문의 드립니다 !감사합니다.
-
미해결카프카 완벽 가이드 - 코어편
auto.offset.reset은 첫구독일때만 의미가 있는건가요?
__consumer_offsets 토픽에 오프셋 데이터 적재 이후로는의미가 없는 설정값인게 맞을까요?
-
미해결[아파치 카프카 애플리케이션 프로그래밍] 개념부터 컨슈머, 프로듀서, 커넥트, 스트림즈까지!
애플리케이션 개발 실습간 레코드 미등록 사항
안녕하십니까 애플리케이션 실습 중인데 레코드가 등록 되지 않아서 이런경우는 어떤것을 확인하면 되는지 알려주시면 감사하겠습니다. 이클립스에서 git에 올려주신 코드를 그대로 실행하였습니다. 그래서 아래와 같이 로그가 떴고아래와 같이 해당 토픽을 조회하였지만 아무 레코드가 조회되지 않았습니다.
-
미해결실습으로 배우는 선착순 이벤트 시스템
MySql Lock을 사용하지 않는 이유
강의에서 설명해주시기로는 쿠폰 개수를 가져오는 것부터 쿠폰 생성까지 lock을 걸어야 한다고 설명 주셨는데 이전 강의인 재고 관리 이슈와는 다르게 row가 아닌 table에 lock을 걸기 때문에 성능 이슈가 발생한다고 보면 될까요?
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
Filter우선순위 질문
안녕하세요! MSA강의 섹션2 Logging Filter관련 부분 듣다가 필터 우선순위와 관련된 궁금증이 생겨서 질문 남깁니다! GatewayFilter filter = new OrderedGatewayFilter((exchange, chain) -> { ServerHttpRequest request = exchange.getRequest(); ServerHttpResponse response = exchange.getResponse(); log.info("Logging Filter base message: {}",config.getBaseMessage()); if(config.isPreLogger()){ log.info("Logging Filter Start: request uri -> {}",request.getURI()); } //Custom Post Filter return chain.filter(exchange).then(Mono.fromRunnable(()->{ if(config.isPostLogger()){ log.info("Logging Filter End: response Code -> {}",response.getStatusCode()); } })); }, Ordered.HIGHEST_PRECEDENCE); return filter;위와 같은 방식으로 OrderedGatewayFilter를 사용해 filter를 생성했는데 이때 두번째 인자로 Ordered.HIGHEST_PRECEDENCE를 사용할 때와 Ordered.LOWEST_PRECEDENCE를 사용할 때 등장하는 filter 우선순위와 관련된 궁금증이 생겼습니다.HIGHEST를 사용할때는 우선순위가 높은 필터가 먼저 나와서 강의에서도 그렇고 코드 실행결과LoggingFIlter -> GlobalFilter -> CustomFilter의 순서로 Filter 가 등장했는데 그렇다면, 반대로 우선순위가 낮은 경우인 LOWEST를 사용할 때는 CustomFilter -> GlobalFilter -> LoggingFIlter의 순서로 filter가 등장해야한다고 생각하는데 결과가 그렇지 않아서 우선순위에 어떠한 개념이 있는지, 제가 어떤 개념을 놓치고 있는지 의문이 들어 질문글 남깁니다!
-
미해결[아파치 카프카 애플리케이션 프로그래밍] 개념부터 컨슈머, 프로듀서, 커넥트, 스트림즈까지!
KStreamJoinKTable 에서
ADDRESS_TABLE에서 기존의 key에 주소를 새로 작성했을 때에는, consumer에 메시지가 새로 뜨지 않고, ORDER_STREAM에서 기존의 key에 새로운 value를 작성했을 때에만 consumer에 메시지가 새로 뜨는 이유는 무엇인가요?
-
해결됨카프카 완벽 가이드 - 코어편
Kafka에 설정값이 엄청 많은데요
이직하는 회사가 Kafka 기반으로 MSA간 통신을 해서max.in.flight.~ 강의까지 열심히 듣는 중입니다 ㅎㅎ보다보니까 설정할 수 있는 영역이 엄청 많은데요~보통 실무에서 로드테스트 등을 통해서 서비스에 적합한 값을 찾아가나요?어느정도 경험이 없다면 최적의 설정값을 찾기가 어려울 것 같아서요 ㅎㅎ
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
JDBC Connector 위치가 변경 된거 같습니다.
https://docs.confluent.io/5.5.1/connect/kafka-connect-jdbc/index.html 는 현재 메인 페이지로 이동이 되어서 다음 페이지에서 다운로드 받을수 있었습니다. https://www.confluent.io/hub/confluentinc/kafka-connect-jdbc
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
loadUserByUsername(String username) 의 매개변수가 어디서 오는지 궁금합니다.
loadUserByUsername(String username) 에 매개변수로 들어오는 String username은 AuthenticationFilter의attemptAuthentication에서 만들어 주었던 UsernamePasswordAuthenticationToken 을 사용하는게 맞나요? 맞다면 email을 입력하였는데 어떻게 userName으로 바뀐건지 궁금합니다.
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
login 요청하면 404 에러가 발생합니다.
포스트맨으로 API_GW를 경유해서 http://127.0.0.1:8000/user-service/login 요청하면 404 에러가 발생합니다.근데 http://127.0.0.1:54656/login 로 바로 리퀘스트하면 200 상태가 반환됩니다.로그인만 저렇고 http://127.0.0.1:8000/user-service/users 요청하면 회원가입은 또 됩니다..어디 부분부터 잘못되었는지 찾아봐야할까요?필터부분도 오타없이 잘 되었는데.. - id: user-service uri: lb://USER-SERVICE predicates: - Path=/user-service/login - Method=POST filters: - RemoveRequestHeader=Cookie - RewritePath=/user-service/(?<segment>.*), /$\{segment}/ - id: user-service uri: lb://USER-SERVICE predicates: - Path=/user-service/users - Method=POST filters: - RemoveRequestHeader=Cookie - RewritePath=/user-service/(?<segment>.*), /$\{segment}/ - id: user-service uri: lb://USER-SERVICE predicates: - Path=/user-service/** - Method=GET filters: - RemoveRequestHeader=Cookie - RewritePath=/user-service/(?<segment>.*), /$\{segment}/
-
미해결실습으로 배우는 선착순 이벤트 시스템
springboot에서 docker의 mysql에 접속이 안 됩니다
docker의 mysql url localhost:3306/coupon_example에 접속이 안 됩니다.제 로컬 mysql에 접속이 되는 듯한데 어떻게 하면 docker의 3306 포트의 url에 연동을 할 수 있는지 모르겠네요.. application.yml 파일입니다.spring: jpa: hibernate: ddl-auto: create show-sql: true properties: hibernate: dialect: org.hibernate.dialect.MySQLDialect datasource: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/test username: root password: 1234
-
해결됨Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
java.security.KeyStoreException: Uninitialized keystore 에러가 발생 하고 있습니다.
비대칭키를 통한 암호화 과정에서 keytool을 사용하여 올려주신 내용 그대로 keytool -genkeypair -alias apiEncryptionKey -keyalg RSA -dname "CN=Kenneth Lee, OU=API Development, O=joneconsulting.co.kr, L=Seoul, C=KR" -keypass "1q2w3e4r" -keystore apiEncryptionKey.jks -storepass "1q2w3e4r" 키를 생성후 bootstrap.yml에 적용 하였습니다. 그런데 encrypt를 실행 하면 java.security.KeyStoreException: Uninitialized keystore at java.base/java.security.KeyStore.getKey(KeyStore.java:1076) ~[na:na] at org.springframework.security.rsa.crypto.KeyStoreKeyFactory.getKeyPair(KeyStoreKeyFactory.java:80) ~[spring-security-rsa-1.0.11.RELEASE.jar:na] at org.springframework.cloud.config.server.encryption.KeyStoreTextEncryptorLocator.rsaSecretEncryptor(KeyStoreTextEncryptorLocator.java:99) ~[spring-cloud-config-server-3.1.6.jar:3.1.6] 해당 에러가 발생을 하고 있습니다. keytool을 생성시 제 자바 home 버전은 java 18 이고 개발 환경운 java 11 이어서 이런 문제가 생기는 걸까요?
-
해결됨실습으로 배우는 선착순 이벤트 시스템
카프카 Consumer에 메시지가 정상 도착하지 않습니다.
동시에 여러명이 요청하는 케이스를 카프카로 해결하는 케이스에서 테스트를 실행하였더니 카프카 컨슈머에 아무런 메시지가 전달되지 않아 질문드립니다. 토픽명은 강의와 다르게 "coupon"으로 생성하였습니다.
-
미해결실습으로 배우는 선착순 이벤트 시스템
발급가능 쿠폰개수가 1인당 2개이상일 때
안녕하세요! 강의 재미있고 유익하게 잘 듣고 있습니다 :)확장에 대해 생각해보니, Set을 이용해서는 중복방지 이상 개수 확장에 대해서 처리는 불가능 할 거 같아서요. 혹시, 2개 이상 N개 제한에 대한 확장 방법은 어떤게 있을까요??감사합니다!
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
order-service orderId문제
"not-null property references a null or transient value : com.example.orderservice.jpa.OrderEntity.orderId; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value : com.example.orderservice.jpa.OrderEntity.orderId"이 오류는 com.example.orderservice.jpa.OrderEntity 클래스의 orderId 속성이 null 또는 임시 값으로 설정되어 있을 때 발생합니다. 즉, orderId 속성에는 null이 허용되지 않는데, null이나 임시 값으로 설정되었기 때문에 오류가 발생합니다.application.ymlserver: port: 0 spring: application: name: order-service h2: console: enabled: true settings: web-allow-others: true path: /h2-console sql: init: mode: always jpa: database-platform: org.hibernate.dialect.H2Dialect hibernate: ddl-auto: update properties: hibernate: format_sql: true show_sql: true defer-datasource-initialization: true datasource: driver-class-name: org.h2.Driver url: jdbc:h2:mem:testdb main: allow-bean-definition-overriding: true eureka: instance: instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value}} client: register-with-eureka: true fetch-registry: true service-url: defaultZone: http://127.0.0.1:8761/eureka logging: level: com.example.orderservice: DEBUG OrderEntity@Data @Entity @Table(name = "orders") public class OrderEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(nullable = false, length = 120, unique = true) private String productId; @Column(nullable = false) private Integer qty; @Column(nullable = false) private Integer unitPrice; @Column(nullable = false) private Integer totalPrice; @Column(nullable = false) private String userId; @Column(nullable = false, unique = true) private String orderId; @Column(nullable = false, updatable = false, insertable = false) @ColumnDefault(value = "CURRENT_TIMESTAMP") private Date createAt; } OrderDto@Data public class OrderDto implements Serializable { private String productId; private Integer qty; private Integer unitPrice; private Integer totalPrice; private String orderId; private String userId; } ResponseOrder@Data @JsonInclude(JsonInclude.Include.NON_NULL) public class ResponseOrder { private String productId; private Integer qty; private Integer unitPrice; private Integer totalPrice; private Date createAt; private String orderId; } OrderServicepublic interface OrderService { OrderDto createOrder(OrderDto orderDetails); OrderDto getOrderByOrderId(String orderId); Iterable<OrderEntity> getOrdersByUserId(String userId); } OrderServiceImpl@Service public class OrderServiceImpl implements OrderService{ OrderRepository orderRepository; @Autowired public OrderServiceImpl(OrderRepository orderRepository){ this.orderRepository = orderRepository; } @Override public OrderDto createOrder(OrderDto orderDto){ orderDto.setUserId(UUID.randomUUID().toString()); orderDto.setTotalPrice(orderDto.getQty() * orderDto.getUnitPrice()); ModelMapper mapper = new ModelMapper(); mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); OrderEntity orderEntity = mapper.map(orderDto, OrderEntity.class); orderRepository.save(orderEntity); OrderDto returnValue = mapper.map(orderEntity, OrderDto.class); return returnValue; } @Override public OrderDto getOrderByOrderId(String orderId) { OrderEntity orderEntity = orderRepository.findByOrderId(orderId); OrderDto orderDto = new ModelMapper().map(orderEntity, OrderDto.class); return orderDto; } @Override public Iterable<OrderEntity> getOrdersByUserId(String userId) { return orderRepository.findByUserId(userId); } }OrderController@RestController @RequestMapping("/order-service") public class OrderController { Environment env; OrderService orderService; @Autowired public OrderController(Environment env, OrderService orderService) { this.env = env; this.orderService = orderService; } @GetMapping("/health_check") public String status(){ return String.format("It's Working in Order Service on PORT %s", env.getProperty("local.server.port")); } // http://127.0.0.1:0/order-service/{user_id}/orders/ @PostMapping("/{userId}/orders") public ResponseEntity<ResponseOrder> createOrder(@PathVariable("userId") String userId, @RequestBody RequestOrder orderDetails){ ModelMapper mapper = new ModelMapper(); mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); OrderDto orderDto = mapper.map(orderDetails, OrderDto.class); orderDto.setUserId(userId); OrderDto createOrder = orderService.createOrder(orderDto); ResponseOrder responseOrder = mapper.map(createOrder, ResponseOrder.class); return ResponseEntity.status(HttpStatus.CREATED).body(responseOrder); } @GetMapping("/{userId}/orders") public ResponseEntity<List<ResponseOrder>> getOrder(@PathVariable("userId") String userId){ Iterable<OrderEntity> orderList = orderService.getOrdersByUserId(userId); List<ResponseOrder> result = new ArrayList<>(); orderList.forEach(v -> { result.add(new ModelMapper().map(v, ResponseOrder.class)); }); return ResponseEntity.status(HttpStatus.OK).body(result); } } 다 똑같이 쳤는데 뭐가 문제일까요?
-
해결됨[아파치 카프카 애플리케이션 프로그래밍] 개념부터 컨슈머, 프로듀서, 커넥트, 스트림즈까지!
멱등성 프로듀서, 컨슈머 질문
안녕하세요 멱등성 프로듀서를 사용할꺼면기본 값이 retry가 INTEGER MAX, acks=all로 설정이 되는데꼭 이 기본 값을 같이 사용해야지만 멱등성 프로듀서를 사용할 수 있는건가요??강의 마지막에 Consumer에서 단 한 번만 데이터를 처리할 수 있게 만들 수 있다고 하셨는데 이건 어떻게 하는 건지 알 수 있을까요?
-
미해결실습으로 배우는 선착순 이벤트 시스템
왜 쿠폰수가 너무 많을까요?
분명 현재 없는 상태이고결과가 자꾸 이상하게 나와서 sout 처리를 잠시 해보았습니다 package com.example.api.service; import com.example.api.domain.Coupon; import com.example.api.repository.CouponCountRepository; import com.example.api.repository.CouponRepository; import org.springframework.stereotype.Service; @Service public class ApplyService { private final CouponRepository couponRepository; private final CouponCountRepository couponCountRepository; public ApplyService(CouponRepository couponRepository, CouponCountRepository couponCountRepository) { this.couponRepository = couponRepository; this.couponCountRepository = couponCountRepository; } public void applyV1(Long userId) { Long count = couponRepository.count(); if(count > 100) { return; } couponRepository.save(new Coupon(userId)); } public void applyV2(Long userId) { Long count = couponCountRepository.increment(); System.out.println(count); if(count > 100) { return; } couponRepository.save(new Coupon(userId)); } } @SpringBootTest class ApplyServiceTest { @Autowired private ApplyService applyService; @Autowired private CouponRepository couponRepository; @Test public void applyOnce() { applyService.applyV1(1L); long count = couponRepository.count(); Assertions.assertEquals(1L, count); } @Test public void 여러명응모V1() throws InterruptedException { int threadCount = 1000; ExecutorService executorService = Executors.newFixedThreadPool(32); CountDownLatch latch = new CountDownLatch(threadCount); for(int i=0; i<threadCount; i++){ long userId = i; executorService.submit(() -> { try { applyService.applyV1(userId); } catch(Exception e) { System.out.println(e); }finally { latch.countDown(); } }); } latch.await(); long count = couponRepository.count(); assertThat(count).isEqualTo(100); } @Test public void 여러명응모V2() throws InterruptedException { int threadCount = 1000; ExecutorService executorService = Executors.newFixedThreadPool(32); CountDownLatch latch = new CountDownLatch(threadCount); for(int i=0; i<threadCount; i++){ long userId = i; executorService.submit(() -> { try { applyService.applyV2(userId); } catch(Exception e) { System.out.println(e); }finally { latch.countDown(); } }); } latch.await(); long count = couponRepository.count(); org.assertj.core.api.Assertions.assertThat(count).isEqualTo(100); } } 그런데 여러명응모V2 test를 실행시에 count를 출력시다음과 같은 수가 나옵니다. 20003200112001220013200152001620017200182002020022 ??? 한번 할때마다 1000씩 쿠폰의 수가 증가중인데요;;;조회했을때는 empty라 나오는데 이렇게 되는 연유를 잘 모르갰습니다. 테스트 코드라서 rollback이 되야할거 같은데 그렇지 않는것도 잘 모르겟네요;; ㅠㅠ
-
미해결[아파치 카프카 애플리케이션 프로그래밍] 개념부터 컨슈머, 프로듀서, 커넥트, 스트림즈까지!
파티션 개수 늘리기
파티션 개수를 늘리면프로듀서의 처리량이 늘어나는 게 맞을까요?이게 맞다면 왜 파티션 개수를 늘리면프로듀서의 처리량이 늘어나는 지 알 수 있을까요?파티션이 2개라고 했을 때 프로듀서의 데이터를 넣는 게파티션 A 넣고 파티션 B 넣고 파티션 A 넣고 이렇게 되면파티션 하나 일 때랑 별 차이가 없을 것 같아서 질문 드립니다.
-
해결됨[아파치 카프카 애플리케이션 프로그래밍] 개념부터 컨슈머, 프로듀서, 커넥트, 스트림즈까지!
CommitAsync
안녕하세요강의를 듣다보니CommitAsync는 commitSync에 비해서 데이터 처리가 일시적으로 중단되지 않아서 더 좋아보이는데CommitAsync의 단점은 없을까요?운영환경에서도 보통 CommitAsync를 사용하시나요?
-
해결됨[아파치 카프카 애플리케이션 프로그래밍] 개념부터 컨슈머, 프로듀서, 커넥트, 스트림즈까지!
Producer key, 커스텀 파티셔너
kafka Producer를 사용할 때 Key 값을 사용하거나 커스텀 파티셔너를 사용하면 특정 파티션으로만 데이터를 넣을 수 있는데 특정 파티션으로 데이터를 넣는 가장 큰 이유가데이터의 순서를 보장하기 위해서 인가요??아니면 다른 이유도 있을까요?? 강의를 들어보면서 순서가 중요하지 않다면Producer key나 커스텀 파티셔너를 안 사용해도 될 것 같아서 질문드립니다.