spring-cloud-stream request-reply messaging patter

2020-06-21 05:10发布

问题:

Is there a request-reply pattern that one should use with spring-cloud-stream? All the documentation I can find on spring-cloud-stream is geared toward the MessageChannel.send fire-and-forget type of producer, and I'm familiar with @MessagingGateway from spring-integration, but I'm not sure how that would work with spring-cloud-stream. That would be useful when you have a REST POST endpoint that saves an entity with an assigned identifier and you need to return the assigned identifier to the caller, but you still want to use messaging.

回答1:

There is not currently any notion of request/reply in spring cloud stream.

Consider it an analogy of a unix pipe foo | bar | baz where each "application" or microservice takes some input and forwards it to the next element in the pipe.

Consider a stand-alone spring-boot app utilizing spring-integration for request/reply scenarios. Of course, that app can use s-c-s to do its work.