rebus-org / Rebus.AzureQueues

:bus: Azure Storage Queues transport implementation for Rebus
https://mookid.dk/category/rebus
Other
7 stars 5 forks source link

Warning: Method not found: 'Void Rebus.Transport.ITransactionContext.OnCommitt #18

Closed khinze closed 1 year ago

khinze commented 1 year ago

Hallo There,

I am trying to implement Rebus that uses azure storage queues with no luck. I have integrated it into my worker and it seems like the handler are not being executed on message received.

The warning im getting: warn: Rebus.Workers.ThreadPoolBased.ThreadPoolWorker[0] An error occurred when attempting to receive the next message: System.MissingMethodException: Method not found: 'Void Rebus.Transport.ITransactionContext.OnCompleted(System.Func`1)'. at Rebus.AzureStorage.Transport.AzureStorageQueuesTransport.SetUpCompletion(ITransactionContext context, CloudQueueMessage cloudQueueMessage, CloudQueue inputQueue) at Rebus.AzureStorage.Transport.AzureStorageQueuesTransport.Receive(ITransactionContext context, CancellationToken cancellationToken) at Rebus.Workers.ThreadPoolBased.ThreadPoolWorker.ReceiveTransportMessage(CancellationToken token, ITransactionContext context)

The configuration in my worker: var storageAccount = CloudStorageAccount.Parse(azureStorageQueueConfiguration);

    services.AddRebus(configure => configure
        .Transport(t => t.UseAzureStorageQueues(storageAccount, "queue"))
        .Routing(c => c.TypeBased()
            .Map<Mycommand>("queue")
        ))
        .AddRebusHandler<MyHandler>();

I am using .net 6 with the following nuget packages: "Rebus" Version="6.6.5" "Rebus.AzureStorage" "Rebus.ServiceProvider" Version="8.3.1" Rebus.AzureQueues" Version="3.0.0-b1"

Is there something wrong in my configuration or could be that there is something missing in Azure.StorageQueues?

mookid8000 commented 1 year ago

Weird! The error indicates that the method signature of OnCompleted is not void OnCompleted(Func<Task> handler) as expected, which is the error one would get from running Rebus 6 with a dependency that requires Rebus 5.

You made me realize though that a proper v3 of Rebus.AzureQueues was never published after the 3.0.0-b1 prerelease version, so I have made a few updates (i.e. updated the Azure.Storage.Queues dependency to latest) and published it as Rebus.AzureQueues 3.0.0 to NuGet.org.

Could you try that and see if it makes a difference?

khinze commented 1 year ago

Hallo Mookid,

I updated to the version 3.0.0 package. Thank you. I realized that I still had Rebus.AzureStorage in my dependencies. Once removing this the warning disappeared.

However I am receiving the following error now, warn: Rebus.Workers.ThreadPoolBased.ThreadPoolWorker[0] An error occurred when attempting to receive the next message: System.Text.Json.JsonException: 'e' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0. ---> System.Text.Json.JsonReaderException: 'e' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0. at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker) at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first) at System.Text.Json.Utf8JsonReader.ReadSingleSegment() at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) --- End of inner exception stack trace --- at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex) at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.Serialization.JsonConverter1.ReadCoreAsObject(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable1 actualByteCount) at System.Text.Json.JsonSerializer.Deserialize(ReadOnlySpan`1 utf8Json, Type returnType, JsonSerializerOptions options) at System.BinaryData.ToObjectFromJson[T](JsonSerializerOptions options) at Rebus.AzureQueues.Transport.AzureStorageQueuesTransport.Deserialize(BinaryData cloudQueueMessage) at Rebus.AzureQueues.Transport.AzureStorageQueuesTransport.InnerReceive(ITransactionContext context, CancellationToken cancellationToken, QueueClient inputQueue) at Rebus.AzureQueues.Transport.AzureStorageQueuesTransport.Receive(ITransactionContext context, CancellationToken cancellationToken) at Rebus.Workers.ThreadPoolBased.ThreadPoolWorker.ReceiveTransportMessage(CancellationToken token, ITransactionContext context)

Just as a note I am using Azurite for the storage queues.

mookid8000 commented 1 year ago

It looks like the message contents are not quite right.

Could you try and check (e.g. with Azure Storage Explorer) the message payload and see if you can figure out why it can't be deserialized?

khinze commented 1 year ago

Hi Mookid,

I went on Azure Storage explorer and all the messages looked fine to me. I removed all items from the queue and sent a new message and handler consumed it.

I'm going to run some extensive tests later (tommorow) to see if there still is an issue. I'm wondering if I had old messages from the older version of the Azure.StorageQueue library.

mookid8000 commented 1 year ago

(..) I'm wondering if I had old messages from the older version of the Azure.StorageQueue library.

That's most likely it.

Although I cannot recall having changed the wire-level format of the messages.

Good that it works for you now 👍