From 4f8a00ef2c48654915792b54819deae80c41e7d7 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Sun, 7 Nov 2021 03:49:37 +0000 Subject: [PATCH] - SupportsOrdering => SupportOrdering - Adding in autoDeleteOnIdle property which was missing for subscriptions --- .../azservicebus/admin_client_subscription.go | 11 +++++++++++ sdk/messaging/azservicebus/admin_client_test.go | 8 +++++--- sdk/messaging/azservicebus/admin_client_topic.go | 8 ++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/sdk/messaging/azservicebus/admin_client_subscription.go b/sdk/messaging/azservicebus/admin_client_subscription.go index 98d2df51fcbb..928623d8c197 100644 --- a/sdk/messaging/azservicebus/admin_client_subscription.go +++ b/sdk/messaging/azservicebus/admin_client_subscription.go @@ -46,6 +46,9 @@ type SubscriptionProperties struct { // Status is the current status of the queue. Status *EntityStatus + // AutoDeleteOnIdle is the idle interval after which the subscription is automatically deleted. + AutoDeleteOnIdle *time.Duration + // ForwardTo is the name of the recipient entity to which all the messages sent to the queue // are forwarded to. ForwardTo *string @@ -372,6 +375,7 @@ func newSubscriptionEnvelope(props *SubscriptionProperties, tokenProvider auth.T ForwardDeadLetteredMessagesTo: props.ForwardDeadLetteredMessagesTo, UserMetadata: props.UserMetadata, EnableBatchedOperations: props.EnableBatchedOperations, + AutoDeleteOnIdle: utils.DurationToStringPtr(props.AutoDeleteOnIdle), // TODO: when we get rule serialization in place. // DefaultRuleDescription: props.DefaultRuleDescription, // are these attributes just not valid anymore? @@ -393,6 +397,12 @@ func newSubscriptionProperties(desc *atom.SubscriptionDescription) (*Subscriptio return nil, err } + autoDeleteOnIdle, err := utils.ISO8601StringToDuration(desc.AutoDeleteOnIdle) + + if err != nil { + return nil, err + } + return &SubscriptionProperties{ RequiresSession: desc.RequiresSession, DeadLetteringOnMessageExpiration: desc.DeadLetteringOnMessageExpiration, @@ -405,6 +415,7 @@ func newSubscriptionProperties(desc *atom.SubscriptionDescription) (*Subscriptio DefaultMessageTimeToLive: defaultMessageTimeToLive, EnableBatchedOperations: desc.EnableBatchedOperations, Status: (*EntityStatus)(desc.Status), + AutoDeleteOnIdle: autoDeleteOnIdle, }, nil } diff --git a/sdk/messaging/azservicebus/admin_client_test.go b/sdk/messaging/azservicebus/admin_client_test.go index 498159e75dd3..a1a15ddfdb06 100644 --- a/sdk/messaging/azservicebus/admin_client_test.go +++ b/sdk/messaging/azservicebus/admin_client_test.go @@ -449,7 +449,7 @@ func TestAdminClient_TopicAndSubscription(t *testing.T) { EnableBatchedOperations: to.BoolPtr(true), Status: &status, AutoDeleteOnIdle: toDurationPtr(time.Minute * 7), - SupportsOrdering: to.BoolPtr(true), + SupportOrdering: to.BoolPtr(true), UserMetadata: to.StringPtr("user metadata"), }, nil) require.NoError(t, err) @@ -465,7 +465,7 @@ func TestAdminClient_TopicAndSubscription(t *testing.T) { EnableBatchedOperations: to.BoolPtr(true), Status: &status, AutoDeleteOnIdle: toDurationPtr(time.Minute * 7), - SupportsOrdering: to.BoolPtr(true), + SupportOrdering: to.BoolPtr(true), UserMetadata: to.StringPtr("user metadata"), }, addResp.TopicProperties) @@ -481,7 +481,7 @@ func TestAdminClient_TopicAndSubscription(t *testing.T) { EnableBatchedOperations: to.BoolPtr(true), Status: &status, AutoDeleteOnIdle: toDurationPtr(time.Minute * 7), - SupportsOrdering: to.BoolPtr(true), + SupportOrdering: to.BoolPtr(true), UserMetadata: to.StringPtr("user metadata"), }, getResp.TopicProperties) @@ -496,6 +496,7 @@ func TestAdminClient_TopicAndSubscription(t *testing.T) { // ForwardTo: &forwardToQueueName, // ForwardDeadLetteredMessagesTo: &forwardToQueueName, EnableBatchedOperations: to.BoolPtr(false), + AutoDeleteOnIdle: toDurationPtr(11 * time.Minute), UserMetadata: to.StringPtr("user metadata"), }, nil) require.NoError(t, err) @@ -513,6 +514,7 @@ func TestAdminClient_TopicAndSubscription(t *testing.T) { // ForwardTo: &forwardToQueueName, // ForwardDeadLetteredMessagesTo: &forwardToQueueName, EnableBatchedOperations: to.BoolPtr(false), + AutoDeleteOnIdle: toDurationPtr(11 * time.Minute), UserMetadata: to.StringPtr("user metadata"), }, addSubWithPropsResp.CreateSubscriptionResult.SubscriptionProperties) } diff --git a/sdk/messaging/azservicebus/admin_client_topic.go b/sdk/messaging/azservicebus/admin_client_topic.go index 10685fdd2781..1bc6352c0a9a 100644 --- a/sdk/messaging/azservicebus/admin_client_topic.go +++ b/sdk/messaging/azservicebus/admin_client_topic.go @@ -45,9 +45,9 @@ type TopicProperties struct { // EnablePartitioning indicates whether the topic is to be partitioned across multiple message brokers. EnablePartitioning *bool - // SupportsOrdering defines whether ordering needs to be maintained. If true, messages + // SupportOrdering defines whether ordering needs to be maintained. If true, messages // sent to topic will be forwarded to the subscription, in order. - SupportsOrdering *bool + SupportOrdering *bool // UserMetadata is custom metadata that user can associate with the topic. UserMetadata *string @@ -369,7 +369,7 @@ func newTopicEnvelope(props *TopicProperties, tokenProvider auth.TokenProvider) Status: (*atom.EntityStatus)(props.Status), UserMetadata: props.UserMetadata, - SupportOrdering: props.SupportsOrdering, + SupportOrdering: props.SupportOrdering, AutoDeleteOnIdle: utils.DurationToStringPtr(props.AutoDeleteOnIdle), EnablePartitioning: props.EnablePartitioning, } @@ -406,7 +406,7 @@ func newTopicProperties(td *atom.TopicDescription) (*TopicProperties, error) { UserMetadata: td.UserMetadata, AutoDeleteOnIdle: autoDeleteOnIdle, EnablePartitioning: td.EnablePartitioning, - SupportsOrdering: td.SupportOrdering, + SupportOrdering: td.SupportOrdering, }, nil }