Skip to content

How to troubleshoot NatsJSApiNoResponseException when calling CreateOrUpdateConsumerAsync? #428

Answered by mtmk
robertmircea asked this question in Q&A
Discussion options

You must be logged in to vote

yes, you can still ack/nack/terminate messages as usual, and yes the exception would be NatsDeserializeException and you can access the actual serializer exception (it'd be the InnerException) and even the payload as byte array:

await foreach (var msg in consumer.ConsumeAsync<Order>())
{
    Console.WriteLine($"Received: {msg.Subject}");

    if (msg.Error is { } error)
    {
        // Handle serialization errors

        if (error is NatsDeserializeException
            {
                RawData: { } rawData,
                InnerException.Message: { } errorMessage,
            })
        {
            Console.WriteLine($"Error message: {errorMessage}");

            var payload = Encoding

Replies: 3 comments 13 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
9 replies
@mtmk
Comment options

mtmk Mar 5, 2024
Maintainer

@robertmircea
Comment options

@mtmk
Comment options

mtmk Mar 5, 2024
Maintainer

@robertmircea
Comment options

@mtmk
Comment options

mtmk Mar 6, 2024
Maintainer

Comment options

You must be logged in to vote
4 replies
@mtmk
Comment options

mtmk Mar 4, 2024
Maintainer

@mtmk
Comment options

mtmk Mar 19, 2024
Maintainer

@robertmircea
Comment options

@mtmk
Comment options

mtmk Mar 20, 2024
Maintainer

Answer selected by robertmircea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants