amqp:internal-error trying to implement renew-lock for ServiceBus
See original GitHub issueHi, 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:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
LockToken is of type Guid, so the line to create the lockToken should be,
The request body is AmqpValue containing a map. It should be created like this,
… 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!