瀏覽代碼

Add aws sqs transport docs. (#597)

master
Savorboard 4 年之前
父節點
當前提交
67ebf8dcc1
共有 6 個檔案被更改,包括 183 行新增0 行删除
  1. 二進制
     
  2. 二進制
     
  3. +90
    -0
      docs/content/user-guide/en/transports/aws-sqs.md
  4. +1
    -0
      docs/content/user-guide/en/transports/general.md
  5. +91
    -0
      docs/content/user-guide/zh/transports/aws-sqs.md
  6. +1
    -0
      docs/content/user-guide/zh/transports/general.md

二進制
查看文件


二進制
查看文件


+ 90
- 0
docs/content/user-guide/en/transports/aws-sqs.md 查看文件

@@ -0,0 +1,90 @@
# Amazon SQS

AWS SQS is a fully managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications.

AWS SNS is a highly available, durable, secure, fully managed pub/sub messaging service that enables you to decouple microservices, distributed systems, and serverless applications.

## How CAP uses AWS SNS and SQS

### SNS

Because CAP works based on the topic pattern, it needs to use AWS SNS, which simplifies the publish and subscribe architecture of messages.

When the CAP startup, all subscription names will be registered as SNS topics, and you will see a list of all registered topics in the management console.

SNS does not support the use of symbols such as `.` `:` as the name of the topic, so we replaced it. We replaced `.` with `-` and `:` with `_`

!!! note "Precautions"
Amazon SNS currently allows the maximum size of published messages to be 256KB

For example, you have the following two subscriber methods in your current project

```C#
[CapSubscribe("sample.sns.foo")]
public void TestFoo(DateTime value)
{
}

[CapSubscribe("sample.sns.bar")]
public void TestBar(DateTime value)
{
}
```
After the CAP startup, you will see in SNS management console:

![img](/img/aws-sns-demo.png)

### SQS

For each consumer group, CAP will create a corresponding SQS queue, the name of the queue is the name of the `DefaultGroup` in the configuration options, and the queue type is Standard.

The SQS queue will subscribe to Topic in SNS, as shown below:

![img](/img/aws-sns-demo.png)

!!! warning "Precautions"
Due to the limitation of AWS SNS, when you remove the subscription method, CAP will not delete topics or queues on AWS SNS or SQS, you need to delete them manually.


## Configuration

To use AWS SQS as the transport, you need to install the packages from NuGet:

```shell

Install-Package DotNetCore.CAP.AmazonSQS

```

Next, add configuration items to the `ConfigureServices` method of `Startup.cs`:

```csharp

public void ConfigureServices(IServiceCollection services)
{
// ...

services.AddCap(x =>
{
x.UseAmazonSQS(opt=>
{
//AmazonSQSOptions
});
// x.UseXXX ...
});
}

```

#### AmazonSQS Options

CAP 直接对外提供的 AmazonSQSOptions 配置参数如下:

NAME | DESCRIPTION | TYPE | DEFAULT
:---|:---|---|:---
Region | AWS 所处的区域 | Amazon.RegionEndpoint |
Credentials | AWS AK SK信息 | Amazon.Runtime.AWSCredentials |

如果你的项目运行在 AWS EC2 中,则不需要设置 Credentials,直接对 EC2 应用 IAM 策略即可。

Credentials 需要具有新增和订阅 SNS Topic,SQS Queue 等权限。

+ 1
- 0
docs/content/user-guide/en/transports/general.md 查看文件

@@ -9,6 +9,7 @@ CAP supports several transport methods:
* [RabbitMQ](rabbitmq.md)
* [Kafka](kafka.md)
* [Azure Service Bus](azure-service-bus.md)
* [Amazon SQS](aws-sqs.md)
* [In-Memory Queue](in-memory-queue.md)

## How to select a transport


+ 91
- 0
docs/content/user-guide/zh/transports/aws-sqs.md 查看文件

@@ -0,0 +1,91 @@
# Amazon SQS

AWS SQS 是一种完全托管的消息队列服务,可让您分离和扩展微服务、分布式系统和无服务器应用程序。

AWS SNS 是一种高度可用、持久、安全、完全托管的发布/订阅消息收发服务,可以轻松分离微服务、分布式系统和无服务器应用程序。

## CAP 如何使用 AWS SNS & SQS

### SNS

由于 CAP 是基于 Topic 模式工作的,所以需要使用到 AWS SNS,SNS 简化了消息的发布订阅架构。

在 CAP 启动时会将所有的订阅名称注册为 SNS 的 Topic,你将会在管理控制台中看到所有已经注册的 Topic 列表。

由于 SNS 不支持使用 `.` `:` 等符号作为 Topic 的名称,所以我们进行了替换,我们将 `.` 替换为了 `-`,将 `:` 替换为了 `_`

!!! note "注意事项"
Amazon SNS 当前允许发布的消息最大大小为 256KB

举例,你的当前项目中有以下两个订阅者方法

```C#
[CapSubscribe("sample.sns.foo")]
public void TestFoo(DateTime value)
{
}

[CapSubscribe("sample.sns.bar")]
public void TestBar(DateTime value)
{
}
```

在 CAP 启动后,在 AWS SNS 中你将看到

![img](/img/aws-sns-demo.png)

### SQS

针对每个消费者组,CAP 将创建一个与之对应的 SQS 队列,队列的名称为配置项中 DefaultGroup 的名称,类型为 Standard Queue 。

该 SQS 队列将订阅 SNS 中的 Topic ,如下图:

![img](/img/aws-sns-demo.png)

!!! warning "注意事项"
由于 AWS SNS 的限制,当你减少订阅方法时,我们不会主动删除 AWS SNS 或者 SQS 上的相关 Topic 或 Queue,你需要手动删除他们。


## 配置

要使用 AWS SQS 作为消息传输器,你需要从 NuGet 安装以下扩展包:

```shell

Install-Package DotNetCore.CAP.AmazonSQS

```

然后,你可以在 `Startup.cs` 的 `ConfigureServices` 方法中添加基于 RabbitMQ 的配置项。

```csharp

public void ConfigureServices(IServiceCollection services)
{
// ...

services.AddCap(x =>
{
x.UseAmazonSQS(opt=>
{
//AmazonSQSOptions
});
// x.UseXXX ...
});
}

```

#### AmazonSQS Options

CAP 直接对外提供的 AmazonSQSOptions 配置参数如下:

NAME | DESCRIPTION | TYPE | DEFAULT
:---|:---|---|:---
Region | AWS 所处的区域 | Amazon.RegionEndpoint |
Credentials | AWS AK SK信息 | Amazon.Runtime.AWSCredentials |

如果你的项目运行在 AWS EC2 中,则不需要设置 Credentials,直接对 EC2 应用 IAM 策略即可。

Credentials 需要具有新增和订阅 SNS Topic,SQS Queue 等权限。

+ 1
- 0
docs/content/user-guide/zh/transports/general.md 查看文件

@@ -9,6 +9,7 @@ CAP 支持以下几种运输方式:
* [RabbitMQ](rabbitmq.md)
* [Kafka](kafka.md)
* [Azure Service Bus](azure-service-bus.md)
* [Amazon SQS](aws-sqs.md)
* [In-Memory Queue](in-memory-queue.md)

## 怎么选择运输器


Loading…
取消
儲存