From e16cb0492890777ed4532e2d6f1ebd733d5f8ec7 Mon Sep 17 00:00:00 2001 From: bravin Date: Mon, 19 May 2025 21:42:49 -0400 Subject: [PATCH 1/2] CHAT-72: to remove rabbitMQ in the main service as this has been moved . --- README.md | 18 +--- backend-service/pom.xml | 3 +- .../co/teamsphere/api/config/WebConfig.java | 21 ----- .../api/config/WebSocketConfig.java | 40 -------- .../api/controller/RealTimeMsgController.java | 92 ------------------- .../src/main/resources/application-dev.yml | 6 -- .../src/main/resources/application-local.yml | 8 +- .../src/main/resources/application-prod.yml | 8 +- .../src/main/resources/application.yml | 14 --- docker-compose.yml | 10 -- pom.xml | 5 - 11 files changed, 4 insertions(+), 221 deletions(-) delete mode 100644 backend-service/src/main/java/co/teamsphere/api/config/WebConfig.java delete mode 100644 backend-service/src/main/java/co/teamsphere/api/config/WebSocketConfig.java delete mode 100644 backend-service/src/main/java/co/teamsphere/api/controller/RealTimeMsgController.java diff --git a/README.md b/README.md index 3b36c00..25ab346 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Teamsphere Backend -Welcome to the backend of Teamsphere, a chat application built with Spring Boot. This application provides the core functionality for one-on-one chats, user authentication, and profile image storage. Future updates will include group chat functionality using web sockets with the STOMP protocol and RabbitMQ. +Welcome to the backend of Teamsphere, a chat application built with Spring Boot. This application provides the core functionality for one-on-one chats, user authentication, and profile image storage. Future updates will include group chat functionality using web sockets with the STOMP protocol. ## Table of Contents @@ -97,12 +97,6 @@ openssl pkcs8 -in keypair.pem -topk8 -nocrypt -inform PEM -outform PEM -out priv hibernate: ddl-auto: update show-sql: true - rabbitmq: - host: localhost - password: guest - port: 61613 - requested-heartbeat: 580 - username: guest servlet: multipart: max-file-size: 20MB @@ -121,16 +115,6 @@ openssl pkcs8 -in keypair.pem -topk8 -nocrypt -inform PEM -outform PEM -out priv MYSQL_DATABASE: teamsphere_db ports: - "3306:3306" - rabbitmq: - image: rabbitmq:management - environment: - RABBITMQ_DEFAULT_USER: guest - RABBITMQ_DEFAULT_PASS: guest - command: > - bash -c "rabbitmq-plugins enable rabbitmq_stomp && rabbitmq-server" - ports: - - "61613:61613" - - "15672:15672" ``` ## M-Chip MAC users diff --git a/backend-service/pom.xml b/backend-service/pom.xml index d3bbcb6..675356a 100644 --- a/backend-service/pom.xml +++ b/backend-service/pom.xml @@ -218,7 +218,6 @@ ${project.basedir}/checkstyle.xml - UTF-8 true true @@ -226,4 +225,4 @@ - \ No newline at end of file + diff --git a/backend-service/src/main/java/co/teamsphere/api/config/WebConfig.java b/backend-service/src/main/java/co/teamsphere/api/config/WebConfig.java deleted file mode 100644 index 9f7b5f9..0000000 --- a/backend-service/src/main/java/co/teamsphere/api/config/WebConfig.java +++ /dev/null @@ -1,21 +0,0 @@ -package co.teamsphere.api.config; - -import co.teamsphere.api.filters.LoggingFilter; -import org.springframework.boot.autoconfigure.security.SecurityProperties; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - - -@Configuration -public class WebConfig { - @Bean - public FilterRegistrationBean loggingFilterRegistration() { - FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); - registrationBean.setFilter(new LoggingFilter()); - registrationBean.addUrlPatterns("/*"); // Apply filter to all URLs - registrationBean.setName("LoggingFilter"); - registrationBean.setOrder(SecurityProperties.DEFAULT_FILTER_ORDER - 1); // Set order if multiple filters - return registrationBean; - } -} diff --git a/backend-service/src/main/java/co/teamsphere/api/config/WebSocketConfig.java b/backend-service/src/main/java/co/teamsphere/api/config/WebSocketConfig.java deleted file mode 100644 index 1b3f8dc..0000000 --- a/backend-service/src/main/java/co/teamsphere/api/config/WebSocketConfig.java +++ /dev/null @@ -1,40 +0,0 @@ -package co.teamsphere.api.config; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; -import org.springframework.messaging.simp.config.MessageBrokerRegistry; -import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; -import org.springframework.web.socket.config.annotation.StompEndpointRegistry; -import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; - -@Configuration -@EnableWebSocketMessageBroker -public class WebSocketConfig implements WebSocketMessageBrokerConfigurer{ - - @Value("${spring.rabbitmq.username}") - private String userName; - @Value("${spring.rabbitmq.password}") - private String password; - @Value("${spring.rabbitmq.host}") - private String host; - @Value("${spring.rabbitmq.port}") - private int port; - - @SuppressWarnings("null") - @Override - public void registerStompEndpoints(StompEndpointRegistry registry) { - registry.addEndpoint("/ws").setAllowedOriginPatterns("*").withSockJS(); - } - - @SuppressWarnings("null") - @Override - public void configureMessageBroker(MessageBrokerRegistry registry) { - registry.enableStompBrokerRelay("/group", "/user") - .setRelayHost(host) - .setRelayPort(port) - .setSystemLogin(userName) - .setSystemPasscode(password); - registry.setApplicationDestinationPrefixes("/app"); - registry.setUserDestinationPrefix("/user"); - } -} diff --git a/backend-service/src/main/java/co/teamsphere/api/controller/RealTimeMsgController.java b/backend-service/src/main/java/co/teamsphere/api/controller/RealTimeMsgController.java deleted file mode 100644 index 1ba2970..0000000 --- a/backend-service/src/main/java/co/teamsphere/api/controller/RealTimeMsgController.java +++ /dev/null @@ -1,92 +0,0 @@ -package co.teamsphere.api.controller; - -import co.teamsphere.api.exception.ChatException; -import co.teamsphere.api.exception.UserException; -import co.teamsphere.api.models.Chat; -import co.teamsphere.api.models.Messages; -import co.teamsphere.api.models.User; -import co.teamsphere.api.request.SendMessageRequest; -import co.teamsphere.api.services.ChatService; -import co.teamsphere.api.services.MessageService; -import co.teamsphere.api.services.UserService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.messaging.handler.annotation.Header; -import org.springframework.messaging.handler.annotation.MessageMapping; -import org.springframework.messaging.handler.annotation.Payload; -import org.springframework.messaging.handler.annotation.SendTo; -import org.springframework.messaging.handler.annotation.DestinationVariable; - -import org.springframework.messaging.simp.SimpMessagingTemplate; - -import java.util.Iterator; - -@Slf4j -public class RealTimeMsgController { - - private final SimpMessagingTemplate simpMessagingTemplate; - - private final UserService userService; - - private final MessageService messageService; - - private final ChatService chatService; - - public RealTimeMsgController(SimpMessagingTemplate simpMessagingTemplate, - UserService userService, - MessageService messageService, - ChatService chatService) { - this.simpMessagingTemplate = simpMessagingTemplate; - this.userService = userService; - this.messageService = messageService; - this.chatService = chatService; - } - - @MessageMapping("/message") - @SendTo("/group/public") - public Messages receiveMessage(@Payload Messages messages){ - - simpMessagingTemplate.convertAndSend("/group/"+ messages.getChat().getId().toString(), messages); - - return messages; - } - - @MessageMapping("/chat/{groupId}") - public Messages sendToUser(@Payload SendMessageRequest req, @Header("Authorization") String jwt, @DestinationVariable String groupId) throws ChatException, UserException { - try { - log.info("Processing send message request for userId= {} to group: {}", req.getUserId(), groupId); - - User user = userService.findUserProfile(jwt); - req.setUserId(user.getId()); - - Chat chat = chatService.findChatById(req.getChatId()); - - Messages createdMessages = messageService.sendMessage(req); - - User receiverUser = receiver(chat, user); - - simpMessagingTemplate.convertAndSendToUser(groupId, "/private", createdMessages); - - log.info("Message sent successfully to group: {} by userId: {}", groupId, req.getUserId()); - - return createdMessages; - } catch (ChatException e) { - log.error("Error during send message process", e); - throw new ChatException("Error during send message process" + e); - } catch (UserException e) { - log.error("Error during send message process", e); - throw new UserException("Error during send message process" + e); - } - } - - public User receiver(Chat chat, User reqUser) { - Iterator iterator = chat.getUsers().iterator(); - - User user1 = iterator.next(); // get first user - User user2 = iterator.next(); // get second user - - if(user1.getId().equals(reqUser.getId())){ - return user2; - } - return user1; - } -} diff --git a/backend-service/src/main/resources/application-dev.yml b/backend-service/src/main/resources/application-dev.yml index 4bdcb2f..9a7b9aa 100644 --- a/backend-service/src/main/resources/application-dev.yml +++ b/backend-service/src/main/resources/application-dev.yml @@ -25,12 +25,6 @@ spring: hibernate: ddl-auto: update show-sql: true - rabbitmq: - host: rabbitmq-dev - username: ${RABBITMQ_DEV_USERNAME} - password: ${RABBITMQ_DEV_PASSWORD} - port: 61613 - requested-heartbeat: 580 servlet: multipart: max-file-size: 20MB diff --git a/backend-service/src/main/resources/application-local.yml b/backend-service/src/main/resources/application-local.yml index 7c20144..6bc08e8 100644 --- a/backend-service/src/main/resources/application-local.yml +++ b/backend-service/src/main/resources/application-local.yml @@ -19,12 +19,6 @@ spring: hibernate: ddl-auto: update show-sql: true - rabbitmq: - host: localhost - username: ${RABBITMQ_USERNAME} - password: ${RABBITMQ_PASSWORD} - port: 61613 - requested-heartbeat: 580 servlet: multipart: max-file-size: 20MB @@ -43,4 +37,4 @@ management: include: health, info, metrics info: build: - enabled: true \ No newline at end of file + enabled: true diff --git a/backend-service/src/main/resources/application-prod.yml b/backend-service/src/main/resources/application-prod.yml index d8fb0a0..ad9b6cd 100644 --- a/backend-service/src/main/resources/application-prod.yml +++ b/backend-service/src/main/resources/application-prod.yml @@ -24,12 +24,6 @@ spring: database: mysql hibernate: ddl-auto: update - rabbitmq: - host: rabbitmq - username: ${RABBITMQ_USERNAME} - password: ${RABBITMQ_PASSWORD} - port: 61613 - requested-heartbeat: 580 servlet: multipart: max-file-size: 20MB @@ -38,4 +32,4 @@ spring: app: environment: ALLOWED_ORIGINS: - - ${ALLOWED_ORIGIN} \ No newline at end of file + - ${ALLOWED_ORIGIN} diff --git a/backend-service/src/main/resources/application.yml b/backend-service/src/main/resources/application.yml index f4f203c..4994c3a 100644 --- a/backend-service/src/main/resources/application.yml +++ b/backend-service/src/main/resources/application.yml @@ -21,17 +21,3 @@ spring: show-sql: true profiles: active: local - rabbitmq: - cache: - channel: - size: 10 - host: '' - password: '' - port: 15672 - requested-heartbeat: 580 - username: '' - virtual-host: '' -twilio: - accountSid: '' - authToken: '' - phoneNumber: '' \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b4167f1..bc497a0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,13 +7,3 @@ services: MYSQL_DATABASE: teamsphere_db ports: - "3306:3306" - rabbitmq: - image: rabbitmq:management - environment: - RABBITMQ_DEFAULT_USER: guest - RABBITMQ_DEFAULT_PASS: guest - command: > - bash -c "rabbitmq-plugins enable rabbitmq_stomp && rabbitmq-server" - ports: - - "61613:61613" - - "15672:15672" \ No newline at end of file diff --git a/pom.xml b/pom.xml index e210ecc..2043350 100644 --- a/pom.xml +++ b/pom.xml @@ -62,11 +62,6 @@ spring-dotenv 4.0.0 - - org.springframework.amqp - spring-amqp - 3.0.2 - io.netty netty-resolver-dns-native-macos From ca39291e269d5843dd0b8562a0a6460a97b6cb62 Mon Sep 17 00:00:00 2001 From: bravin Date: Mon, 19 May 2025 21:57:56 -0400 Subject: [PATCH 2/2] CHAT-72: to remove stomp protocol from README.md. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 25ab346..bdfc316 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Teamsphere Backend -Welcome to the backend of Teamsphere, a chat application built with Spring Boot. This application provides the core functionality for one-on-one chats, user authentication, and profile image storage. Future updates will include group chat functionality using web sockets with the STOMP protocol. +Welcome to the backend of Teamsphere, a chat application built with Spring Boot. This application provides the core functionality for one-on-one chats, user authentication, and profile image storage. Future updates will include group chat functionality using web sockets. ## Table of Contents