Skip to content

Commit

Permalink
fix : rabbitmq 데드레터 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-1116 committed Aug 10, 2024
1 parent a7f10a3 commit c44db9c
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -12,21 +12,21 @@ public class RabbitFailedComponentConfig {

@Bean
public Queue capsuleSkinFailQueue() {
return new Queue(RabbitmqComponentConstants.CAPSULE_SKIN_QUEUE.getFailComponent(), true);
return new Queue(
RabbitmqComponentConstants.CAPSULE_SKIN_QUEUE.getFailComponent(), true);
}

@Bean
public DirectExchange capsuleSkinFailExchange() {
return new DirectExchange(
public FanoutExchange capsuleSkinFailExchange() {
return new FanoutExchange(
RabbitmqComponentConstants.CAPSULE_SKIN_EXCHANGE.getFailComponent());
}

@Bean
public Binding capsuleSkinFailBinding() {
return BindingBuilder
.bind(capsuleSkinFailQueue())
.to(capsuleSkinFailExchange())
.withQueueName();
.to(capsuleSkinFailExchange());
}

@Bean
Expand All @@ -36,39 +36,39 @@ public Queue groupInviteFailQueue() {
}

@Bean
public DirectExchange groupInviteFailExchange() {
return new DirectExchange(
public FanoutExchange groupInviteFailExchange() {
return new FanoutExchange(
RabbitmqComponentConstants.GROUP_INVITE_NOTIFICATION_EXCHANGE.getFailComponent());
}

@Bean
public Binding groupInviteFailBinding() {
return BindingBuilder
.bind(groupInviteFailQueue())
.to(groupInviteFailExchange())
.withQueueName();
.to(groupInviteFailExchange());
}


@Bean
public Queue groupAcceptFailQueue() {
return new Queue(
RabbitmqComponentConstants.GROUP_ACCEPT_NOTIFICATION_QUEUE.getFailComponent(), true);
}

@Bean
public DirectExchange groupAcceptFailExchange() {
return new DirectExchange(
public FanoutExchange groupAcceptFailExchange() {
return new FanoutExchange(
RabbitmqComponentConstants.GROUP_ACCEPT_NOTIFICATION_EXCHANGE.getFailComponent());
}

@Bean
public Binding groupAcceptFailBinding() {
return BindingBuilder
.bind(groupAcceptFailQueue())
.to(groupAcceptFailExchange())
.withQueueName();
.to(groupAcceptFailExchange());
}


@Bean
public Queue friendRequestFailQueue() {
return new Queue(
Expand All @@ -77,17 +77,16 @@ public Queue friendRequestFailQueue() {
}

@Bean
public DirectExchange friendRequestFailExchange() {
return new DirectExchange(
public FanoutExchange friendRequestFailExchange() {
return new FanoutExchange(
RabbitmqComponentConstants.FRIEND_REQUEST_NOTIFICATION_EXCHANGE.getFailComponent());
}

@Bean
public Binding friendRequestFailBinding() {
return BindingBuilder
.bind(friendRequestFailQueue())
.to(friendRequestFailExchange())
.withQueueName();
.to(friendRequestFailExchange());
}

@Bean
Expand All @@ -98,16 +97,35 @@ public Queue friendAcceptFailQueue() {
}

@Bean
public DirectExchange friendAcceptFailExchange() {
return new DirectExchange(
public FanoutExchange friendAcceptFailExchange() {
return new FanoutExchange(
RabbitmqComponentConstants.FRIEND_ACCEPT_NOTIFICATION_EXCHANGE.getFailComponent());
}

@Bean
public Binding friendAcceptFailBinding() {
return BindingBuilder
.bind(friendAcceptFailQueue())
.to(friendAcceptFailExchange())
.withQueueName();
.to(friendAcceptFailExchange());
}

@Bean
public Queue batchFriendRequestsFailQueue() {
return new Queue(
RabbitmqComponentConstants.BATCH_FRIEND_REQUESTS_NOTIFICATION_QUEUE.getFailComponent(),
true);
}

@Bean
public FanoutExchange batchFriendRequestsFailExchange() {
return new FanoutExchange(
RabbitmqComponentConstants.BATCH_FRIEND_REQUESTS_NOTIFICATION_EXCHANGE.getFailComponent());
}

@Bean
public Binding batchFriendRequestsFailBinding() {
return BindingBuilder
.bind(batchFriendRequestsFailQueue())
.to(batchFriendRequestsFailExchange());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
Expand Down Expand Up @@ -43,10 +44,14 @@ public Binding capsuleSkinBinding() {
.withQueueName();
}


@Bean
public Queue groupInviteQueue() {
return new Queue(
RabbitmqComponentConstants.GROUP_INVITE_NOTIFICATION_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
Expand All @@ -65,8 +70,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 @@ -85,9 +93,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 @@ -104,45 +114,49 @@ public Binding friendRequestBinding() {
.withQueueName();
}

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

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

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

@Bean
public Queue friendAcceptQueue() {
return new Queue(
RabbitmqComponentConstants.FRIEND_ACCEPT_NOTIFICATION_QUEUE.getSuccessComponent(),
true);
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();
}

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

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

Expand Down

0 comments on commit c44db9c

Please sign in to comment.