-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e18f9a
commit 79c2538
Showing
12 changed files
with
161 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/gwangjang/server/domain/subscribe/adapter/PublishSubscribeChange.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//package gwangjang.server.domain.subscribe.adapter; | ||
// | ||
//import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribeData; | ||
//import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribersByIssueDto; | ||
//import gwangjang.server.domain.subscribe.application.service.SubscribeReadUseCase; | ||
//import org.springframework.beans.factory.annotation.Autowired; | ||
//import org.springframework.cloud.stream.messaging.Source; | ||
//import org.springframework.messaging.support.MessageBuilder; | ||
//import org.springframework.stereotype.Component; | ||
// | ||
//import java.util.List; | ||
// | ||
//@Component | ||
//public class PublishSubscribeChange { | ||
// | ||
// @Autowired | ||
// private Source source; | ||
// @Autowired | ||
// private SubscribeReadUseCase subscribeReadUseCase; | ||
// | ||
// public void publishMemberChange() { | ||
// List<SubscribeData> allIssueBySubscribers = subscribeReadUseCase.getAllIssueBySubscribers(); | ||
// | ||
// source.output().send(MessageBuilder.withPayload(allIssueBySubscribers).build()); | ||
// } | ||
//} |
87 changes: 48 additions & 39 deletions
87
...main/java/gwangjang/server/domain/subscribe/adapter/consumer/message/KeywordChannels.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,53 @@ | ||
package gwangjang.server.domain.subscribe.adapter.consumer.message; | ||
import gwangjang.server.domain.auth.application.mapper.MemberMapper; | ||
import gwangjang.server.global.feign.dto.response.MemberDto; | ||
import gwangjang.server.domain.member.domain.entity.Member; | ||
import gwangjang.server.domain.member.domain.service.MemberQueryService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.util.function.Function; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class KeywordChannels { | ||
|
||
private final MemberQueryService memberQueryService; | ||
private final MemberMapper memberMapper; | ||
|
||
//package gwangjang.server.domain.subscribe.adapter.consumer.message; | ||
//import gwangjang.server.domain.auth.application.mapper.MemberMapper; | ||
//import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribeData; | ||
//import gwangjang.server.domain.subscribe.adapter.producer.web.dto.SubscribersByIssueDto; | ||
//import gwangjang.server.global.feign.dto.response.MemberDto; | ||
//import gwangjang.server.domain.member.domain.entity.Member; | ||
//import gwangjang.server.domain.member.domain.service.MemberQueryService; | ||
//import lombok.RequiredArgsConstructor; | ||
//import org.springframework.context.annotation.Bean; | ||
//import org.springframework.context.annotation.Configuration; | ||
// | ||
//import java.util.List; | ||
//import java.util.function.Consumer; | ||
//import java.util.function.Function; | ||
// | ||
//@Configuration | ||
//@RequiredArgsConstructor | ||
//public class KeywordChannels { | ||
// | ||
// private final MemberQueryService memberQueryService; | ||
// private final MemberMapper memberMapper; | ||
// | ||
//// @Bean | ||
//// public Function<String, String> uppercase() { // 메시지를 받아 처리한 후 결과를 반환 | ||
//// return message -> { | ||
//// // 메시지 처리 로직 | ||
//// return message.toUpperCase(); | ||
//// }; | ||
////} | ||
// @Bean | ||
// public Function<String, String> uppercase() { // 메시지를 받아 처리한 후 결과를 반환 | ||
// return message -> { | ||
// // 메시지 처리 로직 | ||
// return message.toUpperCase(); | ||
// }; | ||
//} | ||
// @Bean | ||
// public Consumer<String> receiveFromCommunity(Long memberId) { //메시지를 받아 처리하는 데 사용되지만 반환 값이 없 | ||
// public Consumer<List<SubscribeData>> receiveFromKeyword() { //메시지를 받아 처리하는 데 사용되지만 반환 값이 없 | ||
// return message -> { | ||
// // 메시지 처리 로직 ( 역직렬화 ) | ||
// System.out.println("Member Received: " + message); | ||
//// System.out.println("Member Received: " + message); | ||
// | ||
// | ||
// System.out.println("hihi"+message); | ||
// }; | ||
// } | ||
|
||
@Bean | ||
public Function<String, MemberDto> receiveFromKeyword() { | ||
return memberId -> { | ||
// memberId를 사용하여 Member 객체를 조회 | ||
Member member = memberQueryService.getMemberBySocialId(memberId); | ||
|
||
return memberMapper.mapToMemberDto(member); | ||
|
||
}; | ||
} | ||
} | ||
// | ||
//// @Bean | ||
//// public Function<String, SubscribersByIssueDto> receiveFromKeyword() { | ||
//// return memberId -> { | ||
//// // memberId를 사용하여 Member 객체를 조회 | ||
//// | ||
//// | ||
//// Member member = memberQueryService.getMemberBySocialId(memberId); | ||
//// | ||
//// return memberMapper.mapToMemberDto(member); | ||
//// | ||
//// }; | ||
//// } | ||
//} |
86 changes: 43 additions & 43 deletions
86
...ang/server/domain/subscribe/adapter/consumer/message/model/KeywordCustomDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
package gwangjang.server.domain.subscribe.adapter.consumer.message.model; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import gwangjang.server.global.feign.dto.response.MemberDto; | ||
import lombok.RequiredArgsConstructor; | ||
import org.apache.kafka.common.header.Headers; | ||
import org.apache.kafka.common.serialization.Deserializer; | ||
|
||
import java.util.Map; | ||
|
||
@RequiredArgsConstructor | ||
public class KeywordCustomDeserializer implements Deserializer<MemberDto> { | ||
|
||
private final ObjectMapper objectMapper; | ||
|
||
@Override | ||
public void configure(Map<String, ?> configs, boolean isKey) { | ||
Deserializer.super.configure(configs, isKey); | ||
} | ||
|
||
@Override | ||
public MemberDto deserialize(String topic, byte[] data) { | ||
if (data == null) { | ||
return null; | ||
} | ||
|
||
try { | ||
return objectMapper.readValue(data, MemberDto.class); | ||
} catch (Exception e) { | ||
throw new RuntimeException("Deserialization error: " + e.getMessage(), e); | ||
} | ||
} | ||
|
||
@Override | ||
public MemberDto deserialize(String topic, Headers headers, byte[] data) { | ||
return Deserializer.super.deserialize(topic, headers, data); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
Deserializer.super.close(); | ||
} | ||
} | ||
//package gwangjang.server.domain.subscribe.adapter.consumer.message.model; | ||
// | ||
//import com.fasterxml.jackson.databind.ObjectMapper; | ||
//import gwangjang.server.global.feign.dto.response.MemberDto; | ||
//import lombok.RequiredArgsConstructor; | ||
//import org.apache.kafka.common.header.Headers; | ||
//import org.apache.kafka.common.serialization.Deserializer; | ||
// | ||
//import java.util.Map; | ||
// | ||
//@RequiredArgsConstructor | ||
//public class KeywordCustomDeserializer implements Deserializer<MemberDto> { | ||
// | ||
// private final ObjectMapper objectMapper; | ||
// | ||
// @Override | ||
// public void configure(Map<String, ?> configs, boolean isKey) { | ||
// Deserializer.super.configure(configs, isKey); | ||
// } | ||
// | ||
// @Override | ||
// public MemberDto deserialize(String topic, byte[] data) { | ||
// if (data == null) { | ||
// return null; | ||
// } | ||
// | ||
// try { | ||
// return objectMapper.readValue(data, MemberDto.class); | ||
// } catch (Exception e) { | ||
// throw new RuntimeException("Deserialization error: " + e.getMessage(), e); | ||
// } | ||
// } | ||
// | ||
// @Override | ||
// public MemberDto deserialize(String topic, Headers headers, byte[] data) { | ||
// return Deserializer.super.deserialize(topic, headers, data); | ||
// } | ||
// | ||
// @Override | ||
// public void close() { | ||
// Deserializer.super.close(); | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/gwangjang/server/domain/subscribe/adapter/producer/web/dto/SubscribeData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package gwangjang.server.domain.subscribe.adapter.producer.web.dto; | ||
|
||
import lombok.*; | ||
|
||
@Setter | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class SubscribeData { | ||
private Long issueId; | ||
private Long count; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters