Search code examples
modelrabbitmqyamlamqpasyncapi

AsyncApi and RabbitMq


How do I put my RabbitMq exchange to an asyncapi definition?

In the examples I found this ...

channels:
  user/signup:
    publish:
      bindings:
        amqp:
          expiration: 100000
          userId: guest
          cc: ['user.logs']
          priority: 10
          deliveryMode: 2
          mandatory: false
          bcc: ['external.audit']
          replyTo: user.signedup
          timestamp: true
          ack: false
          bindingVersion: 0.2.0

Is maybe the part of the channel name before the slash meant as exchange?


Solution

  • There is an entire exchange property you can use for the channel binding for AMQP. The binding you are currently using is the operation binding.

    This means that you can define it as such

    channels:
      user/signedup:
        publish:
          bindings:
            amqp:
              expiration: 100000
              userId: guest
              cc: ['user.logs']
              priority: 10
              deliveryMode: 2
              mandatory: false
              bcc: ['external.audit']
              replyTo: user.signedup
              timestamp: true
              ack: false
              bindingVersion: 0.2.0
        bindings:
          amqp:
            is: routingKey
            queue:
              name: my-queue-name
              durable: true
              exclusive: true
              autoDelete: false
              vhost: /
            exchange:
              name: myExchange
              type: topic
              durable: true
              autoDelete: false
              vhost: /
            bindingVersion: 0.2.0