-
Notifications
You must be signed in to change notification settings - Fork 7
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
RDS reader writer 적용 #701
RDS reader writer 적용 #701
Conversation
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.
초롱짱
궁금한거 물어봤어용
<root level="INFO"> | ||
<appender-ref ref="info-appender"/> |
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.
해당 부분은 앞으로도 계속 적용할 정책인가요? 아니면 데모데이 이후 변경될 예정인가요?
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.
해당 설정 파일이 잘 적용되는지 정도만 확인하고 삭제하겠습니다~
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.
초롱짱
저도 궁금한거 살짝쿵 적어봤어요 깔깔
|
||
@Override | ||
protected Object determineCurrentLookupKey() { | ||
boolean readOnly = TransactionSynchronizationManager.isCurrentTransactionReadOnly(); |
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.
새로운 트랜잭션인 경우, TransactionSynchronizationManager 에 새로운 트랜잭션을 등록합니다.
TransactionSynchronizationManager으로부터 지금 실행되는 트랜잭션이 readOnly으로 마킹되어있는지 체크하는가 보군요 신기방기
@ConfigurationProperties("spring.datasource.write") | ||
public DataSource writeDataSource() { | ||
return DataSourceBuilder.create().type(HikariDataSource.class).build(); | ||
} |
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.
따로 "spring.datasource.write" 값을 주입하는 코드가 없는데 자동으로 주입이 되는 건가요? 이것도 신기방기하네요
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.
ㄹㅇㄹㅇ 신기한게 한두개가 아님요
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.
아마 @ConfigurationProperties
를 리플렉션해서 주입해주는 코드가 내부에 있을 것 같네요
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.
reader / writer 라우팅을 어플리케이션 코드로 할 수 있다는게 진짜 신기하네용
사소한 궁금증 + 제안 하나 남겨두었으니 확인 부탁드려요!
DataSource readerDataSource = readeDataSource(); | ||
|
||
Map<Object, Object> dataSourceMap = new HashMap<>(); | ||
dataSourceMap.put("write", writerDataSource); |
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.
dataSourceMap.put("write", writerDataSource); | |
dataSourceMap.put(DataSourceRouter.WRITER_LOOKUP_KEY, writerDataSource); |
위의 키들은 DataSourceRouter
의 반환값과 맞춰 주어야 하는건가요??
그렇다면 오탈자 때문에 오류가 나는 것을 예방하기 위해 상수로 관리하는 것은 어떤가요??
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.
좋은데요???!
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.
초롱 짱 ~~ 신기방기네요 ~
Transactional 관련 코멘트 남겨뒀어요 확인부탁드려요 ~
@@ -52,6 +52,7 @@ public Page<Template> findAllBy( | |||
return templateRepository.findAll(new TemplateSpecification(memberId, keyword, categoryId, tagIds), pageable); | |||
} | |||
|
|||
@Transactional |
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.
위에 create에도 @transactional 해주세요 ~
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.
👍
⚡️ 관련 이슈
close #699
📍주요 변경 사항
@Transational(readOnly=true)
를 설정하면 Reader 인스턴스를 사용하게 되고,@Transactional
을 사용하거나 아예 사용하지 않으면 Writer 인스턴스를 사용합니다.