From 1c83ff73621c90ab623d58aac3b479cdcd15a339 Mon Sep 17 00:00:00 2001 From: eckrin Date: Fri, 1 Dec 2023 10:07:32 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=EA=B3=BC=EC=A0=95=20=EB=B9=84=EB=8F=99=EA=B8=B0=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 8196 -> 8196 bytes README.md | 2 + src/.DS_Store | Bin 6148 -> 6148 bytes src/main/.DS_Store | Bin 6148 -> 6148 bytes src/main/java/.DS_Store | Bin 6148 -> 6148 bytes src/main/java/com/.DS_Store | Bin 6148 -> 6148 bytes src/main/java/com/kusitms/.DS_Store | Bin 6148 -> 6148 bytes src/main/java/com/kusitms/jipbap/.DS_Store | Bin 8196 -> 8196 bytes .../java/com/kusitms/jipbap/auth/.DS_Store | Bin 6148 -> 6148 bytes .../java/com/kusitms/jipbap/chat/.DS_Store | Bin 6148 -> 6148 bytes .../com/kusitms/jipbap/chat/domain/.DS_Store | Bin 6148 -> 0 bytes .../chat/service/MessageReleaseService.java | 41 ++++++++++++++++++ .../jipbap/chat/service/MessageService.java | 20 ++------- .../java/com/kusitms/jipbap/common/.DS_Store | Bin 6148 -> 6148 bytes 14 files changed, 46 insertions(+), 17 deletions(-) delete mode 100644 src/main/java/com/kusitms/jipbap/chat/domain/.DS_Store create mode 100644 src/main/java/com/kusitms/jipbap/chat/service/MessageReleaseService.java diff --git a/.DS_Store b/.DS_Store index 34640bfbd55d1d636865c9731b2c3ab1a9e30b5e..2650b64b3e99841b73971220b9034a65fcbdd76d 100644 GIT binary patch delta 416 zcmZp1XmQw}DiA01f}4SXfrUYjA)O(Up(Hoo#U&{xKM5$t@%@E~a8~+Uv<~!of@;3X^9GFJx*Lo@^%~<{KEhs1S!6pI_!}5D&y`7Mo>;)MnO)*9I{-*3Zdw2U delta 405 zcmZp1XmQw}DiFuNbQJ>w0}F#5LpnnyLrHGFi%U{YeiBfOgU2l>=1tpCM^yO~yz&JZ zhQZ1CxdlKy3=9P`fM+wi#9wv*CShmt diff --git a/README.md b/README.md index eff3ab4..c15a5d9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # 28th_Meetup_BE KUSITMS 28th_meetup BackEnd + +![밋업 프로젝트 아키텍처](https://github.com/28th-meetup/28th_Meetup_BE/assets/81168401/ed8d87f9-fc59-42e7-9139-2fc876050da7) diff --git a/src/.DS_Store b/src/.DS_Store index 6ca1480066a0940e7ab7b9fa9d9d9704b465f690..26eecb58c584de3c4c3cda418f181bcbadf8996c 100644 GIT binary patch delta 111 zcmZoMXffEJ#uS&&&%nUI!jQ|5$dJj9mz(e6l9ZF51Qg@=#;E3O*nZRzRXzo;d_jg` aaB_Zb0ZSletgV`}Vf#@>RQVLV@&y@& w!O8i#1wcIv4159%lm9V^O`gTX&sYy;9bn>NJ7S~4Xwp9U50k{^S4>i(0D$TwmjD0& delta 129 zcmZoMXffEJ#uQiY&A`CG!jQ#~$WX?Rn49n7l9ZF51Qg>q{xr+LuCJ?`4y9tC;-CsBgOy# diff --git a/src/main/java/.DS_Store b/src/main/java/.DS_Store index 6b7c218331ad9a8284dd5bc52786828824e8e1ca..0d19cada6de9160808de265a43348326aad70514 100644 GIT binary patch delta 85 zcmZoMXfc?u#AfL>1_lOZhGd3(hTPnI7nh`*{3M_V$6i-8XT$cRj>xhpXtEO@NHKoc R%*e>bKCyvqGdss$egF)97+nAW delta 85 zcmZoMXfc?u#3tRHfq{XUA(eE7>ED> diff --git a/src/main/java/com/.DS_Store b/src/main/java/com/.DS_Store index 9de05b01ad8ba8c48bcaf2c0e0e9938645c2291c..84d88e58dccb55142d25d40a41f9323c2d6daed9 100644 GIT binary patch delta 78 zcmZoMXffEJ!^qUTX|f)poX%D+HD|;2qmB#=4D1Zq45bXk44Dii47m)&x%nwBNjdpR dKp75*s>v0MN{kmaFJw$(o7lj%nVsV=KLBcX7Qg@i delta 78 zcmZoMXffEJ!^q_CJXw!XPA8u++rY5xs3QXd13N=DLn%WsLncEBLoP#cZhneOQcivn dP=*7dYH|gm5~IWBg^X!z6C2nzvvd6A2LKad6vqGn diff --git a/src/main/java/com/kusitms/.DS_Store b/src/main/java/com/kusitms/.DS_Store index e73727923fdd16e2525118bb0c74d4f72763efca..eaacec889abb8aaaba070e6601371ca70abc5c88 100644 GIT binary patch delta 78 zcmZoMXffEJ#mH2;Zn6%e3|rhKW+$We$$pG->Ja8pM+OE4Hij&QOojr6B!)zWf`Sag d;N<+=0-!hp1Mh~-3mMbcCN}VGX6N|J4*+6X6~+Jn delta 78 zcmZoMXffEJ#mHoCKUs%ShK;Y`plM~>WIskZbqMpQBLf2i8$%XDCPM*35apJYAFuzj+dKm^lfp2-UY zB-ke8cK92&Pu?dW1!LY5kYSuK`L}=qW7T9CK^Zo`tZW0rw#jyaFBIxef(=e%$Opm{ zWP?qwhcp?tZ*~)sVyvII2B?Y^sG^7=g&~!p2w5G!_=g!r?MEHaRiwb3h+RcNhGB4W zer^F!9|Hpum}Frn0NPQ^P?D35B*(zaXgc|UumszjnDuNxkNp!)VDk7hIYC5$V>W}J zS}D+OAV+NSJP|H7h`{7^A}aL5TYtKMKI#*VP-xl&R$U5Iix$8R-`t9T5y2+L R#-4)RViKK3eV6@X1OU@_vsnND delta 667 zcmZp1XmQw}CZG@##K6G7!jQ;N%22|Pk(=-0l9ZF51Qg?Fn93dbrfssDKm^memy;I= zNU-txXB!x{P2MLU#kR>+F8y@v~8#nmRdLNOp6G5D#PhvQI!MR-kYZLkdGGLlLr-2WK8Mt!z8$h^`_9?x>w{$?mGH z=qd^_41<&Na|?j_7#NrmKqL!80nm(9+c_z1fS6d%bmP5?Q81!#RLrkA(^CKrfGuz50_QdOy++$S2L&?pC1T?$l- b7Ql~|g5q>Dn;08=3U-T0bQ<+t_Ky(&GncW9 diff --git a/src/main/java/com/kusitms/jipbap/auth/.DS_Store b/src/main/java/com/kusitms/jipbap/auth/.DS_Store index e91f201e31ee7051a2f28ce15704fa0d3b785312..f7e3a5e1e657123e20fef48669724a3bd12b87d8 100644 GIT binary patch delta 90 zcmZoMXffEJ!X(Fkg@J*AnIVOtgdsmS-^C>z>% delta 90 zcmZoMXffEJ!Xziq$H2hA%#gxR!jPYv@8Xh_lb-|>;rQm7ZD80o*@-ERiKSrj877Iz nyO_Ax?u2@@NY+n2#iRmbeqmB$OxUc*{ETH{0o!JFj=%f>hrJuQ diff --git a/src/main/java/com/kusitms/jipbap/chat/.DS_Store b/src/main/java/com/kusitms/jipbap/chat/.DS_Store index 53a30001fa524e97226eccf2337f36c591a7c4fa..6bbfb8a7e2da16575786ad4986f5a3366a909ced 100644 GIT binary patch delta 137 zcmZoMXffEJ&B7=<1=*gw4$pO%7z4(DF<=b*PX=&jvlQ!sHX8%R zfHBZAz~_UJR}6}cAS@6ku0U~h+G03yhu-VHpx6kC zJ2`DWoM!%PUR=tK_&#kX7X)oK28@B6fq^`Z`2OF=C)3;H=PveS3>X7{i~%<+r{x4M zrFZMM*W}w DdIm redisTemplateMessage; + private final MessageRepository messageRepository; + private final ObjectMapper objectMapper; + + @Async + public void saveMessage(MessageDto messageDto, Room room) { + // DB 저장 + Message message = messageRepository.save(new Message(messageDto.getSenderName(), room, messageDto.getMessage())); + message.updateSentTime(message.getCreatedAt().toString()); + + // 1. 직렬화 + redisTemplateMessage.setValueSerializer(new GenericJackson2JsonRedisSerializer(objectMapper)); + + // 2. redis 저장 + redisTemplateMessage.opsForList().rightPush(messageDto.getRoomId(), messageDto); + + // 3. redistemplate의 expire() 을 이용해서, Key 를 만료시킬 수 있음 + redisTemplateMessage.expire(messageDto.getRoomId(), 60, TimeUnit.MINUTES); + } +} \ No newline at end of file diff --git a/src/main/java/com/kusitms/jipbap/chat/service/MessageService.java b/src/main/java/com/kusitms/jipbap/chat/service/MessageService.java index 20e0302..646eabd 100644 --- a/src/main/java/com/kusitms/jipbap/chat/service/MessageService.java +++ b/src/main/java/com/kusitms/jipbap/chat/service/MessageService.java @@ -1,23 +1,20 @@ package com.kusitms.jipbap.chat.service; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.kusitms.jipbap.chat.exception.RoomNotExistsException; import com.kusitms.jipbap.chat.model.dto.MessageDto; import com.kusitms.jipbap.chat.model.entity.Message; import com.kusitms.jipbap.chat.model.entity.Room; -import com.kusitms.jipbap.chat.exception.RoomNotExistsException; import com.kusitms.jipbap.chat.repository.MessageRepository; import com.kusitms.jipbap.chat.repository.RoomRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.TimeUnit; @Slf4j @Service @@ -26,7 +23,7 @@ public class MessageService { private final RedisTemplate redisTemplateMessage; private final MessageRepository messageRepository; private final RoomRepository roomRepository; - private final ObjectMapper objectMapper; + private final MessageReleaseService messageReleaseService; // 메세지 저장 @Transactional @@ -35,18 +32,7 @@ public void saveMessage(MessageDto messageDto) { ()->new RoomNotExistsException("채팅방이 더 이상 존재하지 않습니다.") ); - // DB 저장 - Message message = messageRepository.save(new Message(messageDto.getSenderName(), room, messageDto.getMessage())); - message.updateSentTime(message.getCreatedAt().toString()); - - // 1. 직렬화 - redisTemplateMessage.setValueSerializer(new GenericJackson2JsonRedisSerializer(objectMapper)); - - // 2. redis 저장 - redisTemplateMessage.opsForList().rightPush(messageDto.getRoomId(), messageDto); - - // 3. redistemplate의 expire() 을 이용해서, Key 를 만료시킬 수 있음 - redisTemplateMessage.expire(messageDto.getRoomId(), 60, TimeUnit.MINUTES); + messageReleaseService.saveMessage(messageDto, room); } // 6. 대화 조회 - Redis & DB (TLB 캐시전략 유사) diff --git a/src/main/java/com/kusitms/jipbap/common/.DS_Store b/src/main/java/com/kusitms/jipbap/common/.DS_Store index 354ab02bac678b551f64b32f0b30c86288b5b452..50b55319acd4ff0e4344e63d56980e82b2ae9a98 100644 GIT binary patch delta 30 mcmZoMXffEZjfqJ#fARw+vB~F{xY&;QE`KT6zWE-LnkWFTGYe(_ delta 26 icmZoMXffEZjfqL*$K(f0Vw2A?aZO^D+5Ck`KokIns|i*B