You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 29, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: docs/exchange-configuration.md
+20-19Lines changed: 20 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@
2
2
3
3
### Basics
4
4
5
-
Client applications work with exchanges and queues, and they must be "declared" and "bound" to each other is a certain way before they can be used.
6
-
Queues and exchanges can also be customized by using additional parameters. This library allows to do this routine simply calling `AddExchange` method passing additional parameters to it.
5
+
Client applications work with exchanges and queues which must be "declared" and "bound" to each other in a certain way before they can be used.
6
+
Queues and exchanges can also be customized by using additional parameters. This library allows you to do this routine simply calling the`AddExchange` method passing additional parameters to it.
7
7
You are allowed to configure multiple exchanges with multiple queues bound to them.
8
8
9
9
Your `Startup` code will look like this.
@@ -57,26 +57,26 @@ And the `appsettings.json` file will be like this.
57
57
}
58
58
```
59
59
60
-
The RabbitMQ client configuration section not specified in this example, for more information see the [documentation](rabbit-configuration.md) file.
60
+
The RabbitMQ client configuration section is not specified in this example, for more information see the [documentation](rabbit-configuration.md) file.
61
61
62
62
Exchanges can be configured with properties:
63
-
-`Type` - exchange type (direct, topic, fanout). Default value is `"direct"`.
64
-
-`Durable` - durability option. Default value is `true`.
65
-
-`AutoDelete` - option for exchange auto deleting. Default value is `false`.
66
-
-`Arguments` - dictionary of additional arguments. Default value is `null`.
67
-
-`RequeueFailedMessages` - option that specifies behaviour of re-queueing failed messages with delay through dead-letter-exchange. Default value is `true`. Mechanism of sending delayed messages covered in the [documentation](message-production.md).
68
-
-`DeadLetterExchange` - default value for dead-letter-exchange. Default value for dead-letter-exchange name is `"default.dlx.exchange"`.
69
-
-`Queues` - collection of queues bound to the exchange.
63
+
-`Type` - an exchange type (direct, topic, fanout). The default value is `"direct"`.
64
+
-`Durable` - a durability option. The default value is `true`.
65
+
-`AutoDelete` - an option for exchange auto deleting. The default value is `false`.
66
+
-`Arguments` - a dictionary of additional arguments. The default value is `null`.
67
+
-`RequeueFailedMessages` - an option that specifies behaviour of re-queueing failed messages with certain delay through the dead-letter-exchange. The default value is `true`. The mechanism of sending delayed messages is covered in the [documentation](message-production.md).
68
+
-`DeadLetterExchange` - a value for dead-letter-exchange. The default value for the dead-letter-exchange name is `"default.dlx.exchange"`.
69
+
-`Queues` - a collection of queues bound to the exchange.
70
70
71
71
Queue options:
72
-
-`Name` - queue name.
73
-
-`Durable` - durability option. Default value is `true`.
74
-
-`AutoDelete` - option for queue auto deleting. Default value is `false`.
75
-
-`Exclusive` - exclusive option. Default value is `false`.
76
-
-`Arguments` - dictionary of additional [arguments](https://www.rabbitmq.com/queues.html#optional-arguments). Default value is `null`.
77
-
-`RoutingKeys` - collection of routing keys that queue "listens".
72
+
-`Name` - a queue name.
73
+
-`Durable` - a durability option. The default value is `true`.
74
+
-`AutoDelete` - an option for queue auto deleting. The default value is `false`.
75
+
-`Exclusive` - an exclusive option. The default value is `false`.
76
+
-`Arguments` - a dictionary of additional [arguments](https://www.rabbitmq.com/queues.html#optional-arguments). The default value is `null`.
77
+
-`RoutingKeys` - a collection of routing keys that the queue "listens".
78
78
79
-
Taking into account all the default values that you can skip configuration will look like this.
79
+
Taking into account all the default values that you can skip, configuration will look like this.
80
80
81
81
```json
82
82
{
@@ -92,7 +92,7 @@ Taking into account all the default values that you can skip configuration will
92
92
}
93
93
```
94
94
95
-
If you want to use routing keys matching with queue names you can skip `"RoutingKeys"` option and queues will be bound to the exchange by their names.
95
+
If you want to use routing keys matching with queue names you can skip the `"RoutingKeys"` option and queues will be bound to the exchange by their names.
Copy file name to clipboardExpand all lines: docs/message-consumption.md
+12-11Lines changed: 12 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@
2
2
3
3
### Starting a consumer
4
4
5
-
The first step that has to be done to retrieve messages from queues is to start a consumer. This can be achieved by calling `StartConsuming` method of the`IQueueService`.
6
-
Consumption exchanges will work only in message-production mode if `StartConsuming` method won't be called.
5
+
The first step that has to be done to retrieve messages from queues is to start a consumer. This can be achieved by calling the `StartConsuming` method of `IQueueService`.
6
+
Consumption exchanges will work only in a message-production mode if the`StartConsuming` method won't be called.
7
7
8
8
Let's say that your configuration looks like this.
9
9
@@ -27,7 +27,7 @@ public class Startup
27
27
}
28
28
```
29
29
30
-
You can register an `IHostedService` and inject the instance of the`IQueueService` into it.
30
+
You can register `IHostedService` and inject an instance of `IQueueService` into it.
@@ -108,7 +108,7 @@ public class Worker : BackgroundService
108
108
109
109
The second step without which receiving messages does not make sense - configuration of message handling services. If there are no message handlers then received messages will not be processed.
110
110
111
-
Message handlers are classes that implement `IMessageHandler` interface (or a few others) and contain functionality including error handling for processing messages.
111
+
Message handlers are classes that implement the `IMessageHandler` interface (or a few others) and contain functionality (including error handling) for processing messages.
112
112
You can register `IMessageHandler` in your `Startup` like this.
113
113
114
114
```c#
@@ -134,7 +134,8 @@ public class Startup
134
134
135
135
RabbitMQ client and exchange configuration sections are not specified in this example, but covered [here](rabbit-configuration.md) and [here](exchange-configuration.md).
136
136
137
-
`IMessageHandler` implementation will "listen" for messages by specified routing key, or a collection of routing keys. If it is necessary you can also register multiple message handler at once.
137
+
`IMessageHandler` implementation will "listen" for messages by the specified routing key, or a collection of routing keys. If it is necessary, you can also register multiple message handler at once.
`IMessageHandler` consists of one method `Handle` that gets a message in string format. You can deserialize it (if it is a json message) or handle a raw value.
182
-
Thus, message handler will look like this.
182
+
`IMessageHandler` consists of one method `Handle` that gets a message in a string format. You can deserialize it (if it is a json message) or handle a raw value.
183
+
Thus, a message handler will look like this.
183
184
184
185
```c#
185
186
publicclassCustomMessageHandler : IMessageHandler
@@ -192,7 +193,7 @@ public class CustomMessageHandler : IMessageHandler
192
193
}
193
194
```
194
195
195
-
You can also inject services inside `IMessageHandler` constructor.
196
+
You can also inject services inside the `IMessageHandler` constructor.
196
197
197
198
```c#
198
199
publicclassCustomMessageHandler : IMessageHandler
@@ -210,7 +211,7 @@ public class CustomMessageHandler : IMessageHandler
210
211
}
211
212
```
212
213
213
-
The only exception is `IQueueService`. You can't inject it inside a message handler because of the appearance of cyclic dependencies. If you want to use an instance of `IQueueService` (e.g. handle one message and send another) use `INonCyclicMessageHandler`.
214
+
The only exception is the `IQueueService`. You can't inject it inside a message handler because of the appearance of cyclic dependencies. If you want to use an instance of `IQueueService` (e.g. handle one message and send another) use `INonCyclicMessageHandler`.
214
215
`INonCyclicMessageHandler` can be registered the same way as `IMessageHandler`. There are similar semantic methods for adding it in **singleton** or **transient** modes.
215
216
216
217
```c#
@@ -298,7 +299,7 @@ So you can use async/await power inside your message handler.
298
299
299
300
The message handling process is organized as follows:
300
301
301
-
-`IQueueMessage` receives a message and delegates it to the `IMessageHandlingService`.
302
+
-`IQueueMessage` receives a message and delegates it to `IMessageHandlingService`.
302
303
-`IMessageHandlingService` gets a message (as a byte array) and decodes it to the UTF8 string. It also checks if there are any message handlers in collections of `IMessageHandler`, `IAsyncMessageHandler`, `INonCyclicMessageHandler` and `IAsyncNonCyclicMessageHandler` instances and forwards a message to them.
303
304
- All subscribed message handlers (`IMessageHandler`, `IAsyncMessageHandler`, `INonCyclicMessageHandler`, `IAsyncNonCyclicMessageHandler`) process the given message.
304
305
-`IMessageHandlingService` acknowledges the message by its `DeliveryTag`.
Copy file name to clipboardExpand all lines: docs/message-production.md
+17-11Lines changed: 17 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@
5
5
`IQueueService` represents a service that handles all the work of sending and receiving messages. You can inject `IQueueService` wherever you want in order to use it.
**Prerequisites.**Let's say that producer want to send a message to the exchange **"Exchange B"** with a routing key **"routing.key"** and delay in **30 seconds**.
**Prerequisites.**Let's say that producer want to send a message to the exchange **"Exchange B"** with a routing key **"routing.key"**, and a delay in **30 seconds**.
Copy file name to clipboardExpand all lines: docs/rabbit-configuration.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# RabbitMQ configuration
2
2
3
-
To connect to a RabbitMQ, it is necessary to instantiate an `IQueueService` and configure it to use desired endpoint, credentials and other valuable connection settings.
4
-
`IQueueService` allows clients to configure queues to exchange bindings, and to consume and produce messages in different ways (sync or async, with or without delay). To add `IQueueService` in your application simply use `AddRabbitMqClient` extension method as in the example below.
3
+
To connect to a RabbitMQ server, it is necessary to instantiate `IQueueService` and configure it to use a desired endpoint, credentials and other valuable connection settings.
4
+
`IQueueService` allows clients to configure queues to exchange bindings, and to consume and produce messages in different ways (sync or async, with or without delay). To add `IQueueService` in your application simply use the `AddRabbitMqClient` extension method as in the example below.
5
5
6
6
```c#
7
7
publicclassStartup
@@ -24,7 +24,7 @@ public class Startup
24
24
}
25
25
```
26
26
27
-
RabbitMQ client can be configured via configuration section located in the `appsettings.json` file. This configuration section must be of a certain format and down below is an example of all configuration options used in `IQueueService`.
27
+
A RabbitMQ client can be configured via a configuration section located in the `appsettings.json` file. This configuration section must be of a certain format and down below is an example of all configuration options used in `IQueueService`.
28
28
29
29
```json
30
30
{
@@ -43,7 +43,7 @@ RabbitMQ client can be configured via configuration section located in the `apps
43
43
}
44
44
```
45
45
46
-
RabbitMQ connection can be configured with properties:
46
+
A RabbitMQ connection can be configured with properties:
47
47
-`HostName` - RabbitMQ server,
48
48
-`HostNames` - collection of RabbitMQ hostnames,
49
49
-`TcpEndpoints` - collection of AMPQ TCP endpoints,
@@ -70,7 +70,7 @@ RabbitMQ connection can be configured with properties:
70
70
}
71
71
```
72
72
73
-
For high availability RabbitMQ clusters with multiple nodes you can set hosts collection with `HostNames` option.
73
+
For high availability RabbitMQ clusters with multiple nodes you can set hosts collection with the `HostNames` option.
74
74
75
75
```json
76
76
{
@@ -109,9 +109,9 @@ If nodes are running on different hosts with different ports you have an option
109
109
}
110
110
```
111
111
112
-
There is an importance of `TcpEndpoints`, `HostNames`, `HostName` options. If all of them are set connection will be created using `TcpEndpoints` option. The second will be option `HostNames` and the `HostName` option is the least important between those three.
112
+
There is an importance of `TcpEndpoints`, `HostNames`, `HostName` options. If all of them are set connection will be created using the `TcpEndpoints` option. The second will be the option `HostNames` and the `HostName` option is the least important between those three.
113
113
114
-
If `.json` configuration files unacceptable for you there is another `AddRabbitMqClient` extension method that takes manually created `RabbitMqClientOptions` configuration as a parameter. `RabbitMqClientOptions` is the model class used for injecting RabbitMQ client configuration as an `IOtions<T>` instance so properties named the same as in the previous method.
114
+
If `.json` configuration files unacceptable for you there is another `AddRabbitMqClient` extension method that takes manually created `RabbitMqClientOptions` configuration as a parameter. `RabbitMqClientOptions` is the model class used for injecting a RabbitMQ client configuration as an `IOtions<T>` instance so properties named the same as in the previous method.
0 commit comments