alexeybogdan95 / sqspoller Goto Github PK
View Code? Open in Web Editor NEWA small .NET library that polls and handles messages from a SQS queue
License: MIT License
A small .NET library that polls and handles messages from a SQS queue
License: MIT License
Please take a look at next test:
https://github.com/IhnatKlimchuk/SqsPoller/blob/playground/test/SqsPoller.Tests.Unit/ConsumerResolverTests.cs#L184
Task cancelled this way causes ContinueWith
task see task.IsCancelled == true
but still deleting message from sqs.
example of consumer https://github.com/IhnatKlimchuk/SqsPoller/blob/playground/test/SqsPoller.Tests.Unit/ThrowingMessageConsumer.cs#L14
same issue is reproduced while stopping host
This issue is pretty important as caused some data loss on prod envs.
Let us take following Json object:
{
"name":"test",
"date":"2021-03-23T10:14:40.115+00:00"
}
As you see, time is UTC, but if such object will be message body, it will be deserialized incorrectly. Its Kind
property will have DateTimeKind.Local
value. It seems to be easily fixed by adjusting Newtonsoft.Json
settings. I reproduced same issue on test project with only Newtonsoft.Json
serializing/deserializing
private async Task ProcessEvent(Message message, CancellationToken cancellationToken, SemaphoreSlim semaphore, string queueUrl)
{
try
{
await _consumerResolver.Resolve(message, cancellationToken);
DeleteMessage(queueUrl, message, cancellationToken);
}
catch (OperationCanceledException e)
{
_logger.LogWarning(e,
"Failed to handle message with id {message_id} and ReceiptHandle {receipt_handle}. Task has been cancelled");
}
catch (Exception e)
{
_logger.LogError(e,
"Failed to handle message with id {message_id} and ReceiptHandle {receipt_handle}");
}
finally
{
semaphore.Release();
}
}
Error during handling can be resulted by race condition and/or similar issue. Issue will cause retry by SQS, but you can't avoid Error
logs, otherwise message will be assumed "consumed" correctly.
Add ability for one of
result
to avoid deleting messageexception
for "Warning" level similar to OperationCanceledException
Please see https://github.com/IhnatKlimchuk/SqsPoller/tree/playground/test/SqsPoller.LoadTest for more details.
SqsPoller tries to read all available messages. In case of huge amount of messages that leads to:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.