diff --git a/sdk/messaging_servicebus/src/service_bus/mod.rs b/sdk/messaging_servicebus/src/service_bus/mod.rs index 3cf8babefd..49d94e9487 100644 --- a/sdk/messaging_servicebus/src/service_bus/mod.rs +++ b/sdk/messaging_servicebus/src/service_bus/mod.rs @@ -139,10 +139,10 @@ async fn peek_lock_message( queue_or_topic: &str, policy_name: &str, signing_key: &Secret, - lock_expiry: Option, + timeout: Option, subscription: Option<&str>, ) -> azure_core::Result { - let url = craft_peek_lock_url(namespace, queue_or_topic, lock_expiry, subscription)?; + let url = craft_peek_lock_url(namespace, queue_or_topic, timeout, subscription)?; let req = finalize_request(url.as_ref(), Method::Post, None, policy_name, signing_key)?; @@ -162,10 +162,10 @@ async fn peek_lock_message2( queue_or_topic: &str, policy_name: &str, signing_key: &Secret, - lock_expiry: Option, + timeout: Option, subscription: Option<&str>, ) -> azure_core::Result { - let url = craft_peek_lock_url(namespace, queue_or_topic, lock_expiry, subscription)?; + let url = craft_peek_lock_url(namespace, queue_or_topic, timeout, subscription)?; let req = finalize_request(url.as_ref(), Method::Post, None, policy_name, signing_key)?; diff --git a/sdk/messaging_servicebus/src/service_bus/queue_client.rs b/sdk/messaging_servicebus/src/service_bus/queue_client.rs index e1347f99d5..b88543d1a2 100644 --- a/sdk/messaging_servicebus/src/service_bus/queue_client.rs +++ b/sdk/messaging_servicebus/src/service_bus/queue_client.rs @@ -79,13 +79,16 @@ impl QueueClient { /// Non-destructively read a message /// + /// * `timeout` : Sets the maximum duration for the HTTP connection when receiving a message. + /// If no message is received within this time, an empty 204 HTTP response will be returned. + /// /// Note: This function does not return the delete location /// of the message, so, after reading, you will lose /// "track" of it until the lock expiry runs out and /// the message can be consumed by others. If you want to keep /// track of this message (i.e., have the possibility of deletion), /// use `peek_lock_message2`. - pub async fn peek_lock_message(&self, lock_expiry: Option) -> Result { + pub async fn peek_lock_message(&self, timeout: Option) -> Result { body_bytes_to_utf8( peek_lock_message( &self.http_client, @@ -93,7 +96,7 @@ impl QueueClient { &self.queue, &self.policy_name, &self.signing_key, - lock_expiry, + timeout, None, ) .await? @@ -103,6 +106,9 @@ impl QueueClient { /// Non-destructively read a message but track it /// + /// * `timeout` : Sets the maximum duration for the HTTP connection when receiving a message. + /// If no message is received within this time, an empty 204 HTTP response will be returned. + /// /// Note: This function returns a `PeekLockResponse` /// that contains a helper `delete_message` function. pub async fn peek_lock_message2( diff --git a/sdk/messaging_servicebus/src/service_bus/topic_client.rs b/sdk/messaging_servicebus/src/service_bus/topic_client.rs index c05b7e05b5..795e6df9a6 100644 --- a/sdk/messaging_servicebus/src/service_bus/topic_client.rs +++ b/sdk/messaging_servicebus/src/service_bus/topic_client.rs @@ -115,13 +115,16 @@ impl SubscriptionReceiver { /// Non-destructively read a message /// + /// * `timeout` : Sets the maximum duration for the HTTP connection when receiving a message. + /// If no message is received within this time, an empty 204 HTTP response will be returned. + /// /// Note: This function does not return the delete location /// of the message, so, after reading, you will lose /// "track" of it until the lock expiry runs out and /// the message can be consumed by others. If you want to keep /// track of this message (i.e., have the possibility of deletion), /// use `peek_lock_message2`. - pub async fn peek_lock_message(&self, lock_expiry: Option) -> Result { + pub async fn peek_lock_message(&self, timeout: Option) -> Result { body_bytes_to_utf8( peek_lock_message( &self.topic_client.http_client, @@ -129,7 +132,7 @@ impl SubscriptionReceiver { &self.topic_client.topic, &self.topic_client.policy_name, &self.topic_client.signing_key, - lock_expiry, + timeout, Some(&self.subscription), ) .await? @@ -139,6 +142,9 @@ impl SubscriptionReceiver { /// Non-destructively read a message but track it /// + /// * `timeout` : Sets the maximum duration for the HTTP connection when receiving a message. + /// If no message is received within this time, an empty 204 HTTP response will be returned. + /// /// Note: This function returns a `PeekLockResponse` /// that contains a helper `delete_message` function. pub async fn peek_lock_message2( diff --git a/sdk/messaging_servicebus/src/utils.rs b/sdk/messaging_servicebus/src/utils.rs index f417693a39..f1936a521f 100644 --- a/sdk/messaging_servicebus/src/utils.rs +++ b/sdk/messaging_servicebus/src/utils.rs @@ -7,7 +7,7 @@ use std::time::Duration; pub fn craft_peek_lock_url( namespace: &str, queue_or_topic: &str, - lock_expiry: Option, + timeout: Option, subscription: Option<&str>, ) -> Result { let url_path = get_head_url(namespace, queue_or_topic, subscription); @@ -17,7 +17,7 @@ pub fn craft_peek_lock_url( )?; // add timeout, if given - if let Some(t) = lock_expiry { + if let Some(t) = timeout { url.query_pairs_mut() .append_pair("timeout", &t.as_secs().to_string()); };