question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

amqp:internal-error trying to implement renew-lock for ServiceBus

See original GitHub issue

Hi, I am trying to implement the renew-lock mentioned in #164 .

I am using the documentation from the page referenced on renew-lock.

If I call the renew-lock on a partitioned topic, I get the following message:

This SDK does not support operation ‘com.microsoft:renew-lock’ for an entity with partitioning enabled. Please use a newer version of the SDK

If I try to renew a lock on a non-partitioned topic, I get the following:

errorCondition: {amqp:internal-error} statusCode: 0x000001f4 The service was unable to process the request; please retry the operation.

Here’s some sample code to recreate. I am hoping it is something simple, like possibly in the way that I have the BodySection implemented. Do you have any pointers? Or is renewing a lock on Service Bus through this library simply not possible? If it is possible, will we be able to renew a lock on a partitioned topic as well? Maybe via implementing x-opt-partition-key somehow?

Thanks for your time…

public static async Task RenewLock(string connectionString, Message message, string topic, string subscription, int lockDurationMilliseconds)
{
    var lockToken = new Guid(message.DeliveryTag).ToString();
    var entityAddress = $"{topic}/Subscriptions/{subscription}";
    var managementNodeAddress = $"{entityAddress}/$management";
    var renewLockSenderAddress = $"{subscription}-renew-lock-sender";
    var renewLockReceiverAddress = $"{subscription}-renew-lock-reply-to";

    var senderAttach = new Attach()
    {
        Source = new Source() { Address = renewLockSenderAddress },
        Target = new Target() { Address = managementNodeAddress }
    };

    var recieverAttach = new Attach()
    {
        Source = new Source() { Address = managementNodeAddress },
        Target = new Target() { Address = renewLockReceiverAddress },
    };

    var connection = await Amqp.Connection.Factory.CreateAsync(new Amqp.Address(connectionString));
    var renewLockSession = new Session(connection);
    var renewLockSenderLink = new Amqp.SenderLink(renewLockSession, "renew-lock-sender", senderAttach, null);
    var renewLockReceiverLink = new Amqp.ReceiverLink(renewLockSession, "renew-lock-receiver", recieverAttach, null);

    Console.WriteLine(message.Properties.MessageId);

    var renewLockMessage = new Message()
    {
        ApplicationProperties = new ApplicationProperties(),
        Properties = new Properties()
        {
            MessageId = message.Properties.MessageId,
            ReplyTo = renewLockReceiverAddress
        },
        BodySection = new Data() { Binary = Encoding.UTF8.GetBytes($"['map',['string', 'lock-tokens'], ['array', 'uuid', '{lockToken}']]") }
    };
    renewLockMessage.ApplicationProperties["operation"] = "com.microsoft:renew-lock";
    renewLockMessage.ApplicationProperties["com.microsoft:server-timeout"] = lockDurationMilliseconds;

    await renewLockSenderLink.SendAsync(renewLockMessage);

    var renewLockResponse = await renewLockReceiverLink.ReceiveAsync();

    await renewLockSenderLink.CloseAsync();
    await renewLockReceiverLink.CloseAsync();
    await renewLockSession.CloseAsync();
    await connection.CloseAsync();
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
xinchen10commented, Dec 6, 2016

LockToken is of type Guid, so the line to create the lockToken should be,

    var lockToken = new Guid(message.DeliveryTag);

The request body is AmqpValue containing a map. It should be created like this,

        BodySection = new AmqpValue() { Value = new Map() { { "lock-tokens", new Guid[] { lockToken } } } }
0reactions
Blackbaud-CameronBlackcommented, Dec 8, 2016

… and now it works in both scenarios (with or without x-opt-partition-key). I could consistently recreate the issue up until about an hour ago. Now it just started working. Odd… thanks for the help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

RenewLock error using ServiceBus SubscriptionClient
One thing I've noticed is that when I create a new Topic and have EnabledPartioning = false, the problem does not occur. Has...
Read more >
Azure Service Bus message transfers, locks, and settlement
The client owning the lock can renew the message lock by using methods on the receiver object. Instead, you can use the automatic...
Read more >
Azure Service Bus - How to extend the lock of a message
We should double check all the time that the lock renew logic is done where we want and WHEN we want. We don't...
Read more >
Azure Service Bus lock renewal
Message lock renewal applies to only the message currently being processed. Prefetched messages that are not handled within the LockDuration ...
Read more >
Azure Service Bus Essentials — Message Settlement with ...
A consumer holding a lock on a message can renew it by calling methods on the receiver object. As an alternative, you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found