Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If Dead Letters REST API is used a System.Data.SqlTypes.SqlNullValueException is thrown, when ListenForMessagesFromExternalDatabaseTable is configured #1225

Closed
KnutFreyer opened this issue Jan 17, 2025 · 0 comments
Milestone

Comments

@KnutFreyer
Copy link

If Dead Letters REST API is used a System.Data.SqlTypes.SqlNullValueException is thrown, when ListenForMessagesFromExternalDatabaseTable is configured and a message coming from the external table is moved to the error queue.

To Reproduce

Steps to reproduce the behavior:

  1. Setup a service to use ListenForMessagesFromExternalDatabaseTable option.
  2. Setup a message handler to raise an exception
  3. Configure the message handler like this:
public static void Configure(HandlerChain chain)
  {
    chain.OnException<Exception>().MoveToErrorQueue();
  }

  1. Insert message data into the external table
  2. Make sure that the message is processed
  3. Use Dead Letters REST API to list entries kike this, where 'messageType' should be replaced with the matching type name:
  --url http://localhost:5000/dead-letters \
  --header 'Content-Type: application/json' \
  --header 'content-type: application/json' \
  --data '{
  "Limit": 50,
  "MessageType": "messageType"
}'
  1. Observe response:
   at Microsoft.Data.SqlClient.SqlDataReader.GetFieldValueFromSqlBufferInternal[T](SqlBuffer data, _SqlMetaData metaData, Boolean isAsync)
   at Microsoft.Data.SqlClient.SqlDataReader.GetFieldValueAsync[T](Int32 i, CancellationToken cancellationToken)
--- End of stack trace from previous location ---
   at Wolverine.RDBMS.DatabasePersistence.ReadDeadLetterAsync(DbDataReader reader, CancellationToken cancellation) in /home/runner/work/wolverine/wolverine/src/Persistence/Wolverine.RDBMS/DatabasePersistence.cs:line 110
   at Weasel.Core.CommandExtensions.FetchListAsync[T](DbCommand cmd, Func`2 transform, CancellationToken cancellation)
   at Weasel.Core.CommandExtensions.FetchListAsync[T](DbCommand cmd, Func`2 transform, CancellationToken cancellation)
   at Wolverine.RDBMS.MessageDatabase`1.QueryDeadLetterEnvelopesAsync(DeadLetterEnvelopeQueryParameters queryParameters, String tenantId) in /home/runner/work/wolverine/wolverine/src/Persistence/Wolverine.RDBMS/MessageDatabase.DeadLetters.cs:line 76
   at Wolverine.Http.DeadLettersEndpointExtensions.<>c.<<MapDeadLettersEndpoints>b__0_0>d.MoveNext() in /home/runner/work/wolverine/wolverine/src/Http/Wolverine.Http/DeadLettersEndpointExtensions.cs:line 75
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Http.RequestDelegateFactory.<ExecuteTaskOfT>g__ExecuteAwaited|132_0[T](Task`1 task, HttpContext httpContext, JsonTypeInfo`1 jsonTypeInfo)
   at Microsoft.AspNetCore.Http.RequestDelegateFactory.<>c__DisplayClass101_2.<<HandleRequestBodyAndCompileRequestDelegateForJson>b__2>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

HEADERS
=======
Accept: application/json, text/plain, */*
Connection: keep-alive
Host: localhost:5000
User-Agent: bruno-runtime/1.32.0
Accept-Encoding: gzip, compress, deflate, br
Content-Type: application/json
Content-Length: 106
request-start-time: 1737096822108```

It seems this is caused, because field Source will not be set  in wolverine_dead_letters table under this scenario. As a workaround we are using an update trigger at the moment.
We didn't tested so far, what happens, if `Replay` method from Dead Letters REST API is used.

**Expected behavior**
1. No exception is raised. 
2. As an optimum `Replay` will raise no exception.  

Environment
Desktop
Windows 11 Pro 23H2
Microsoft SQL Server Express (64-bit) Version 16.0.1135.2
and
Windows Server 2019 Standard (10.0)
Microsoft SQL Server Standard (64-bit) Version 15.0.4312.2
.Net 9
Wolverine 3.6.5
@jeremydmiller jeremydmiller added this to the 3.7.0 milestone Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants