application.yaml şöyle olsun
spring:rabbitmq:host: localhostport: 5672username: guestpassword: guestcloud:stream:bindings:orderSubmissionInput:destination: orderSubmitted.exchangegroup: inventorymovementEventInput:destination: movementEvent.exchangegroup: inventory
Şöyle yaparız
public interface MessageChannels {static final String ORDER_SUBMISSION_INPUT = "orderSubmissionInput";static final String MOVEMENT_EVENT_INPUT = "movementEventInput";@Input(ORDER_SUBMISSION_INPUT)SubscribableChannel orderSubmissionChannel();@Input(MOVEMENT_EVENT_INPUT)SubscribableChannel movementEventChannel();}@Slf4j@Componentpublic class OrderListener {@StreamListener(MessageChannels.ORDER_SUBMISSION_INPUT)public void handleSubmittedOrder(Order order) {log.info("Order received - {}", order.toString());}}@Slf4j@Componentpublic class MovementEventListener {@StreamListener(MessageChannels.MOVEMENT_EVENT_INPUT)public void handleMovementEvent(MovementEvent event) {log.info("Movement event received - {}", event.toString());}}
Hiç yorum yok:
Yorum Gönder