Skip to content

Commit

Permalink
chore: exchange, queue name change
Browse files Browse the repository at this point in the history
Related: #70
  • Loading branch information
hoa0217 committed Apr 5, 2024
1 parent 06b7f9f commit e7b1944
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class AlarmConsumer {
private final AlarmService alarmService;
private final ObjectMapper objectMapper;

@RabbitListener(queues = "q.reservation")
@RabbitListener(queues = "q.alarm.work")
public void handler(String message) {
log.info("AlarmEvent consume from q.reservation");
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class AlarmDLQConsumer {
@Value("${spring.rabbitmq.retry_count}")
private int retryCount;

@RabbitListener(queues = "q.reservation.dlx")
@RabbitListener(queues = "q.alarm.dead")
public void processFailedMessagesRequeue(Message failedMessage) {
Integer retriesCnt = (Integer) failedMessage.getMessageProperties().getHeaders()
.get(RETRY_COUNT_HEADER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void send(AlarmEvent alarmEvent) {
try {
log.info("AlarmEvent produce to x.reservation");
String message = objectMapper.writeValueAsString(alarmEvent);
rabbitTemplate.convertAndSend("x.reservation", "", message);
rabbitTemplate.convertAndSend("x.alarm.work", "", message);
} catch (JsonProcessingException e) {
throw new MessageParsingError();
}
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/com/modoospace/RabbitMQTestInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ static void initializeRabbitMQ(RabbitMQContainer container) {
}

static void createExchangeAndQueue(Channel channel) throws IOException {
channel.exchangeDeclare("x.reservation", BuiltinExchangeType.FANOUT);
channel.exchangeDeclare("x.reservation.dlx", BuiltinExchangeType.FANOUT);
channel.exchangeDeclare("x.alarm.work", BuiltinExchangeType.FANOUT);
channel.exchangeDeclare("x.alarm.dead", BuiltinExchangeType.FANOUT);

HashMap<String, Object> argumentsMap = new HashMap<>();
argumentsMap.put("x-dead-letter-exchange", "x.reservation.dlx");
channel.queueDeclare("q.reservation", false, false, false, argumentsMap);
channel.queueBind("q.reservation", "x.reservation", "");
argumentsMap.put("x-dead-letter-exchange", "x.alarm.dead");
channel.queueDeclare("q.alarm.work", false, false, false, argumentsMap);
channel.queueBind("q.alarm.work", "x.alarm.work", "");

channel.queueDeclare("q.reservation.dlx", false, false, false, null);
channel.queueBind("q.reservation.dlx", "x.reservation.dlx", "");
channel.queueDeclare("q.alarm.dead", false, false, false, null);
channel.queueBind("q.alarm.dead", "x.alarm.dead", "");
}
}

0 comments on commit e7b1944

Please sign in to comment.