Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
@Slf4j
@Service
@RequiredArgsConstructor
@Transactional
public class MessageUseCaseImpl implements MessageUseCase {

private final GetMessageService getMessageService;
Expand All @@ -42,6 +41,7 @@ public class MessageUseCaseImpl implements MessageUseCase {
private final SaveMusicService saveMusicService;
private final RedisTemplate<String, String> redisTemplate; // RedisTemplate 주입

@Transactional(readOnly = true)
@Override
public MessageResponse getMessage(UUID messageId) {

Expand All @@ -62,6 +62,7 @@ public PageResponse<MessageListResponse> getMessages(UUID userId, Pageable pagea
}

@Override
@Transactional
public void createMessage(SaveMessageRequest request) {

Board board = getBoardService.getBoardBySharedId(request.shareUri());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
import org.springframework.transaction.support.TransactionSynchronizationManager;

@Slf4j
@Service
@RequiredArgsConstructor
@Transactional
public class SaveMusicService {

private final MusicRepository musicRepository;
private final MusicEventProducer musicEventProducer;
private final MusicAsyncService musicAsyncService;

/**
* music 저장 전용 트랜잭션
* - 중복 시 DB 유니크 제약에 의해 실패
* - 실패해도 상위 트랜잭션(message)은 영향받지 않도록 REQUIRES_NEW
*/
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Music saveMusic(Music music) {
Music targetMusic;

Expand Down