Hello, we have encountered datetime parsing error when we try to publish delayed message with transaction.
We are using Kafka + PostgreSQL.
This is the error:
String '25.09.2024 10:55:38' was not recognized as a valid DateTime.
Stack Trace:
at DotNetCore.CAP.CapTransactionBase.Flush() at DotNetCore.CAP.PostgreSqlCapTransaction.CommitAsync(CancellationToken cancellationToken) at Space.Service.Common.EventBus.EventBusTransaction.Commit(CancellationToken cancellationToken) at Space.Service.Card.Application.Features.PhysicalCard.Command.CreatePhysicalCardAsync.CreatePhysicalCardAsyncCommandHandler.Handle(CreatePhysicalCardAsyncCommand request, CancellationToken cancellationToken) in /home/runner01/actions-runner/_work/Space.Service.Card/Space.Service.Card/Space.Service.Card.Application/Features/PhysicalCard/Command/CreatePhysicalCardAsync/CreatePhysicalCardAsyncCommandHandler.cs:line 207
Hello, we have encountered datetime parsing error when we try to publish delayed message with transaction.
We are using Kafka + PostgreSQL.
This is the error:
String '25.09.2024 10:55:38' was not recognized as a valid DateTime.
Stack Trace:
at DotNetCore.CAP.CapTransactionBase.Flush() at DotNetCore.CAP.PostgreSqlCapTransaction.CommitAsync(CancellationToken cancellationToken) at Space.Service.Common.EventBus.EventBusTransaction.Commit(CancellationToken cancellationToken) at Space.Service.Card.Application.Features.PhysicalCard.Command.CreatePhysicalCardAsync.CreatePhysicalCardAsyncCommandHandler.Handle(CreatePhysicalCardAsyncCommand request, CancellationToken cancellationToken) in /home/runner01/actions-runner/_work/Space.Service.Card/Space.Service.Card/Space.Service.Card.Application/Features/PhysicalCard/Command/CreatePhysicalCardAsync/CreatePhysicalCardAsyncCommandHandler.cs:line 207
Error Happens here:
_dispatcher.EnqueueToScheduler(message, DateTime.Parse(message.Origin.Headers[Headers.SentTime]!)).ConfigureAwait(false);
DateTime.Parse throws an error.
It happens because when this event was produced, CurrentCulture was set to 'ru-RU' and "cap-senttime" was set to string in russian format.
When event was consumed and it tried to parse this datetime, culture info was set to 'en-EN' and parsing russian format throws exception.
Steps to reproduce: PUBLISHER:
CONSUMER:
POSSIBLE FIXES: DateTime.ToString() and DateTime.Parse() should be called with Invariant Culture