Closed sypark9646 closed 3 years ago
qc-server에서 큐 생성 후에 restTemplate 같은 걸 이용해서 이쪽으로
POST /queues
{
"queue_name": "q.example.name"
}
이런식으로 보내면 될까요?
@AMYMEME 넵!! 좋습니다
지금 post당 큐는 하나지만 post에 생성되는 댓글을 라우팅하는 exchange와 댓글 좋아요를 라우팅하는 exchange가 두개씩 생성됩니다. 그리고 테스트해보고 있는데, consumer쪽에서 routing key도 필요하길래
POST /queues
{
"QueueName": "q.example.name",
"DirectRoutingKey": "post.1",
"TopicRoutingKey:": "post.1.#"
}
이런식으로 보내려고합니다.
아 넵넵 감사합니다!
마찬가지로 post 삭제 시 큐 삭제를 위해
DELETE /queues
{
"QueueName": "q.example.name"
}
이런식으로 보냅니다.
수정된 MQ에 따라서 request Body를 바꾸려고 하는데, 혹시 댓글 공감 이벤트 때에 commentId만 필요하고 postId는 필요없나요?_?
넹 필요없을 것 같아요! 레디스에 이렇게 저장하지 않을까 싶네용
commentID1 : {postID1, likeCount, content, createdAt, updatedAt},
commentID2 : {postID2, likeCount, content, createdAt, updatedAt},
commentID3 : {postID3, likeCount, content, createdAt, updatedAt},
아하 그럼 post 상관없이 commentId는 고유한거군요 혹시 commentId는 uuid같은 string인가요?? 아님 그냥 Long인가요? 혹시 그냥 Long이면 버퍼오버플로우 우려는 없을까요??
혹시 commentId는 uuid같은 string인가요?? 아님 그냥 Long인가요? 혹시 그냥 Long이면 버퍼오버플로우 우려는 없을까요??
일단은 Long auto-increment 으로 두었는데 uuid로 하는 것이 좋겠네요 (버퍼오버플로우는 생각하지 않았어요) snowflake 을 사용해서 아이디를 만드는 방식이 겹치지 않고 짧은 길이의 아이디를 만들어주어서 이걸 사용해보면 어떨까합니다! comment를 정렬할 때에는 시간순으로 해야하니 createdAt, updatedAt을 추가적으로 저장하도록 할게요!
snowflake 을 사용해서 아이디를 만드는 방식이 겹치지 않고 짧은 길이의 아이디를 만들어주어서 이걸 사용해보면 어떨까합니다! comment를 정렬할 때에는 시간순으로 해야하니 createdAt, updatedAt을 추가적으로 저장하도록 할게요!
레디스 쪽에서 사용하신다는 거죠? 제 쪽에서는
{
"postId": 1,
"content": "content example",
"password": "password example",
"messageType": "register"
}
{
"commentId": "uuid-uuidform-uuid",
"messageType": "like"
}
이런식으로 큐에 넣으면 되나요?
아니면 register때 createAt이랑 updatedAt을 따로 전달해 주어야 하나요? 그리고 updateAt이면 댓글 수정 기능도 있는 것 같은데, 레디스에서 지원해주는건가요?
아 아니군요.. 제가 여기 서버를 호출할 필요 없이 그냥 큐에 넣으면 되네요.. 질문만 확인 부탁드립니다. 🙏
제 쪽에서는 이 맞을까요?
네 맞습니다!!
레디스에서 지원해주진 않고 제가 구현할까 했습니닷ㅋㅋupdateAt은 빼도 됩니다!! 댓글 수정을 구현하는건 생각하지않았어서ㅎ.ㅎ likeCount를 그냥 +1씩 update하게될 것 같아용
레디스에서 지원해주진 않고 제가 구현할까 했습니닷ㅋㅋupdateAt은 빼도 됩니다!!
넴 그럼 createAt은 전달해주면 되는거죠?? ㅋㅋ근데 그냥 궁금해서 그럼 구현은 어떤식으로 하나요? 메시지큐에 남아있으면 그 내용을 수정하고, 그렇지 않으면 레디스쪽 내용을 수정하는 식인가요??
넴 그럼 createAt은 전달해주면 되는거죠??
네넵!! 전달해주시면 저도 편할 것 같습니다!!
일반적으로는 어떻게 하는지 잘 모르겠지만 SET 할 때 NX이나 XX 옵션을 주면 되지 않을까 싶었어용ㅋㅋㅋ
http://redisgate.kr/redis/command/set.php 요건 관련 커맨드입니당ㅋㅋㅋ
네넵!! 전달해주시면 저도 편할 것 같습니다!!
읽어보니 괜찮을 것 같기두 하네요 댓글 수정 기능도 같이 할까요?
그리고 createAt을 localdatetime으로 하지 말고 timestamp로 하는건 어떤가요?
댓글 수정 기능도 같이 할까요? 그리고 createAt을 localdatetime으로 하지 말고 timestamp로 하는건 어떤가요?
네넹 좋습니다!! 그럼 register 타입은 이런식으로 주시는 것 맞나용??
{
"postId": 1,
"content": "content example",
"password": "password example",
"messageType": "register"
"timestamp": "2021-08-03~~~"
}
네넹 좋습니다!! 그럼 register 타입은 이런식으로 주시는 것 맞나용??
네! 그럴 것 같습니다 :) golang에서는 대문자로 받아야 참조 가능할텐데,
type User struct {
Name string `json:"name"`
Age int `json:"age"`
}
이런식으로 하면 json의 소문자를 알아서 객체로 변환 가능한 것으로 알고 있습니다!
팁 감사합니당!!👍👍
댓글 수정... queue 따로 만들어야겠죠??
{
"commentId": "uuid-uuidform-uuid",
"content": "content example",
"messageType": "update",
"timestamp": "2021-08-03~~~"
}
이렇게하면 될까요? password 처리는 따로 할 것 같아서 필드에서 제외시켰습니다.
앗 네네 좋아요!!