How do you accomplish this when you have a synchronous client (ie a user waiting in his web browser)? Should the browser poll for the result? How could you possibly implement something like this in the real world?
How do you accomplish this when you have a synchronous client (ie a user waiting in his web browser)? Should the browser poll for the result? How could you possibly implement something like this in the real world?
BTW now that the browser supports websockets (a bidirectional protocol the rest of the world had since the 70s!), you don't have to poll.
Firstly my terse hand wavey statement was at least clear on the fact that it was talking about communication between services. It said nothing about web browsers or any other human interface.
But since this relatively narrow context is clearly the one which you can most relate to, I'll stay within it. If you think about it, the HTTP request/response cycle is actually an illusion of synchronous communication on top of a transport mechanism which is fundamentally asynchronous. It's an abstraction layer which shields you from the complexities of asynchronous communication. Broadly speaking this is known as the [request/response](https://en.wikipedia.org/wiki/Request%E2%80%93response) pattern.
HTTP by no means the only implementation of the request/response pattern. Even in asychronous messaging systems it's not unusual to see it implemented - https://www.enterpriseintegrationpatterns.com/patterns/messa....
But request/reply is just one of the patterns which exists in the realm of asynchronous communication. There are other, much more common patterns such as send/receive and publish/subscribe. Exploring these patterns opens up whole new approaches to software design.
I wholeheartedly recommend the book [Enterprise Integration Patterns](https://www.enterpriseintegrationpatterns.com/) by Gregor Hohpe and Bobby Woolf. It's quite old now but is still the best and most complete introduction to asynchronous design.
An alternative perspective is from the viewpoint of [Command Query Separation](https://en.wikipedia.org/wiki/Command%E2%80%93query_separati...), and it's relative at the architural level, [Command Query Responsibility Segregation](https://martinfowler.com/bliki/CQRS.html).