추후 개발 계획
1. 인기 포스트 보여주는 page 및 컴포넌트
2. websocket 통신을 이용한 Sessions 연결 후, 실질적 msg는 kafka p -> c 를 이용해 전달.
원래는 다른 port에 새로운 카프카 p -> c 를 구현했으나, 메모리상 손해가 큼
--> kafka sub server(:9292)에 토픽 새로 생성 후 내부에 p -> c cycle 형성.
--> main과 분리되어 scaling 및 error 대처에 용이함. 채팅창에서 발생하는 이벤트에 추가적인 알림 보내기 가능.
ex) 메세지 창에 계속 text가 남아있을 때, 보내지 않았다고 알림. 메세지 보낼려는 시간 알람.
예전에 Service에 AOP 걸어놔서 entity 뜯어와서, controller에서 AOP로 데이터 가져오는것 보다 성능 구림. 그리고 postDislike 같은건 void 라서, service에서만 필요한 값 return 하게하고(aop에서 가져와서 쓰려고), controller에서 그 값 안받음 -> 메인 코드 안바꾸기 위한 전략
- 알림창 계속 열고있어도, 새 알림 오면 바로 추가됨
- 로그아웃하고, 다시 재로그인하면, 안읽은 알람 다시보내주기 + 로그아웃 동안 발생한 이벤트 순서 맞춰 보내줌
- 프론트 작업 좀 햇슴다. 그 모달 밖에 누르면 닫히게 만듬.
프론트에서 정한 단위시간별로 부르거나 프론트의 로직에 맞게, 이 url 호출하면 인기 포스트 id 주고, 백엔드 캐시 데이터는 날라갑니다.
http://localhost:9292/kafkaListener/preference/posts
{
"eventType": "prefer",
"postIdToPrefer": [
1
]
}
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
container_name: zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
container_name: kafka
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: localhost
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
server.port=9292
spring.application.name=kafka-consumer
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/KafkaConsumerDB?createDatabaseIfNotExist=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.datasource.username={}
spring.datasource.password={}
spring.jpa.hibernate.ddl-auto=update
notifications.bootstrap-servers=localhost:9092
notifications.group-id-1=test-group-notify
notifications.group-id-2=test-group-dataAgg
notifications.topic-name=test-topic-notify
notifications.max_poll_interval_ms=1800000
spring.application.name=delta
spring.datasource.driver-class-name =com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/DeltaDB2?createDatabaseIfNotExist=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.datasource.username=root
spring.datasource.password=p@ssw0rd
spring.jpa.hibernate.ddl-auto=update
token.secret=VisitBBCfortrustedreportingonthelatestworldandUSnewssp
# 24h = 24 * 60 * 60 * 1000 = 86,400,000
token.expiration-time=86400000
spring.mvc.static-path-pattern=/uploads/**
spring.web.resources.static-locations=classpath:/static/uploads/
server.port=8080
notifications.bootstrap-servers=localhost:9092
notifications.topic-name=test-topic-notify
- docker-compose를 vscode 아무데서나 열고, dokcer-compose up 하시면 이미지 깔림
- docker-desktop -> kafka run -> sns backend -> kafka backend -> react zzz
