This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feat: 주문 이벤트 listener-side의 MessageConverter 추가, Json 매퍼 추가 * Feat : 주문 이벤트 리스너 설정 * Format : Google Java Format * Refactor : Fanout 에서 적용안되는 routing key 삭제 * Refactor : Fanout 에서 적용안되는 routing key 삭제 * Format : Google Java Format Co-authored-by: github-actions <>
- Loading branch information
1 parent
b088a5a
commit 4e1bab7
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
delivery-relay-service/src/main/java/com/inbobwetrust/config/MessageQueueConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.inbobwetrust.config; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; | ||
import org.springframework.amqp.support.converter.MessageConverter; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class MessageQueueConfig { | ||
|
||
@Bean | ||
public MessageConverter messageConverter(ObjectMapper objectMapper) { | ||
return new Jackson2JsonMessageConverter(objectMapper.registerModule(new JavaTimeModule())); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...ry-relay-service/src/main/java/com/inbobwetrust/subscriber/DeliveryMessageSubscriber.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.inbobwetrust.subscriber; | ||
|
||
import com.inbobwetrust.domain.Delivery; | ||
import com.inbobwetrust.domain.ReceiverType; | ||
import com.inbobwetrust.domain.RelayRequest; | ||
import com.inbobwetrust.repository.RelayRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.amqp.rabbit.annotation.Exchange; | ||
import org.springframework.amqp.rabbit.annotation.Queue; | ||
import org.springframework.amqp.rabbit.annotation.QueueBinding; | ||
import org.springframework.amqp.rabbit.annotation.RabbitListener; | ||
import org.springframework.stereotype.Service; | ||
import reactor.core.publisher.Mono; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class DeliveryMessageSubscriber { | ||
public static final String shopExchange = "messageQueue.exchange.shop"; | ||
public static final String agencyExchange = "messageQueue.exchange.agency"; | ||
|
||
private final RelayRepository relayRepository; | ||
|
||
@RabbitListener( | ||
ackMode = "MANUAL", | ||
id = "addDeliveryMessageListener", | ||
bindings = @QueueBinding(value = @Queue, exchange = @Exchange("messageQueue.exchange.shop"))) | ||
public Mono<Void> processAddDeliveryMessage(Delivery delivery) { | ||
log.info("Consuming addDelivery ===> " + delivery); | ||
return relayRepository | ||
.save(new RelayRequest(ReceiverType.SHOP, delivery.getShopId(), delivery)) | ||
.then(); | ||
} | ||
|
||
@RabbitListener( | ||
ackMode = "MANUAL", | ||
id = "setRiderMessageListener", | ||
bindings = | ||
@QueueBinding(value = @Queue, exchange = @Exchange("messageQueue.exchange.agency"))) | ||
public Mono<Void> processSetRiderMessage(Delivery delivery) { | ||
log.info("Consuming setRider ===> " + delivery); | ||
return relayRepository | ||
.save(new RelayRequest(ReceiverType.AGENCY, delivery.getAgencyId(), delivery)) | ||
.then(); | ||
} | ||
} |