-
Notifications
You must be signed in to change notification settings - Fork 0
[fix/#133-register-property] 매물 등록 로직 수정 #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HUIJAEKO
wants to merge
2
commits into
dev
Choose a base branch
from
fix/#133-register-property
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
61 changes: 61 additions & 0 deletions
61
src/main/java/com/example/Dingle/global/config/RabbitConfig.java
This file contains hidden or 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,61 @@ | ||
| package com.example.Dingle.global.config; | ||
|
|
||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import org.springframework.amqp.core.*; | ||
| import org.springframework.amqp.rabbit.annotation.EnableRabbit; | ||
| import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; | ||
| import org.springframework.amqp.rabbit.connection.ConnectionFactory; | ||
| import org.springframework.amqp.rabbit.core.RabbitTemplate; | ||
| import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
|
|
||
| @Configuration | ||
| @EnableRabbit | ||
| public class RabbitConfig { | ||
|
|
||
| public static final String EXCHANGE = "property.exchange"; | ||
| public static final String QUEUE = "property.created.queue"; | ||
| public static final String ROUTING_KEY = "property.created"; | ||
|
|
||
| @Bean | ||
| public DirectExchange propertyExchange() { | ||
| return new DirectExchange(EXCHANGE); | ||
| } | ||
|
|
||
| @Bean | ||
| public Queue propertyCreatedQueue() { | ||
| return QueueBuilder.durable(QUEUE).build(); | ||
| } | ||
|
|
||
| @Bean | ||
| public Binding propertyCreatedBinding(Queue propertyCreatedQueue, DirectExchange propertyExchange) { | ||
| return BindingBuilder.bind(propertyCreatedQueue) | ||
| .to(propertyExchange) | ||
| .with(ROUTING_KEY); | ||
| } | ||
|
|
||
| @Bean | ||
| public Jackson2JsonMessageConverter jackson2JsonMessageConverter(ObjectMapper objectMapper) { | ||
| return new Jackson2JsonMessageConverter(objectMapper); | ||
| } | ||
|
|
||
| @Bean | ||
| public RabbitTemplate rabbitTemplate(ConnectionFactory cf, Jackson2JsonMessageConverter converter) { | ||
| RabbitTemplate template = new RabbitTemplate(cf); | ||
| template.setMessageConverter(converter); | ||
| return template; | ||
| } | ||
|
|
||
| @Bean | ||
| public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory( | ||
| ConnectionFactory cf, | ||
| Jackson2JsonMessageConverter converter | ||
| ) { | ||
| SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); | ||
| factory.setConnectionFactory(cf); | ||
| factory.setMessageConverter(converter); | ||
| return factory; | ||
| } | ||
| } |
This file contains hidden or 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
16 changes: 16 additions & 0 deletions
16
src/main/java/com/example/Dingle/property/dto/PropertyCreatedEvent.java
This file contains hidden or 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,16 @@ | ||
| package com.example.Dingle.property.dto; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class PropertyCreatedEvent { | ||
|
|
||
| private Long propertyId; | ||
| private LocalDate createdAt; | ||
| } |
62 changes: 62 additions & 0 deletions
62
src/main/java/com/example/Dingle/property/service/PropertyAsyncOrchestrator.java
This file contains hidden or 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,62 @@ | ||
| package com.example.Dingle.property.service; | ||
|
|
||
| import com.example.Dingle.property.service.openAI.*; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.concurrent.ExecutorService; | ||
| import java.util.concurrent.Executors; | ||
| import java.util.concurrent.Future; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class PropertyAsyncOrchestrator { | ||
| private final EnvironmentExplanationService environmentExplanationService; | ||
| private final ConvenienceExplanationService convenienceExplanationService; | ||
| private final AccessibilityExplanationService accessibilityExplanationService; | ||
| private final NoiseExplanationService noiseExplanationService; | ||
| private final SafetyExplanationService safetyExplanationService; | ||
|
|
||
| public void process(Long propertyId) { | ||
| ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor(); | ||
|
|
||
| try { | ||
| Future<Void> f1 = executor.submit(() -> { | ||
| environmentExplanationService.evaluateAndDescribe(propertyId); | ||
| return null; | ||
| }); | ||
|
|
||
| Future<Void> f2 = executor.submit(() -> { | ||
| convenienceExplanationService.evaluateAndDescribe(propertyId); | ||
| return null; | ||
| }); | ||
|
|
||
| Future<Void> f3 = executor.submit(() -> { | ||
| accessibilityExplanationService.evaluateAndDescribe(propertyId); | ||
| return null; | ||
| }); | ||
|
|
||
| Future<Void> f4 = executor.submit(() -> { | ||
| noiseExplanationService.evaluateAndDescribe(propertyId); | ||
| return null; | ||
| }); | ||
|
|
||
| Future<Void> f5 = executor.submit(() -> { | ||
| safetyExplanationService.evaluateAndDescribe(propertyId); | ||
| return null; | ||
| }); | ||
|
|
||
| f1.get(); | ||
| f2.get(); | ||
| f3.get(); | ||
| f4.get(); | ||
| f5.get(); | ||
|
|
||
| } catch (Exception e) { | ||
| throw new RuntimeException("Property async processing failed", e); | ||
|
|
||
| } finally { | ||
| executor.close(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
19 changes: 19 additions & 0 deletions
19
src/main/java/com/example/Dingle/property/util/PropertyCreatedConsumer.java
This file contains hidden or 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,19 @@ | ||
| package com.example.Dingle.property.util; | ||
|
|
||
| import com.example.Dingle.global.config.RabbitConfig; | ||
| import com.example.Dingle.property.dto.PropertyCreatedEvent; | ||
| import com.example.Dingle.property.service.PropertyAsyncOrchestrator; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.amqp.rabbit.annotation.RabbitListener; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class PropertyCreatedConsumer { | ||
| private final PropertyAsyncOrchestrator orchestrator; | ||
|
|
||
| @RabbitListener(queues = RabbitConfig.QUEUE) | ||
| public void handle(PropertyCreatedEvent event) { | ||
| orchestrator.process(event.getPropertyId()); | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/example/Dingle/property/util/PropertyEventRelay.java
This file contains hidden or 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,25 @@ | ||
| package com.example.Dingle.property.util; | ||
|
|
||
| import com.example.Dingle.global.config.RabbitConfig; | ||
| import com.example.Dingle.property.dto.PropertyCreatedEvent; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.amqp.rabbit.core.RabbitTemplate; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.event.TransactionPhase; | ||
| import org.springframework.transaction.event.TransactionalEventListener; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class PropertyEventRelay { | ||
|
|
||
| private final RabbitTemplate rabbitTemplate; | ||
|
|
||
| @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
| public void on(PropertyCreatedEvent event) { | ||
| rabbitTemplate.convertAndSend( | ||
| RabbitConfig.EXCHANGE, | ||
| RabbitConfig.ROUTING_KEY, | ||
| event | ||
| ); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: D-ingle/backend
Length of output: 669
RabbitMQ 자격증명과 포트 바인딩 설정 개선 필요
Lines 32-33의 포트가 모든 인터페이스(0.0.0.0)에 바인딩되어 있고, Lines 35-36의
guest/guest자격증명이 하드코딩되어 있습니다. 로컬 개발환경에서도 다음을 권장합니다:127.0.0.1로 제한하여 로컬호스트 접근만 허용.env파일로 분리하여 버전 제어 대상에서 제외권장 수정안
.env파일에 추가:🤖 Prompt for AI Agents