Skip to Content
Mastering Spring Cloud
book

Mastering Spring Cloud

by Piotr Mińkowski
April 2018
Intermediate to advanced content levelIntermediate to advanced
432 pages
10h 38m
English
Packt Publishing
Content preview from Mastering Spring Cloud

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microservices with Spring Boot and Spring Cloud - Second Edition

Microservices with Spring Boot and Spring Cloud - Second Edition

Magnus Larsson

Publisher Resources

ISBN: 9781788475433Supplemental Content