- Spring Boot
- Spring Cloud Eureka Client
- MongoDB
- WebSocket
- STOMP
- Kafka
- Mapstruct
- 1:1, 그룹 채팅방 생성
- roomId로 채팅방 조회
- roomId로 채팅방과 첫 메시지 페이지 조회
- user가 참가중인 채팅방 리스트 조회
- userId와 상대방 userId로 1:1 채팅방 조회
- roomId로 채팅방로 채팅방 삭제
- 채팅 메시지 pub/sub
- 채팅방 초대 pub/sub
- 채팅방 나가기 pub/sub
- AWAKE 메시지 pub/sub
- 채팅 메시지 리스트 Pagination
- 사용 버전
- JDK 11
- application.yml
- /src/main/resources 으로 이동합니다.
- 아래와 같은 내용으로 resources 안에 application.yml를 생성합니다.
server:
port: 8080
spring:
profiles:
group:
"dev": "common, devdb"
"prod": "common, proddb"
---
spring:
config:
activate:
on-profile: devdb # optional, but recommend
data:
mongodb:
host: {{ your developing mongodb host }}
port: {{ your developing mongodb port }}
database: {{ your developing mongodb database }}
username: {{ your developing mongodb username }}
password: {{ your developing mongodb password }}
---
spring:
config:
activate:
on-profile: proddb
data:
mongodb:
host: {{ your production mongodb host }}
port: {{ your production mongodb port }}
database: {{ your production mongodb database }}
username: {{ your production mongodb username }}
password: {{ your production mongodb password }}
---
spring:
application:
name: chat-service
config:
activate:
on-profile: common
mvc:
pathmatch:
matching-strategy: ant_path_matcher # swagger 세팅
devtools:
restart:
enabled: true
livereload:
enabled: true
kafka:
push-topic: push
chat-topic: chat
consumer:
bootstrap-servers: {{ your bootstrap server uri }}
group-id: {{ kafka group id }}
auto-offset-reset: latest
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
producer:
bootstrap-servers: {{ your bootstrap server uri }}
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.apache.kafka.common.serialization.StringSerializer
servlet:
multipart:
maxFileSize: 200MB
maxRequestSize: 200MB
management:
endpoints:
web:
exposure:
include: health, info, metrics, prometheus
metrics:
tags:
application: ${spring.application.name}
cloud:
aws:
credentials:
accessKey: {{ your credentials accessKey }}
secretKey: {{ your credentials secretKey }}
s3:
bucket: {{ your bucket name }}
region:
static: {{ region }}
stack:
auto: false
cloudfront:
domain: {{ your cloudfront domain }}
eureka:
instance:
instance-id: {{ eureka client id }}
hostname: {{ eureka client hostname }}
ip-address: {{ eureka client ip address }}
prefer-ip-address: true # optional
client:
register-with-eureka: true # setting whether to register for Service Discovery
fetch-registry: true
service-url:
defaultZone: {{ eureka server url }} # A client is registered by sending a POST request to it.
jwt:
secret: {{ your jwt secret }}
cocotalk:
message-bundle-limit: {{ message bundle limit }}
message-paging-size: {{ message paging size }} # must be little or equals message-bundle-limit
oci:
user:
url: {{ user-server-url:port/token }}
presence:
websocket-url: {{ presence-server-url:port/ws }}
---
spring:
config:
activate:
on-profile: dev
---
spring:
config:
activate:
on-profile: prod
---
spring:
profiles:
active: {{ active profile }}
- 테스트 페이지
[GET] /
- 채팅방 생성
[POST] /rooms
- user가 참가중인 채팅방 리스트 조회
[GET] /rooms/list
- roomId로 채팅방 조회
[GET] /rooms/{id}
- roomId로 채팅방과 첫 메시지 페이지 조회
[GET] /rooms/{id}/tail
- userId와 상대방 userId로 1:1 채팅방 조회
[GET] /rooms/private?userid=
- roomId로 채팅방 삭제
[DELETE] /rooms/{id}
- 채팅 메시지 리스트 Pagination
[GET] /messages?roomid={}bundleid={}count={}
Publish Destination
- 1:1, 그룹 채팅방 생성
/chatroom/new
- 채팅 메시지 Publish
/chatroom/{roomId}/message/send
- 채팅방 초대 Publish
/chatroom/{roomId}/message/invite
- 채팅방 나가기 Publish
/chatroom/{roomId}/message/leave
- Awake 메시지 Publish
/chatroom/{roomId}/message/awake
Subscribe Topic
- 채팅방 리스트
- 메시지 토픽
'/topic/' + userId + '/message'
- 채팅방 정보 토픽
'/topic/' + userId + '/room'
- 채팅방 생성 정보 토픽
'/topic/' + userId + '/room/new'
- 메시지 토픽
- 채팅방 내부
- 메시지 토픽
'/topic/' + roomId + '/message'
- 채팅방 정보 토픽
'/topic/' + roomId + '/room'
- 메시지 토픽