Transformation

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 ...

Get Mastering Spring Cloud now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.