我有一个服务器,它在交换上发布rabbitmq消息,因此我尝试创建以下异步api规范-
asyncapi: 2.3.0
info:
title: Hello World
version: 1.0.0
description: Get Hello World Messages
contact: {}
servers:
local:
url: amqp://rabbitmq
description: RabbitMQ
protocol: amqp
protocolVersion: 0.9.1
defaultContentType: application/json
channels:
hellow_world:
subscribe:
operationId: HelloWorldSubscriber
description:
message:
$ref: '#/components/messages/HellowWorldEvent'
bindings:
amqp:
ack: true
cc: ["hello_world_routing_key"]
bindingVersion: 0.2.0
bindings:
amqp:
is: routingKey
exchange:
name: hello_world_exchange
type: direct
durable: true
vhost: /
bindingVersion: 0.2.0
components:
messages:
HellowWorldEvent:
payload:
type: object
properties: []根据我的理解,它的意思是MyApp将使用路由密钥hello_world_routing_key在hello_world_exchange交换上发布helloworldevent消息。
问题-
发布于 2022-05-16 01:49:48
我看你还没有批准任何作为解决办法的答复。这仍然是个问题吗?您是否使用AsyncAPI生成器来生成代码存根?
如果是这样,生成器将创建一个使用者/订阅服务器。如果您想要不同的处理/业务逻辑,您将生成新的存根并配置它们侦听的队列。队列是实现细节。我对AMQP和RabbitMQ的RabbitMQ生成器有问题,所以我决定用Python测试规范,看看是我还是生成器。
试试生成器,你就可以试试我的要点:https://gist.github.com/adrianvolpe/27e9f02187c5b31247aaf947fa4a7360。我是在2.2.0版本中这样做的,所以希望它对您有用。
我还对Python库进行了测试,但是没有为队列分配绑定。
我注意到在上面的规范中,您正在将exchange类型设置为Direct。您可以使用直接和主题交换与多个使用者进行相同的绑定,但是您可能希望主题引用自RabbitMQ文档:
https://www.rabbitmq.com/tutorials/tutorial-five-python.html
主题交换功能强大,可以像其他交换一样运行。
当队列被"#“(散列)绑定键绑定时,它将接收所有消息,而不管路由密钥如何--就像扇出交换中的那样。
当绑定中不使用特殊字符"*“(星星)和"#”(散列)时,主题交换就会像直接交换一样。
祝你好运!
https://stackoverflow.com/questions/72126009
复制相似问题