Comments on: Building and testing message-driven microservices using Spring Cloud Stream https://piotrminkowski.com/2018/06/15/building-and-testing-message-driven-microservices-using-spring-cloud-stream/ Java, Spring, Kotlin, microservices, Kubernetes, containers Fri, 01 Jan 2021 14:14:04 +0000 hourly 1 https://wordpress.org/?v=6.9.1 By: motivationmyselfblog https://piotrminkowski.com/2018/06/15/building-and-testing-message-driven-microservices-using-spring-cloud-stream/#comment-533 Wed, 12 Feb 2020 02:47:32 +0000 https://piotrminkowski.wordpress.com/?p=6678#comment-533 In reply to Piotr Mińkowski.

Example: In your demo, you have account-service and method to process order in account-service with the code below:
List accounts = accountRepository.findByCustomer(order.getCustomerId());
Account account = accounts.get(0);
LOGGER.info(“Account found: {}”, mapper.writeValueAsString(account));
if (order.getPrice() <= account.getBalance()) {
order.setStatus(OrderStatus.ACCEPTED);
account.setBalance(account.getBalance() – order.getPrice());
} else {
order.setStatus(OrderStatus.REJECTED);
}
orderSender.send(order);
LOGGER.info("Order response sent: {}", mapper.writeValueAsString(order));

But, once orderSender.send(order), I want to wait and get OrderId and return to the method like that:
Order orderResponse = orderSender.send(order);

In the RabbitMQ, we have already a method to do that. It's wait and receive response after send to queue
this.rabbitTemplate.convertSendAndReceive(RabbitmqApplication.EXCHANGE_NAME,
RabbitmqApplication.ROUTING_KEY, message);

So, Does have any way in Spring Cloud Stream to do like that?

]]>
By: Piotr Mińkowski https://piotrminkowski.com/2018/06/15/building-and-testing-message-driven-microservices-using-spring-cloud-stream/#comment-532 Tue, 11 Feb 2020 21:35:25 +0000 https://piotrminkowski.wordpress.com/?p=6678#comment-532 In reply to motivationmyselfblog.

Hi, I’m not sure what are you asking for. Generally you are able to send messages and receive them asynchronously by consumer.

]]>
By: motivationmyselfblog https://piotrminkowski.com/2018/06/15/building-and-testing-message-driven-microservices-using-spring-cloud-stream/#comment-531 Tue, 11 Feb 2020 10:49:10 +0000 https://piotrminkowski.wordpress.com/?p=6678#comment-531 Hi,
Does any capability of sending a request and receiving a reply exist in Spring Cloud Stream
Like call RestApi and retrieve response

]]>
By: Amit https://piotrminkowski.com/2018/06/15/building-and-testing-message-driven-microservices-using-spring-cloud-stream/#comment-530 Tue, 26 Mar 2019 15:07:25 +0000 https://piotrminkowski.wordpress.com/?p=6678#comment-530 Hi, Interesting use of messaging within microservices. I am not able to get your sample compiled. Are there any changes required to make it work.

]]>
By: Kamil Gregorczyk https://piotrminkowski.com/2018/06/15/building-and-testing-message-driven-microservices-using-spring-cloud-stream/#comment-529 Wed, 20 Jun 2018 05:32:34 +0000 https://piotrminkowski.wordpress.com/?p=6678#comment-529 In reply to Piotr Mińkowski.

Thanks, it would be really great as I haven’t found any examples which are similar to yours but with the reactive module. I replaced all modules with the reactive ones, changed controller etc. But what I didn’t know how to change is the OrderSender class, there’s no ReactiveSource or something similar.

]]>
By: Piotr Mińkowski https://piotrminkowski.com/2018/06/15/building-and-testing-message-driven-microservices-using-spring-cloud-stream/#comment-528 Tue, 19 Jun 2018 21:53:53 +0000 https://piotrminkowski.wordpress.com/?p=6678#comment-528 In reply to Kamil Gregorczyk.

Hi. Ok, the answer is that I wanted to show usage of “standard” version of Spring Cloud Stream. Maybe, I’ll describe reactive variant in one of future articles.

]]>
By: Kamil Gregorczyk https://piotrminkowski.com/2018/06/15/building-and-testing-message-driven-microservices-using-spring-cloud-stream/#comment-527 Tue, 19 Jun 2018 14:21:39 +0000 https://piotrminkowski.wordpress.com/?p=6678#comment-527 Why haven’t you used the reactive version of the spring-cloud-stream?

]]>