回复消息传递模式

回复消息传递模式

本文介绍了spring-cloud-stream 请求-回复消息传递模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种应与 spring-cloud-stream 一起使用的请求-回复模式?我可以在 spring-cloud-stream 上找到的所有文档都针对 MessageChannel.send 一劳永逸类型的生产者,我熟悉 spring-integration 中的 @MessagingGateway,但我不确定那会如何使用 spring-cloud-stream.当您有一个 REST POST 端点保存具有分配标识符的实体并且您需要将分配的标识符返回给调用者,但您仍然想使用消息传递时,这将非常有用.

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.

推荐答案

Spring Cloud Stream 目前没有任何请求/回复的概念.

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

把它看成是一个 unix 管道的类比 foo |酒吧|baz 其中每个应用程序"或微服务接受一些输入并将其转发到管道中的下一个元素.

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.

考虑一个独立的 spring-boot 应用程序,它利用 spring-integration 来处理请求/回复场景.当然,该应用程序可以使用 s-c-s 来完成它的工作.

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.

这篇关于spring-cloud-stream 请求-回复消息传递模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 02:48