Hello and thanks in advance.
I’m following this example to try to renew the lock on a message using ASB transport.
When the behavior is invoked the line:
var (serviceBusConnection, path) = transportTransaction.Get<(ServiceBusConnection, string)>();
to retrive the connection string and the queue path throws this exception:
System.Collections.Generic.KeyNotFoundException: No item found in behavior context with key: System.ValueTuple`2[[Microsoft.Azure.ServiceBus.ServiceBusConnection, Microsoft.Azure.ServiceBus, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c],[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
at NServiceBus.Extensibility.ContextBag.Get[T](String key) in /_/src/NServiceBus.Core/Extensibility/ContextBag.cs:line 74
at NServiceBus.Extensibility.ContextBag.Get[T]() in /_/src/NServiceBus.Core/Extensibility/ContextBag.cs:line 25
at Elfo.Alm.Accounts.Endpoint.Infrastructure.LockRenewalBehavior.Invoke(ITransportReceiveContext context, Func`1 next) in D:\BuildAgent_ADOS_1\_work\122\s\src\Backend\Endpoint\Infrastructure\NServiceBusExtensions.cs:line 51
at NServiceBus.MainPipelineExecutor.Invoke(MessageContext messageContext) in /_/src/NServiceBus.Core/Pipeline/MainPipelineExecutor.cs:line 35
at NServiceBus.Transport.AzureServiceBus.MessagePump.InnerProcessMessage(Task`1 receiveTask)
I register the behavior in this way:
public static void LockRenewal(this EndpointConfiguration endpointConfiguration, Action<LockRenewalOptions> action)
{
var lockRenewalOptions = new LockRenewalOptions();
action(lockRenewalOptions);
var pipeline = endpointConfiguration.Pipeline;
var renewLockTokenIn = lockRenewalOptions.LockDuration - lockRenewalOptions.ExecuteLockRenewalBefore;
pipeline.Register(
stepId: "LockRenewal",
factoryMethod: builder => new LockRenewalBehavior(renewLockTokenIn),
description: "Renew message lock token");
}
Could you please help me on what causes this error?
Is there another way to retrieve the ASB connection string and the queue path?