Skip to content

Commit

Permalink
feat: transaction 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
yunuo46 committed May 10, 2024
1 parent 5552955 commit 3514488
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/main/java/getaguitar/site/demo/Config/StompConfig.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package getaguitar.site.demo.Config;

import getaguitar.site.demo.Interceptor.StompHandler;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.ChannelRegistration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
Expand All @@ -12,7 +14,7 @@
@RequiredArgsConstructor
public class StompConfig implements WebSocketMessageBrokerConfigurer {

//final StompHandler stompHandler;
final StompHandler stompHandler;

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
Expand All @@ -24,8 +26,8 @@ public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.setApplicationDestinationPrefixes("/app");
}

// @Override
// public void configureClientInboundChannel(ChannelRegistration registration) {
// registration.interceptors(stompHandler);
// }
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
registration.interceptors(stompHandler);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.EventListener;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.socket.messaging.SessionConnectEvent;
import org.springframework.web.socket.messaging.SessionDisconnectEvent;

import java.util.Map;


@RestController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public void postSend(Message message, MessageChannel channel, boolean sent) {
case DISCONNECT:
LOGGER.info("sessionId Disconnected {}", sessionId);
break;
case null:
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import getaguitar.site.demo.Dto.ResUserDto;
import getaguitar.site.demo.Entity.UserEntity;
import getaguitar.site.demo.Repository.UserRepository;
import jakarta.transaction.Transactional;
import org.springframework.stereotype.Service;
import org.apache.commons.lang3.RandomStringUtils;

Expand All @@ -13,6 +14,7 @@ public APIServiceImpl(UserRepository userRepository) {
}

@Override
@Transactional
public ResUserDto getUser(){
String username = RandomStringUtils.randomAlphanumeric(5);
int id = userRepository.save(UserEntity.builder()
Expand Down

0 comments on commit 3514488

Please sign in to comment.