본문 바로가기

spring

Spring boot kafka demo with docker-compose spring boot kafka demo with docker ref kafka with springboot description kafka ref kafka 는 pub-sub 모델을 기반으로 동작한다. 구성요소: zookeeper: producer 와 consumer 를 관리한다. producer: topic 의 메시지 생성후 해당 메시지를 broker 에 전달 consumer: topic 을 subscribe 한다. 메시지를 pull 방식으로 broker 로부터 가져오기 때문에 batch consumer 구현 가능. broker: topic 을 기준으로 메시지 관리 전달받은 메시지를 topic 별로 분류하여 적재 topic: partition 단위로 구성 된다. 클러스터 서버에 분산 저장할 경우 pa.. 더보기
Flux and Mono Spring Reactive 를 위해 flux and Mono 에 대해 간단하게 테스트 해보도록 하고 기록으로 남기도록 한다. private final static String[] countries = new String[]{"Korea","China","America","Canada"}; private final static Flux countiesFlux = Flux.just("Korea","China","America","Canada"); /** * create flux */ @Test public void createFluxWithJustAndVerify(){ //subscribe 를 사용하여 구독 및 출력 하도록 한다. countiesFlux.subscribe(s->{ System.out.pri.. 더보기
JPA - Join 커뮤니티 게시판 테이블 쿼리: 특정 직업을 가진 사람들이 쓴 글의 정보와 사용자 정보를 조회하는 SQL 는 다음과 같을 것이다 select t.topic_seq '번호',t.title '제목',m.name '작성자',p.title '직업',t.created_at '작성일' from `member` m join `topic` t on m.member_seq = t.member_seq join `profile` p on p.profile_seq = m.profile_seq where p.profile_seq=1; query 결과는 아래와 같을 것이다. JPA 로 해당 부분을 구현 하는 과정은 아래와 같다. JPAQueryFactory 설.. 더보기
usage spring data jpa with query dsl -- dependency com.querydsl querydsl-apt com.querydsl querydsl-jpa org.springframework.boot spring-boot-maven-plugin com.mysema.maven apt-maven-plugin 1.1.3 process target/generated-sources/java com.querydsl.apt.jpa.JPAAnnotationProcessor -- created databaseConfig.java @Configuration public class Databaseconfig { @Bean public JPAQueryFactory queryFactory(EntityManager em) { return new JPAQueryFac.. 더보기
Spring Batch (정리) 해당 글은 과 기타 를 참고하여 정리한 내용 입니다. Spring Boot Batch 장점 - 대용량 데이터 처리에 최적화 - 효과적인 통계처리와 같은 재사용 가능한 필수 기능 지원 - 자동화 처리 - 예외사항과 비정상 동작에 대한 방어 기능 Spring Boot Batch 주의 사항 - 복잡한 구조와 로직을 피할것 - 데이터 무결성을 유지하는 유효성 검사 등의 방어책 필요 - 잦은 I/O 사용 최소화를 위한 개발 필요 - Batch 처리시 다른 프로젝트에 영향을 주는지 확인 할것 - Spring boot batch 는 스케줄러를 제공 하지 않음 해결책: Quartz Framework, Jenkins 장점: Quartz 사용시 클러스터링 및 다양한 스케줄링, 실행 이력 관리가능 비추천: 리눅스의 cron.. 더보기
Spring Security with CustomFilter /** * 기존 프로젝트에서는 클라이언트와 서버간 인증 흐름은 대체로 아래와 같다. * spring security 에서 제공하는 PasswordEncoder 사용 * - client 가 password 를 Sha256 으로 인코딩 하여 서버로 전달 * - server 는 인코딩 된 패스워드를 passwordEncoder 를 사용하여 DB 에 저장된 패스워드와 match 검사를 한다 * passwordEncoder 를 사용하면 내부적으로 match 검사를 한다. * -> Basic 인증을 사용한다고 가정. * 변경후: * client 와 server 에 보안 인증 모듈을 추가로 탑재 하게 되었다. * 공개키 방식의 보안 인증 과정은 아래와 같다. * - client 는 서버가 공개한 public key .. 더보기