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/changelog.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,17 @@
2
2
3
3
All notable changes to this library will be documented in this file.
4
4
5
+
## [4.3.0] - 2020-10-03
6
+
7
+
### Added
8
+
9
+
-`BasicDeliverEventArgs` extensions for parsing messages.
10
+
11
+
### Changed
12
+
13
+
-**Breaking!**`IMessageHandler`, `IAsyncMessageHandler`, `INonCyclicMessageHandler` and `IAsyncNonCyclicMessageHandler` get messages in `Handle` methods as `BasicDeliverEventArgs` instead of string values.
14
+
-**Breaking!**`BatchMessageHandler` has been removed, `BaseBatchMessageHandler` is now one and only base class for handling messages in batches. `HandleMessages` method of `BaseBatchMessageHandler` gets a collection of messages as `BasicDeliverEventArgs` instead of bytes.
Copy file name to clipboardExpand all lines: docs/message-consumption.md
+39-49Lines changed: 39 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,7 +91,7 @@ public class Program
91
91
92
92
publicclassWorker : BackgroundService
93
93
{
94
-
privatereadonlyIQueueService_queueService;
94
+
readonlyIQueueService_queueService;
95
95
96
96
publicWorker(IQueueServicequeueService)
97
97
{
@@ -109,16 +109,16 @@ The second step is to define classes that will take responsibility of handling r
109
109
110
110
### Synchronous message handlers
111
111
112
-
`IMessageHandler` consists of one method `Handle` that gets a message in a string format. You can deserialize that message (if it is a json message) or handle its raw value.
112
+
`IMessageHandler` consists of one method `Handle` that gets a message. You can deserialize that message with `BasicDeliverEventArgs` extensions (described below).
The message handling process organized as follows:
307
307
308
308
-`IQueueMessage` receives a message and delegates it to `IMessageHandlingService`.
309
-
-`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 a combined collection of `IMessageHandler`, `IAsyncMessageHandler`, `INonCyclicMessageHandler` and `IAsyncNonCyclicMessageHandler` instances and forwards a message to them.
309
+
-`IMessageHandlingService` gets a message and checks if there are any message handlers in a combined collection of `IMessageHandler`, `IAsyncMessageHandler`, `INonCyclicMessageHandler` and `IAsyncNonCyclicMessageHandler` instances and forwards a message to them.
310
310
- All subscribed message handlers (`IMessageHandler`, `IAsyncMessageHandler`, `INonCyclicMessageHandler`, `IAsyncNonCyclicMessageHandler`) process the given message in a given or a default order.
311
311
-`IMessageHandlingService` acknowledges the message by its `DeliveryTag`.
312
312
- If any exception occurs `IMessageHandlingService` acknowledges the message anyway and checks if the message has to be re-send. If exchange option `RequeueFailedMessages` is set `true` then `IMessageHandlingService` adds a header `"re-queue-attempts"` to the message and sends it again with delay in value of `RequeueTimeoutMilliseconds` (default is 200 milliseconds). The number of attempts is configurable and re-delivery will be made that many times as the value of `RequeueAttempts` property. Mechanism of sending delayed messages covered in the message production [documentation](message-production.md).
313
313
- If any exception occurs within handling the message that has been already re-sent that message will not be re-send again (re-send happens only once).
314
314
315
315
### Batch message handlers
316
316
317
-
There are also a feature that you can use in case of necessity of handling messages in batches.
318
-
First of all you have to create a class that inherits a `BatchMessageHandler` class.
317
+
There is a feature that you can use in case of necessity of handling messages in batches.
318
+
First of all you have to create a class that inherits `BaseBatchMessageHandler`.
319
319
You have to set up values for `QueueName` and `PrefetchCount` properties. These values are responsible for the queue that will be read by the message handler, and the size of batches of messages. You can also set a `MessageHandlingPeriod` property value and the method `HandleMessage` will be executed repeatedly so messages in unfilled batches could be processed too, but keep in mind that this property is optional.
320
320
Be aware that batch message handlers **do not declare queues**, so if it does not exist an exception will be thrown. Either declare manually or using RabbitMqClient configuration features.
There are some simple extensions for `BasicDeliverEventArgs` class that helps to parse messages. You have to use `RabbitMQ.Client.Core.DependencyInjection` namespace to enable those extensions.
366
+
There is an example of using those extensions inside a `Handle` method of `IMessageHandler`.
The message handler will create a separate connection and use it for reading messages.
393
-
When the message collection is full to the size of `PrefetchCount` they are passed to the `HandleMessage` method.
394
-
Both `BaseBatchMessageHandler` and `BatchMessageHandler` implement `IDisposable` interface, so you can use it for release of resources.
395
-
396
-
Use this method of getting messages only when you sure that the number of messages that pass through this queue is really huge. Otherwise, messages could stack in the temporary collection of messages waiting to get in full.
386
+
You can also pass `JsonSerializerSettings` to `GetPayload` or `GetAnonymousPayload` methods as well as collection of `JsonConverter` in case you use custom serialization.
397
387
398
388
For message production features see the [Previous page](message-production.md)
0 commit comments