AliyunAMQP


  这是适配阿里云 AMQP 订阅管理器 的实现,它继承自 RabbitMQ,配置沿用 RabbitMQ 的,但需要注意 server、userName 和 password,如下所示:

  • .Net Framework 下的 app.config 或 web.config 文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <sectionGroup name="fireasy">
      <section name="subscribers" type="Fireasy.Common.Subscribes.Configuration.SubscribeConfigurationSectionHandler, Fireasy.Common" />
    </sectionGroup>
  </configSections>
  <fireasy>
    <subscribers default="amqp">
      <subscriber name="amqp" type="Fireasy.Aliyun.AMQP.SubscribeManager, Fireasy.Aliyun.AMQP">
        <config 
          userName="[AccessKey Id]"
          password="[AccessKey Secret]"
          server="amqp://[接入点]"
          exchangeType="topic"
          virtualHost="sample" />
      </subscriber>
    </subscribers>
  </fireasy>
</configuration>
  • .Net Core 下的 appsettings.json 文件
{
  "fireasy": {
    "subscribers": {
      "default": "amqp",
      "settings": {
        "amqp": {
          "type": "Fireasy.Aliyun.AMQP.SubscribeManager, Fireasy.Aliyun.AMQP",
          "config": {
            "userName": "[AccessKey Id]",
            "password": "[AccessKey Secret]",
            "server": "amqp://[接入点]",
            "exchangeType": "topic",
            "virtualHost": "sample"
          }
        }
      }
    }
  }
}

  在 .Net Core 应用中可以使用扩展方法 AddAliyunAMQP 切换到 阿里云AMQP 发布订阅,使用方法与 AddRabbitMQSubscriber 相似。