From a0708f641192bd51f66120d54c90fab8caf42bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=8A=B9=EC=A7=84?= Date: Mon, 11 Mar 2024 16:38:31 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT]=20deadletter=20queue=20=EA=B8=B0?= =?UTF-8?q?=EC=A1=B4=20=ED=81=90=EC=99=80=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../twtw/backend/config/rabbitmq/RabbitMQConfig.java | 10 ++++++++-- .../domain/notification/messagequeue/FcmConsumer.java | 8 ++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/com/twtw/backend/config/rabbitmq/RabbitMQConfig.java b/backend/src/main/java/com/twtw/backend/config/rabbitmq/RabbitMQConfig.java index 5cd84e44..9ffd0539 100644 --- a/backend/src/main/java/com/twtw/backend/config/rabbitmq/RabbitMQConfig.java +++ b/backend/src/main/java/com/twtw/backend/config/rabbitmq/RabbitMQConfig.java @@ -24,7 +24,10 @@ public class RabbitMQConfig { @Bean public Queue locationQueue() { - return new Queue(RabbitMQConstant.LOCATION_QUEUE.getName(), true); + return QueueBuilder.durable(RabbitMQConstant.LOCATION_QUEUE.getName()) + .withArgument("x-dead-letter-exchange", RabbitMQConstant.DEAD_LETTER_EXCHANGE.getName()) + .withArgument("x-dead-letter-routing-key", RabbitMQConstant.DEAD_LETTER_ROUTING_KEY.getName()) + .build(); } @Bean @@ -41,7 +44,10 @@ public Binding locationBinding() { @Bean public Queue notificationQueue() { - return new Queue(RabbitMQConstant.NOTIFICATION_QUEUE.getName(), true); + return QueueBuilder.durable(RabbitMQConstant.NOTIFICATION_QUEUE.getName()) + .withArgument("x-dead-letter-exchange", RabbitMQConstant.DEAD_LETTER_EXCHANGE.getName()) + .withArgument("x-dead-letter-routing-key", RabbitMQConstant.DEAD_LETTER_ROUTING_KEY.getName()) + .build(); } @Bean diff --git a/backend/src/main/java/com/twtw/backend/domain/notification/messagequeue/FcmConsumer.java b/backend/src/main/java/com/twtw/backend/domain/notification/messagequeue/FcmConsumer.java index 13301f5b..5674b15a 100644 --- a/backend/src/main/java/com/twtw/backend/domain/notification/messagequeue/FcmConsumer.java +++ b/backend/src/main/java/com/twtw/backend/domain/notification/messagequeue/FcmConsumer.java @@ -19,11 +19,7 @@ public FcmConsumer(FirebaseMessaging firebaseMessaging) { } @RabbitListener(queues = "notification.queue") - public void sendNotification(final NotificationRequest request) { - try { - firebaseMessaging.send(request.toMessage()); - } catch (FirebaseMessagingException e) { - log.error(e.getMessage()); - } + public void sendNotification(final NotificationRequest request) throws FirebaseMessagingException { + firebaseMessaging.send(request.toMessage()); } }