Class: Azure::Storage::Queue::QueueService
- Inherits:
-
StorageService
- Object
- Azure::Storage::Queue::QueueService
- Defined in:
- queue/lib/azure/storage/queue/queue_service.rb
Class Method Summary collapse
-
.create(options = {}, &block) ⇒ Azure::Storage::Queue::QueueService
Public: Creates an instance of [Azure::Storage::Queue::QueueService].
-
.create_development(proxy_uri = nil, &block) ⇒ Azure::Storage::Queue::QueueService
Public: Creates an instance of [Azure::Storage::Queue::QueueService] with Storage Emulator.
-
.create_from_connection_string(connection_string, &block) ⇒ Azure::Storage::Queue::QueueService
Public: Creates an instance of [Azure::Storage::Queue::QueueService] from Environment Variables.
-
.create_from_env(&block) ⇒ Azure::Storage::Queue::QueueService
Public: Creates an instance of [Azure::Storage::Queue::QueueService] from Environment Variables.
Instance Method Summary collapse
-
#clear_messages(queue_name, options = {}) ⇒ Object
Public: Clears all messages from the queue.
-
#create_message(queue_name, message_text, options = {}) ⇒ Object
Public: Adds a message to the queue and optionally sets a visibility timeout for the message.
-
#create_queue(queue_name, options = {}) ⇒ Object
Public: Creates a new queue under the storage account.
-
#delete_message(queue_name, message_id, pop_receipt, options = {}) ⇒ Object
Public: Deletes a specified message from the queue.
-
#delete_queue(queue_name, options = {}) ⇒ Object
Public: Deletes a queue.
-
#get_queue_acl(queue_name, options = {}) ⇒ Object
Public: Gets the access control list (ACL) for the queue.
-
#get_queue_metadata(queue_name, options = {}) ⇒ Object
Public: Returns queue properties, including user-defined metadata.
-
#initialize(options = {}, &block) ⇒ QueueService
constructor
Public: Initializes an instance of [Azure::Storage::Queue::QueueService].
-
#list_messages(queue_name, visibility_timeout, options = {}) ⇒ Object
Public: Retrieves one or more messages from the front of the queue.
-
#list_queues(options = {}) ⇒ Object
Public: Get a list of Queues from the server.
-
#peek_messages(queue_name, options = {}) ⇒ Object
Public: Retrieves one or more messages from the front of the queue, without changing the message visibility.
-
#set_queue_acl(queue_name, options = {}) ⇒ Object
Public: Sets the access control list (ACL) for the queue.
-
#set_queue_metadata(queue_name, metadata, options = {}) ⇒ Object
Public: Sets user-defined metadata on the queue.
-
#update_message(queue_name, message_id, pop_receipt, message_text, visibility_timeout, options = {}) ⇒ Object
Public: Adds a message to the queue and optionally sets a visibility timeout for the message.
Constructor Details
#initialize(options = {}, &block) ⇒ QueueService
Public: Initializes an instance of [Azure::Storage::Queue::QueueService]
Attributes
-
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:use_development_storage
- TrueClass|FalseClass. Whether to use storage emulator. -
:development_storage_proxy_uri
- String. Used with:use_development_storage
if emulator is hosted other than localhost. -
:storage_connection_string
- String. The storage connection string. -
:storage_account_name
- String. The name of the storage account. -
:storage_access_key
- Base64 String. The access key of the storage account. -
:storage_sas_token
- String. The signed access signature for the storage account or one of its service. -
:storage_queue_host
- String. Specified Queue serivce endpoint or hostname -
:storage_dns_suffix
- String. The suffix of a regional Storage Serivce, to -
:default_endpoints_protocol
- String. http or https -
:use_path_style_uri
- String. Whether use path style URI for specified endpoints -
:ca_file
- String. File path of the CA file if having issue with SSL -
:ssl_version
- Symbol. The ssl version to be used, sample: :TLSv1_1, :TLSv1_2, for the details, see github.com/ruby/openssl/blob/master/lib/openssl/ssl.rb -
:ssl_min_version
- Symbol. The min ssl version supported, only supported in Ruby 2.5+ -
:ssl_max_version
- Symbol. The max ssl version supported, only supported in Ruby 2.5+ -
:user_agent_prefix
- String. The user agent prefix that can identify the application calls the library -
:client
- Azure::Storage::Common::Client. The common client used to initalize the service.
The valid set of options include:
-
Storage Emulator:
:use_development_storage
required,:development_storage_proxy_uri
optionally -
Storage account name and key:
:storage_account_name
and:storage_access_key
required, set:storage_dns_suffix
necessarily -
Storage account name and SAS token:
:storage_account_name
and:storage_sas_token
required, set:storage_dns_suffix
necessarily -
Specified hosts and SAS token: At least one of the service host and SAS token. It's up to user to ensure the SAS token is suitable for the serivce
-
Azure::Storage::Common::Client: The common client used to initalize the service. This client can be initalized and used repeatedly.
-
Anonymous Queue: only
:storage_queue_host
, if it is to only access queues within a container
Additional notes:
-
Specified hosts can be set when use account name with access key or sas token
-
:default_endpoints_protocol
can be set if the scheme is not specified in hosts -
Storage emulator always use path style URI
-
:ca_file
is independent.
When empty options are given, it will try to read settings from Environment Variables. Refer to [Azure::Storage::Common::ClientOptions.env_vars_mapping] for the mapping relationship
155 156 157 158 159 160 161 162 163 164 165 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 155 def initialize( = {}, &block) = .clone client_config = [:client] ||= Azure::Storage::Common::Client::create(, &block) @user_agent_prefix = [:user_agent_prefix] if [:user_agent_prefix] @api_version = [:api_version] || Azure::Storage::Queue::Default::STG_VERSION signer = [:signer] || client_config.signer || Azure::Storage::Common::Core::Auth::SharedKey.new(client_config.storage_account_name, client_config.storage_access_key) signer.api_ver = @api_version if signer.is_a? Azure::Storage::Common::Core::Auth::SharedAccessSignatureSigner super(signer, client_config.storage_account_name, , &block) @storage_service_host[:primary] = client.storage_queue_host @storage_service_host[:secondary] = client.storage_queue_host true end |
Class Method Details
.create(options = {}, &block) ⇒ Azure::Storage::Queue::QueueService
Public: Creates an instance of [Azure::Storage::Queue::QueueService]
Attributes
-
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:use_development_storage
- TrueClass|FalseClass. Whether to use storage emulator. -
:development_storage_proxy_uri
- String. Used with:use_development_storage
if emulator is hosted other than localhost. -
:storage_account_name
- String. The name of the storage account. -
:storage_access_key
- Base64 String. The access key of the storage account. -
:storage_sas_token
- String. The signed access signature for the storage account or one of its service. -
:storage_queue_host
- String. Specified Queue service endpoint or hostname -
:storage_dns_suffix
- String. The suffix of a regional Storage Service, to -
:default_endpoints_protocol
- String. http or https -
:use_path_style_uri
- String. Whether use path style URI for specified endpoints -
:ca_file
- String. File path of the CA file if having issue with SSL -
:ssl_version
- Symbol. The ssl version to be used, sample: :TLSv1_1, :TLSv1_2, for the details, see github.com/ruby/openssl/blob/master/lib/openssl/ssl.rb -
:ssl_min_version
- Symbol. The min ssl version supported, only supported in Ruby 2.5+ -
:ssl_max_version
- Symbol. The max ssl version supported, only supported in Ruby 2.5+ -
:user_agent_prefix
- String. The user agent prefix that can identify the application calls the library
The valid set of options include:
-
Storage Emulator:
:use_development_storage
required,:development_storage_proxy_uri
optionally -
Storage account name and key:
:storage_account_name
and:storage_access_key
required, set:storage_dns_suffix
necessarily -
Storage account name and SAS token:
:storage_account_name
and:storage_sas_token
required, set:storage_dns_suffix
necessarily -
Specified hosts and SAS token: At least one of the service host and SAS token. It's up to user to ensure the SAS token is suitable for the serivce
-
Anonymous Queue: only
:storage_queue_host
, if it is to only access queues within a container
Additional notes:
-
Specified hosts can be set when use account name with access key or sas token
-
:default_endpoints_protocol
can be set if the scheme is not specified in hosts -
Storage emulator always use path style URI
-
:ca_file
is independent.
When empty options are given, it will try to read settings from Environment Variables. Refer to [Azure::Storage::Common::ClientOptions.env_vars_mapping] for the mapping relationship
74 75 76 77 78 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 74 def create( = {}, &block) = { client: Azure::Storage::Common::Client::create(, &block), api_version: Azure::Storage::Queue::Default::STG_VERSION } [:user_agent_prefix] = [:user_agent_prefix] if [:user_agent_prefix] Azure::Storage::Queue::QueueService.new(, &block) end |
.create_development(proxy_uri = nil, &block) ⇒ Azure::Storage::Queue::QueueService
Public: Creates an instance of [Azure::Storage::Queue::QueueService] with Storage Emulator
Attributes
-
proxy_uri
- String. Used with:use_development_storage
if emulator is hosted other than localhost.
87 88 89 90 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 87 def create_development(proxy_uri = nil, &block) = { client: Azure::Storage::Common::Client::create_development(proxy_uri, &block), api_version: Azure::Storage::Queue::Default::STG_VERSION } Azure::Storage::Queue::QueueService.new(, &block) end |
.create_from_connection_string(connection_string, &block) ⇒ Azure::Storage::Queue::QueueService
Public: Creates an instance of [Azure::Storage::Queue::QueueService] from Environment Variables
Attributes
-
connection_string
- String. Please refer to azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/.
107 108 109 110 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 107 def create_from_connection_string(connection_string, &block) = { client: Azure::Storage::Common::Client::create_from_connection_string(connection_string, &block), api_version: Azure::Storage::Queue::Default::STG_VERSION } Azure::Storage::Queue::QueueService.new(, &block) end |
.create_from_env(&block) ⇒ Azure::Storage::Queue::QueueService
Public: Creates an instance of [Azure::Storage::Queue::QueueService] from Environment Variables
95 96 97 98 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 95 def create_from_env(&block) = { client: Azure::Storage::Common::Client::create_from_env(&block), api_version: Azure::Storage::Queue::Default::STG_VERSION } Azure::Storage::Queue::QueueService.new(, &block) end |
Instance Method Details
#clear_messages(queue_name, options = {}) ⇒ Object
Public: Clears all messages from the queue.
If a queue contains a large number of messages, Clear Messages may time out before all messages have been deleted. In this case the Queue service will return status code 500 (Internal Server Error), with the additional error code OperationTimedOut. If the operation times out, the client should continue to retry Clear Messages until it succeeds, to ensure that all messages have been deleted.
Attributes
-
queue_name
- String. The name of the queue. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds. -
:request_id
- String. Provides a client-generated, opaque value with a 1 KB character limit that is recordedin the analytics logs when storage analytics logging is enabled.
See msdn.microsoft.com/en-us/library/azure/dd179454
Returns nil on success
248 249 250 251 252 253 254 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 248 def (queue_name, = {}) query = {} query["timeout"] = [:timeout].to_s if [:timeout] uri = (queue_name, query) call(:delete, uri, nil, {}, ) nil end |
#create_message(queue_name, message_text, options = {}) ⇒ Object
Public: Adds a message to the queue and optionally sets a visibility timeout for the message.
Attributes
-
queue_name
- String. The queue name. -
message_text
- String. The message contents. Note that the message content must be in a format that may be encoded with UTF-8. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:visibility_timeout
- Integer. Specifies the new visibility timeout value, in seconds, relative to servertime. The new value must be larger than or equal to 0, and cannot be larger than 7 days. The visibility timeout of a message cannot be set to a value later than the expiry time. :visibility_timeout should be set to a value smaller than the time-to-live value. If not specified, the default value is 0.
-
:message_ttl
- Integer. Specifies the time-to-live interval for the message, in seconds. The maximumtime-to-live allowed is 7 days. If not specified, the default time-to-live is 7 days.
-
:encode
- Boolean. If set to true, the message will be base64 encoded. -
:timeout
- Integer. A timeout in seconds. -
:request_id
- String. Provides a client-generated, opaque value with a 1 KB character limit that is recordedin the analytics logs when storage analytics logging is enabled.
See msdn.microsoft.com/en-us/library/azure/dd179346
Returns a list of Azure::Storage::Queue::Message object containing only the echo of request on success
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 471 def (queue_name, , = {}) query = {} unless .empty? query["visibilitytimeout"] = [:visibility_timeout] if [:visibility_timeout] query["messagettl"] = [:message_ttl] if [:message_ttl] query["timeout"] = [:timeout].to_s if [:timeout] end uri = (queue_name, query) body = Serialization.(, [:encode]) response = call(:post, uri, body, {}, ) Serialization.(response.body, [:decode]) end |
#create_queue(queue_name, options = {}) ⇒ Object
Public: Creates a new queue under the storage account.
Attributes
-
queue_name
- String. The queue name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:metadata
- Hash. A hash of user defined metadata. -
:timeout
- Integer. A timeout in seconds. -
:request_id
- String. Provides a client-generated, opaque value with a 1 KB character limit that is recordedin the analytics logs when storage analytics logging is enabled.
See msdn.microsoft.com/en-us/library/azure/dd179342
Returns nil on success
274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 274 def create_queue(queue_name, = {}) query = {} query["timeout"] = [:timeout].to_s if [:timeout] uri = queue_uri(queue_name, query) headers = {} StorageService.([:metadata] || {}, headers) if [:metadata] call(:put, uri, nil, headers, ) nil end |
#delete_message(queue_name, message_id, pop_receipt, options = {}) ⇒ Object
Public: Deletes a specified message from the queue.
Attributes
-
queue_name
- String. The queue name. -
message_id
- String. The id of the message. -
pop_receipt
- String. The valid pop receipt value returned from an earlier call to the Get Messages orUpdate Message operation.
-
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds. -
:request_id
- String. Provides a client-generated, opaque value with a 1 KB character limit that is recordedin the analytics logs when storage analytics logging is enabled.
See msdn.microsoft.com/en-us/library/azure/dd179347
Returns nil on success
Remarks:
When a message is successfully deleted, it is immediately marked for deletion and is no longer accessible to clients. The message is later removed from the queue during garbage collection.
After a client retrieves a message with the Get Messages operation, the client is expected to process and delete the message. To delete the message, you must have two items of data returned in the response body of the Get Messages operation:
-
The message ID, an opaque GUID value that identifies the message in the queue.
-
A valid pop receipt, an opaque value that indicates that the message has been retrieved.
The message ID is returned from the previous Get Messages operation. The pop receipt is returned from the most recent Get Messages or Update Message operation. In order for the Delete Message operation to succeed, the pop receipt specified on the request must match the pop receipt returned from the Get Messages or Update Message operation.
Pop receipts remain valid until one of the following events occurs:
-
The message has expired.
-
The message has been deleted using the last pop receipt received either from Get Messages or Update Message.
-
The invisibility time has elapsed and the message has been dequeued by a Get Messages request. When the
invisibility time elapses, the message becomes visible again. If it is retrieved by another Get Messages request, the returned pop receipt can be used to delete or update the message.
-
The message has been updated with a new visibility timeout. When the message is updated, a new pop receipt
will be returned.
If the message has already been deleted when Delete Message is called, the Queue service returns status code 404 (Not Found).
If a message with a matching pop receipt is not found, the service returns status code 400 (Bad Request), with additional error information indicating that the cause of the failure was a mismatched pop receipt.
545 546 547 548 549 550 551 552 553 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 545 def (queue_name, , pop_receipt, = {}) query = { "popreceipt" => pop_receipt } query["timeout"] = [:timeout].to_s if [:timeout] uri = (queue_name, , query) call(:delete, uri, nil, {}, ) nil end |
#delete_queue(queue_name, options = {}) ⇒ Object
Public: Deletes a queue.
Attributes
-
queue_name
- String. The queue name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds. -
:request_id
- String. Provides a client-generated, opaque value with a 1 KB character limit that is recordedin the analytics logs when storage analytics logging is enabled.
See msdn.microsoft.com/en-us/library/azure/dd179436
Returns nil on success
304 305 306 307 308 309 310 311 312 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 304 def delete_queue(queue_name, = {}) query = {} query["timeout"] = [:timeout].to_s if [:timeout] uri = queue_uri(queue_name, query) call(:delete, uri, nil, {}, ) nil end |
#get_queue_acl(queue_name, options = {}) ⇒ Object
Public: Gets the access control list (ACL) for the queue.
Attributes
-
queue_name
- String. The queue name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds. -
:request_id
- String. Provides a client-generated, opaque value with a 1 KB character limit that is recordedin the analytics logs when storage analytics logging is enabled.
-
:location_mode
- LocationMode. Specifies the location mode used to decidewhich location the request should be sent to.
See msdn.microsoft.com/en-us/library/azure/jj159101
Returns a list of Azure::Storage::Entity::SignedIdentifier instances
403 404 405 406 407 408 409 410 411 412 413 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 403 def get_queue_acl(queue_name, = {}) query = { "comp" => "acl" } query["timeout"] = [:timeout].to_s if [:timeout] [:request_location_mode] = Azure::Storage::Common::RequestLocationMode::PRIMARY_OR_SECONDARY response = call(:get, queue_uri(queue_name, query, ), nil, {}, ) signed_identifiers = [] signed_identifiers = Serialization.signed_identifiers_from_xml(response.body) unless response.body == (nil) || response.body.length < (1) signed_identifiers end |
#get_queue_metadata(queue_name, options = {}) ⇒ Object
Public: Returns queue properties, including user-defined metadata.
Attributes
-
queue_name
- String. The queue name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds. -
:request_id
- String. Provides a client-generated, opaque value with a 1 KB character limit that is recordedin the analytics logs when storage analytics logging is enabled.
-
:location_mode
- LocationMode. Specifies the location mode used to decidewhich location the request should be sent to.
See msdn.microsoft.com/en-us/library/azure/dd179384
Returns a tuple of (approximate_message_count, metadata)
-
approximate_messages_count - Integer. The approximate number of messages in the queue. This number is not lower than the actual number of messages in the queue, but could be higher.
-
metadata - Hash. The queue metadata (Default: {})
337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 337 def (queue_name, = {}) query = { "comp" => "metadata" } query["timeout"] = [:timeout].to_s if [:timeout] [:request_location_mode] = Azure::Storage::Common::RequestLocationMode::PRIMARY_OR_SECONDARY uri = queue_uri(queue_name, query, ) response = call(:get, uri, nil, {}, ) = response.headers["x-ms-approximate-messages-count"] = Serialization.(response.headers) return .to_i, end |
#list_messages(queue_name, visibility_timeout, options = {}) ⇒ Object
Public: Retrieves one or more messages from the front of the queue.
Attributes
-
queue_name
- String. The queue name. -
visibility_timeout
- Integer. The new visibility timeout value, in seconds, relative to server time. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:number_of_messages
- Integer. How many messages to return. (optional, Default: 1) -
:timeout
- Integer. A timeout in seconds. -
:request_id
- String. Provides a client-generated, opaque value with a 1 KB character limit that is recordedin the analytics logs when storage analytics logging is enabled.
-
:decode
- Boolean. Boolean value indicating if the message should be base64 decoded.
See msdn.microsoft.com/en-us/library/azure/dd179474
Returns a list of Azure::Storage::Entity::Queue::Message instances
611 612 613 614 615 616 617 618 619 620 621 622 623 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 611 def (queue_name, visibility_timeout, = {}) = 1 = [:number_of_messages] if [:number_of_messages] query = { "visibilitytimeout" => visibility_timeout.to_s, "numofmessages" => .to_s } query["timeout"] = [:timeout].to_s if [:timeout] uri = (queue_name, query) response = call(:get, uri, nil, {}, ) = Serialization.(response.body, [:decode]) end |
#list_queues(options = {}) ⇒ Object
Public: Get a list of Queues from the server
Attributes
-
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:prefix
- String. Filters the results to return only containerswhose name begins with the specified prefix. (optional)
-
:marker
- String. An identifier the specifies the portion of thelist to be returned. This value comes from the property Azure::Service::EnumerationResults.continuation_token when there are more containers available than were returned. The marker value may then be used here to request the next set of list items. (optional)
-
:max_results
- Integer. Specifies the maximum number of containers to return.If max_results is not specified, or is a value greater than 5,000, the server will return up to 5,000 items. If it is set to a value less than or equal to zero, the server will return status code 400 (Bad Request). (optional)
-
:metadata
- Boolean. Specifies whether or not to return the container metadata.(optional, Default=false)
-
:timeout
- Integer. A timeout in seconds. -
:request_id
- String. Provides a client-generated, opaque value with a 1 KB character limit that is recordedin the analytics logs when storage analytics logging is enabled.
-
:location_mode
- LocationMode. Specifies the location mode used to decidewhich location the request should be sent to.
NOTE: Metadata requested with the :metadata parameter must have been stored in accordance with the naming restrictions imposed by the 2009-09-19 version of the queue service. Beginning with that version, all metadata names must adhere to the naming conventions for C# identifiers.
See msdn.microsoft.com/en-us/library/azure/dd179466
Any metadata with invalid names which were previously stored, will be returned with the key “x-ms-invalid-name” in the metadata hash. This may contain multiple values and be an Array (vs a String if it only contains a single value).
Returns an Azure::Storage::Common::EnumerationResults
209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 209 def list_queues( = {}) query = {} query["prefix"] = [:prefix] if [:prefix] query["marker"] = [:marker] if [:marker] query["maxresults"] = [:max_results].to_s if [:max_results] query["include"] = "metadata" if [:metadata] == true query["timeout"] = [:timeout].to_s if [:timeout] [:request_location_mode] = Azure::Storage::Common::RequestLocationMode::PRIMARY_OR_SECONDARY uri = collection_uri(query, ) response = call(:get, uri, nil, {}, ) Serialization.queue_enumeration_results_from_xml(response.body) end |
#peek_messages(queue_name, options = {}) ⇒ Object
Public: Retrieves one or more messages from the front of the queue, without changing the message visibility.
Attributes
-
queue_name
- String. The queue name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:number_of_messages
- Integer. How many messages to return. (optional, Default: 1) -
:decode
- Boolean. Boolean value indicating if the message should be base64 decoded. -
:timeout
- Integer. A timeout in seconds. -
:request_id
- String. Provides a client-generated, opaque value with a 1 KB character limit that is recordedin the analytics logs when storage analytics logging is enabled.
-
:location_mode
- LocationMode. Specifies the location mode used to decidewhich location the request should be sent to.
See msdn.microsoft.com/en-us/library/azure/dd179472
Returns a list of Azure::Storage::Entity::Queue::Message instances
576 577 578 579 580 581 582 583 584 585 586 587 588 589 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 576 def (queue_name, = {}) = 1 = [:number_of_messages] if [:number_of_messages] query = { "peekonly" => "true", "numofmessages" => .to_s } query["timeout"] = [:timeout].to_s if [:timeout] [:request_location_mode] = Azure::Storage::Common::RequestLocationMode::PRIMARY_OR_SECONDARY uri = (queue_name, query, ) response = call(:get, uri, nil, {}, ) = Serialization.(response.body, [:decode]) end |
#set_queue_acl(queue_name, options = {}) ⇒ Object
Public: Sets the access control list (ACL) for the queue.
Attributes
-
queue_name
- String. The queue name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:signed_identifiers
- Array. A list of Azure::Storage::Entity::SignedIdentifier instances -
:timeout
- Integer. A timeout in seconds. -
:request_id
- String. Provides a client-generated, opaque value with a 1 KB character limit that is recordedin the analytics logs when storage analytics logging is enabled.
See msdn.microsoft.com/en-us/library/azure/jj159099
Returns nil on success
433 434 435 436 437 438 439 440 441 442 443 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 433 def set_queue_acl(queue_name, = {}) query = { "comp" => "acl" } query["timeout"] = [:timeout].to_s if [:timeout] uri = queue_uri(queue_name, query) body = nil body = Serialization.signed_identifiers_to_xml([:signed_identifiers]) if [:signed_identifiers] && [:signed_identifiers].length > 0 call(:put, uri, body, {}, ) nil end |
#set_queue_metadata(queue_name, metadata, options = {}) ⇒ Object
Public: Sets user-defined metadata on the queue. To delete queue metadata, call this API with an empty hash in the metadata parameter.
Attributes
-
queue_name
- String. The queue name. -
metadata
- Hash. A hash of user defined metadata -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. A timeout in seconds. -
:request_id
- String. Provides a client-generated, opaque value with a 1 KB character limit that is recordedin the analytics logs when storage analytics logging is enabled.
See msdn.microsoft.com/en-us/library/azure/dd179348
Returns nil on success
371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 371 def (queue_name, , = {}) query = { "comp" => "metadata" } query["timeout"] = [:timeout].to_s if [:timeout] uri = queue_uri(queue_name, query) headers = {} StorageService.( || {}, headers) call(:put, uri, nil, headers, ) nil end |
#update_message(queue_name, message_id, pop_receipt, message_text, visibility_timeout, options = {}) ⇒ Object
Public: Adds a message to the queue and optionally sets a visibility timeout for the message.
Attributes
-
queue_name
- String. The queue name. -
message_id
- String. The id of the message. -
pop_receipt
- String. The valid pop receipt value returned from an earlier call to the Get Messages orupdate Message operation.
-
message_text
- String. The message contents. Note that the message content must be in a format that maybe encoded with UTF-8.
-
visibility_timeout
- Integer. The new visibility timeout value, in seconds, relative to server time. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:encode
- Boolean. If set to true, the message will be base64 encoded. -
:timeout
- Integer. A timeout in seconds. -
:request_id
- String. Provides a client-generated, opaque value with a 1 KB character limit that is recordedin the analytics logs when storage analytics logging is enabled.
See msdn.microsoft.com/en-us/library/azure/hh452234
Returns a tuple of (pop_receipt, time_next_visible)
-
pop_receipt - String. The pop receipt of the queue message.
-
time_next_visible - String. A UTC date/time value that represents when the message will be visible on the queue.
Remarks:
An Update Message operation will fail if the specified message does not exist in the queue, or if the specified pop receipt does not match the message.
A pop receipt is returned by the Get Messages operation or the Update Message operation. Pop receipts remain valid until one of the following events occurs:
-
The message has expired.
-
The message has been deleted using the last pop receipt received either from Get Messages or
Update Message.
-
The invisibility time has elapsed and the message has been dequeued by a Get Messages request. When
the invisibility time elapses, the message becomes visible again. If it is retrieved by another Get Messages request, the returned pop receipt can be used to delete or update the message.
-
The message has been updated with a new visibility timeout. When the message is updated, a new pop
receipt will be returned.
The Update Message operation can be used to continually extend the invisibility of a queue message. This functionality can be useful if you want a worker role to “lease” a queue message. For example, if a worker role calls Get Messages and recognizes that it needs more time to process a message, it can continually extend the message's invisibility until it is processed. If the worker role were to fail during processing, eventually the message would become visible again and another worker role could process it.
678 679 680 681 682 683 684 685 686 687 688 689 |
# File 'queue/lib/azure/storage/queue/queue_service.rb', line 678 def (queue_name, , pop_receipt, , visibility_timeout, = {}) query = { "visibilitytimeout" => visibility_timeout.to_s, "popreceipt" => pop_receipt } query["timeout"] = [:timeout].to_s if [:timeout] uri = (queue_name, , query) body = Serialization.(, [:encode]) response = call(:put, uri, body, {}, ) new_pop_receipt = response.headers["x-ms-popreceipt"] time_next_visible = response.headers["x-ms-time-next-visible"] return new_pop_receipt, time_next_visible end |