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.
Asked
Active
Viewed 3,153 times
1 Answers
7
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.

Gary Russell
- 166,535
- 14
- 146
- 179
-
1"Of course, that app can use s-c-s to do its work." - Could you please elaborate a little? – Tony E. Stark Jun 07 '16 at 18:49
-
I meant that, on the client side, you could write a spring cloud stream app that binds an output channel to the request destination and an input channel to the reply destination. On the server side you'd do the opposite. However, the client side would have to do its own request/reply correlation, so it would probably be easier to use an outbound gateway on the client side which handles the correlation internally. – Gary Russell Jun 07 '16 at 18:56
-
"outbound gateway" - from Spring Integration or Spring Cloud Stream? Would it be too much to ask for a simple example of a request/reply scenario using Cloud Stream? – Tony E. Stark Jun 07 '16 at 19:09
-
From Spring Integration - as I said in the answer, spring-cloud-stream is really intended for assembling a pipeline. – Gary Russell Jun 07 '16 at 19:10
-
Is spring cloud stream similar function as spring cloud data flow? – alltej Jan 28 '18 at 05:00
-
1They are different, from [the Spring Cloud Data Flow project page](https://cloud.spring.io/spring-cloud-dataflow/) "Spring Cloud Data Flow is a toolkit for building data integration and real-time data processing pipelines. Pipelines consist of Spring Boot apps, built using the Spring Cloud Stream or Spring Cloud Task microservice frameworks. This makes Spring Cloud Data Flow suitable for a range of data processing use cases, from import/export to event streaming and predictive analytics.". So data flow is used to wire together Spring Cloud Stream apps. In future ask a new question instead. – Gary Russell Jan 28 '18 at 15:35