Beztek.Facade.Queue
1.0.6
dotnet add package Beztek.Facade.Queue --version 1.0.6
NuGet\Install-Package Beztek.Facade.Queue -Version 1.0.6
<PackageReference Include="Beztek.Facade.Queue" Version="1.0.6" />
paket add Beztek.Facade.Queue --version 1.0.6
#r "nuget: Beztek.Facade.Queue, 1.0.6"
// Install Beztek.Facade.Queue as a Cake Addin #addin nuget:?package=Beztek.Facade.Queue&version=1.0.6 // Install Beztek.Facade.Queue as a Cake Tool #tool nuget:?package=Beztek.Facade.Queue&version=1.0.6
Queue Facade Library
This library is intended for high throughput inter-service communication by use of Queues. The source can be found here: https://github.com/Beztek-Software-Solutions/queue-facade
Overview
It is intended to be cloud portable and take advantage of the native managed services in each cloud, such as Azure Queue Storage and AWS Simple Queue Service.
It is a reusable and configurable queue library that can ensure that just one consumer among multiple competing consumers processes each message. If the client fails to confirm processing of the message in a configurable timeout period, the message reappears in the queue for other clients to consume. This library should be available for any micro-service for this use case.
Notes
Every queue within an account must have a unique name. The queue name must be a valid DNS name, and cannot be changed once created. Queue names must confirm to the following rules:
A queue name must start with a letter or number, and can only contain letters, numbers, and the dash (-) character.
The first and last letters in the queue name must be alphanumeric. The dash (-) character cannot be the first or last character. Consecutive dash characters are not permitted in the queue name.
All letters in a queue name must be lowercase.
A queue name must be from 3 through 63 characters long.
Steps to use the Queue Facade
Find Azure storage connection string and queue names, or create a new queue by providing a new queue name
Implement callback interface IMessageProcessor
Use QueueClientFactory to create Queue client by passing connection string and at lease one queue name client=QueueClientFactory.GetQueueClient(…)
Use client.Enqueue(…) to send generic message to queue, or client.EnqueueBatchedMessages(...) to send list of messages in batch mode. - Example1: bool result = await client.Enqueue<string>(stringMessage, true, activityId); - Example2: IList<bool> results = await client.Enqueue<string>(stringList, true, activityId); - Example3: List<string> unsentMessages = await client.EnqueueBatchedMessages<string>(stringList, true, activityId); - Notice that example3 batch input stringList in chunks, each chunk includes a sub-list of input. - This not only result in less messages in queue than example2, but also allow consumer(etc. event scheduler) to handle batched messages more efficiently.
Create an instance of IMessageProcessor
Use client.DequeueAndProcess(… callback) to retrieve messages from queue
The callback instance should have the messages
Critical Details
- Application handling messages implements
IMessageProcessor
, if MessageProcessor implementation throws an exception which is NotSystem.ApplicationException
then SimpleQueue will retry the message processor until message processor succeeds. - If MessageProcessor needs to handle some application exceptions such as ValidationException, it should catch and throw
System.ApplicationException
in order to avoid getting same message again and again. - In the MessageProcessor, we need to use the UnwrappedMessage class and not string, or it will throw an exception.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- Azure.Storage.Queues (>= 12.17.1)
- Microsoft.Extensions.Logging (>= 7.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Beztek.Facade.Queue:
Package | Downloads |
---|---|
Beztek.Facade.Cache
API facade over various distributed and non-distributed caches |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.6 | 1,838 | 4/11/2024 |