Skip to content

Commit

Permalink
Merge pull request #619 from tukcomCD2024/refact/remove_non_use-notif…
Browse files Browse the repository at this point in the history
…ication-B-#617

refact : 알림 서버 사용하지 않는 클래스, 의존 제거 #617
  • Loading branch information
seokho-1116 authored Aug 11, 2024
2 parents dd928b3 + 0deeb62 commit 9e5761f
Show file tree
Hide file tree
Showing 27 changed files with 390 additions and 293 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
package site.timecapsulearchive.notification.global.config;
package site.timecapsulearchive.notification.global.config.rabbitmq;

import java.util.Arrays;
import lombok.Getter;

@Getter
public enum RabbitmqComponentConstants {

CAPSULE_SKIN_QUEUE("notification.createCapsuleSkin.queue",
CAPSULE_SKIN_NOTIFICATION_QUEUE("notification.createCapsuleSkin.queue",
"fail.notification.createCapsuleSkin.queue"),
CAPSULE_SKIN_EXCHANGE("notification.createCapsuleSkin.exchange",
CAPSULE_SKIN_NOTIFICATION_EXCHANGE("notification.createCapsuleSkin.exchange",
"fail.notification.createCapsuleSkin.exchange"),
FRIEND_REQUEST_NOTIFICATION_QUEUE("notification.friendRequest.queue",
"fail.notification.friendRequest.queue"),
FRIEND_REQUEST_NOTIFICATION_EXCHANGE("notification.friendRequest.exchange",
"fail.notification.friendRequest.exchange"),
FRIEND_REQUESTS_NOTIFICATION_QUEUE("notification.friendRequests.queue",
"fail.notification.friendRequests.queue"),
FRIEND_REQUESTS_NOTIFICATION_EXCHANGE("notification.friendRequests.exchange",
"fail.notification.friendRequests.exchange"),
BATCH_FRIEND_REQUESTS_NOTIFICATION_QUEUE("batch.notification.friendRequests.queue",
"fail.batch.notification.friendRequests.queue"),
BATCH_FRIEND_REQUESTS_NOTIFICATION_EXCHANGE("batch.notification.friendRequests.exchange",
"fail.batch.notification.friendRequests.exchange"),
FRIEND_ACCEPT_NOTIFICATION_QUEUE("notification.friendAccept.queue",
"fail.notification.friendAccept.queue"),
FRIEND_ACCEPT_NOTIFICATION_EXCHANGE("notification.friendAccept.exchange",
"fail.notification.friendAccept.exchange"),
GROUP_INVITE_QUEUE("notification.groupInvite.queue", "fail.notification.groupInvite.queue"),
GROUP_INVITE_EXCHANGE("notification.groupInvite.exchange",
GROUP_INVITE_NOTIFICATION_QUEUE("notification.groupInvite.queue",
"fail.notification.groupInvite.queue"),
GROUP_INVITE_NOTIFICATION_EXCHANGE("notification.groupInvite.exchange",
"fail.notification.groupInvite.exchange"),
GROUP_ACCEPT_NOTIFICATION_QUEUE("notification.groupAccept.queue",
"fail.notification.groupAccept.queue"),
Expand All @@ -37,12 +38,4 @@ public enum RabbitmqComponentConstants {
this.successComponent = successComponent;
this.failComponent = failComponent;
}

public static String getFailComponent(String successComponent) {
return Arrays.stream(RabbitmqComponentConstants.values())
.filter(constants -> constants.getSuccessComponent().equals(successComponent))
.map(RabbitmqComponentConstants::getFailComponent)
.toList()
.get(0);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package site.timecapsulearchive.notification.global.config;
package site.timecapsulearchive.notification.global.config.rabbitmq;

import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
Expand All @@ -7,7 +7,9 @@
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
Expand All @@ -24,13 +26,17 @@ public class RabbitmqConfig {

@Bean
public Queue capsuleSkinQueue() {
return new Queue(RabbitmqComponentConstants.CAPSULE_SKIN_QUEUE.getSuccessComponent(), true);
return QueueBuilder.durable(
RabbitmqComponentConstants.CAPSULE_SKIN_NOTIFICATION_QUEUE.getSuccessComponent())
.withArgument("x-dead-letter-exchange",
RabbitmqComponentConstants.CAPSULE_SKIN_NOTIFICATION_EXCHANGE.getFailComponent())
.build();
}

@Bean
public DirectExchange capsuleSkinExchange() {
return new DirectExchange(
RabbitmqComponentConstants.CAPSULE_SKIN_EXCHANGE.getSuccessComponent());
RabbitmqComponentConstants.CAPSULE_SKIN_NOTIFICATION_EXCHANGE.getSuccessComponent());
}

@Bean
Expand All @@ -43,13 +49,17 @@ public Binding capsuleSkinBinding() {

@Bean
public Queue groupInviteQueue() {
return new Queue(RabbitmqComponentConstants.GROUP_INVITE_QUEUE.getSuccessComponent(), true);
return QueueBuilder.durable(
RabbitmqComponentConstants.GROUP_INVITE_NOTIFICATION_QUEUE.getSuccessComponent())
.withArgument("x-dead-letter-exchange",
RabbitmqComponentConstants.GROUP_INVITE_NOTIFICATION_EXCHANGE.getFailComponent())
.build();
}

@Bean
public DirectExchange groupInviteExchange() {
return new DirectExchange(
RabbitmqComponentConstants.GROUP_INVITE_EXCHANGE.getSuccessComponent());
RabbitmqComponentConstants.GROUP_INVITE_NOTIFICATION_EXCHANGE.getSuccessComponent());
}

@Bean
Expand All @@ -62,8 +72,11 @@ public Binding groupInviteBinding() {

@Bean
public Queue groupAcceptQueue() {
return new Queue(
RabbitmqComponentConstants.GROUP_ACCEPT_NOTIFICATION_QUEUE.getSuccessComponent(), true);
return QueueBuilder.durable(
RabbitmqComponentConstants.GROUP_ACCEPT_NOTIFICATION_QUEUE.getSuccessComponent())
.withArgument("x-dead-letter-exchange",
RabbitmqComponentConstants.GROUP_ACCEPT_NOTIFICATION_EXCHANGE.getFailComponent())
.build();
}

@Bean
Expand All @@ -82,9 +95,11 @@ public Binding groupAcceptBinding() {

@Bean
public Queue friendRequestQueue() {
return new Queue(
RabbitmqComponentConstants.FRIEND_REQUEST_NOTIFICATION_QUEUE.getSuccessComponent(),
true);
return QueueBuilder.durable(
RabbitmqComponentConstants.FRIEND_REQUEST_NOTIFICATION_QUEUE.getSuccessComponent())
.withArgument("x-dead-letter-exchange",
RabbitmqComponentConstants.FRIEND_REQUEST_NOTIFICATION_EXCHANGE.getFailComponent())
.build();
}

@Bean
Expand All @@ -103,9 +118,11 @@ public Binding friendRequestBinding() {

@Bean
public Queue friendAcceptQueue() {
return new Queue(
RabbitmqComponentConstants.FRIEND_ACCEPT_NOTIFICATION_QUEUE.getSuccessComponent(),
true);
return QueueBuilder.durable(
RabbitmqComponentConstants.FRIEND_ACCEPT_NOTIFICATION_QUEUE.getSuccessComponent())
.withArgument("x-dead-letter-exchange",
RabbitmqComponentConstants.FRIEND_ACCEPT_NOTIFICATION_EXCHANGE.getFailComponent())
.build();
}

@Bean
Expand All @@ -123,18 +140,41 @@ public Binding friendAcceptBinding() {
}

@Bean
public RabbitTemplate rabbitTemplate() {
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory());
rabbitTemplate.setMessageConverter(jsonMessageConverter());
public Queue batchFriendRequestsQueue() {
return QueueBuilder.durable(
RabbitmqComponentConstants.BATCH_FRIEND_REQUESTS_NOTIFICATION_QUEUE.getSuccessComponent())
.withArgument("x-dead-letter-exchange",
RabbitmqComponentConstants.BATCH_FRIEND_REQUESTS_NOTIFICATION_EXCHANGE.getFailComponent())
.build();
}

return rabbitTemplate;
@Bean
public DirectExchange batchFriendRequestsExchange() {
return new DirectExchange(
RabbitmqComponentConstants.BATCH_FRIEND_REQUESTS_NOTIFICATION_EXCHANGE.getSuccessComponent());
}

@Bean
public Binding batchFriendRequestsBinding() {
return BindingBuilder
.bind(batchFriendRequestsQueue())
.to(batchFriendRequestsExchange())
.withQueueName();
}

@Bean
public Jackson2JsonMessageConverter jsonMessageConverter() {
return new Jackson2JsonMessageConverter();
}

@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() {
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
factory.setConnectionFactory(connectionFactory());
factory.setMessageConverter(jsonMessageConverter());
return factory;
}

@Bean
public CachingConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
Expand All @@ -155,4 +195,11 @@ public CachingConnectionFactory connectionFactory() {

return connectionFactory;
}

@Bean
public RabbitTemplate rabbitTemplate() {
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory());
rabbitTemplate.setMessageConverter(jsonMessageConverter());
return rabbitTemplate;
}
}
Loading

0 comments on commit 9e5761f

Please sign in to comment.