Browse Source

Merge pull request #7897 from real-zony/rabbit-cluster-support

Add support for RabbitMQ cluster.
pull/7919/head
maliming 6 years ago
committed by GitHub
parent
commit
3b24e79486
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      docs/en/Background-Jobs-RabbitMq.md
  2. 22
      docs/en/Distributed-Event-Bus-RabbitMQ-Integration.md
  3. 20
      docs/zh-Hans/Distributed-Event-Bus-RabbitMQ-Integration.md
  4. 11
      framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/ConnectionPool.cs

20
docs/en/Background-Jobs-RabbitMq.md

@ -66,6 +66,26 @@ Defining multiple connections is allowed. In this case, you can use different co
} }
```` ````
If you need to connect to the RabbitMQ cluster, you can use the `;` character to separate the host names.
**Example: Connect to the RabbitMQ cluster**
```json
{
"RabbitMQ": {
"Connections": {
"Default": {
"HostName": "123.123.123.123;234.234.234.234"
}
},
"EventBus": {
"ClientName": "MyClientName",
"ExchangeName": "MyExchangeName"
}
}
}
```
#### AbpRabbitMqOptions #### AbpRabbitMqOptions
`AbpRabbitMqOptions` class can be used to configure the connection strings for the RabbitMQ. You can configure this options inside the `ConfigureServices` of your [module](Module-Development-Basics.md). `AbpRabbitMqOptions` class can be used to configure the connection strings for the RabbitMQ. You can configure this options inside the `ConfigureServices` of your [module](Module-Development-Basics.md).

22
docs/en/Distributed-Event-Bus-RabbitMQ-Integration.md

@ -90,7 +90,7 @@ You can use any of the [ConnectionFactry](http://rabbitmq.github.io/rabbitmq-dot
**Example: Specify the connection port** **Example: Specify the connection port**
````csharp ````json
{ {
"RabbitMQ": { "RabbitMQ": {
"Connections": { "Connections": {
@ -103,6 +103,26 @@ You can use any of the [ConnectionFactry](http://rabbitmq.github.io/rabbitmq-dot
} }
```` ````
If you need to connect to the RabbitMQ cluster, you can use the `;` character to separate the host names.
**Example: Connect to the RabbitMQ cluster**
```json
{
"RabbitMQ": {
"Connections": {
"Default": {
"HostName": "123.123.123.123;234.234.234.234"
}
},
"EventBus": {
"ClientName": "MyClientName",
"ExchangeName": "MyExchangeName"
}
}
}
```
### The Options Classes ### The Options Classes
`AbpRabbitMqOptions` and `AbpRabbitMqEventBusOptions` classes can be used to configure the connection strings and event bus options for the RabbitMQ. `AbpRabbitMqOptions` and `AbpRabbitMqEventBusOptions` classes can be used to configure the connection strings and event bus options for the RabbitMQ.

20
docs/zh-Hans/Distributed-Event-Bus-RabbitMQ-Integration.md

@ -103,6 +103,26 @@
} }
```` ````
如果需要连接到 RabbitMQ 集群,你可以指定多个 HostName。
**示例: 连接到 RabbitMQ 集群**
```json
{
"RabbitMQ": {
"Connections": {
"Default": {
"HostName": "123.123.123.123;234.234.234.234"
}
},
"EventBus": {
"ClientName": "MyClientName",
"ExchangeName": "MyExchangeName"
}
}
}
```
### 选项类 ### 选项类
`AbpRabbitMqOptions` 和 `AbpRabbitMqEventBusOptions` 类用于配置RabbitMQ的连接字符串和事件总线选项. `AbpRabbitMqOptions` 和 `AbpRabbitMqEventBusOptions` 类用于配置RabbitMQ的连接字符串和事件总线选项.

11
framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/ConnectionPool.cs

@ -26,10 +26,13 @@ namespace Volo.Abp.RabbitMQ
return Connections.GetOrAdd( return Connections.GetOrAdd(
connectionName, connectionName,
() => Options () =>
.Connections {
.GetOrDefault(connectionName) var connection = Options.Connections.GetOrDefault(connectionName);
.CreateConnection() var hostnames = connection.HostName.TrimEnd(';').Split(';');
// Handle Rabbit MQ Cluster.
return hostnames.Length == 1 ? connection.CreateConnection() : connection.CreateConnection(hostnames);
}
); );
} }

Loading…
Cancel
Save