April 2018
Intermediate to advanced
432 pages
10h 38m
English
As you probably remember, account-service and product-service have been receiving events from order-service and then sending back the response message. We have created the OrderSender bean, which was responsible for preparing the response payload and sending it to the output channel. It turns out that the implementation may be simpler if we return the response object in method and annotate it with @SentTo:
@StreamListener(Processor.INPUT)@SendTo(Processor.OUTPUT)public Order receiveAndSendOrder(Order order) throws JsonProcessingException { LOGGER.info("Order received: {}", mapper.writeValueAsString(order)); return service.process(order);}
We can even imagine such an implementation, such as the following, without using @StreamListener ...