Class: Azure::ServiceBus::ServiceBusService
- Inherits:
-
Core::SignedService
- Object
- Core::Service
- Core::FilteredService
- Core::SignedService
- Azure::ServiceBus::ServiceBusService
- Defined in:
- lib/azure/service_bus/service_bus_service.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
60
Instance Attribute Summary
Attributes inherited from Core::SignedService
Attributes inherited from Core::FilteredService
Attributes inherited from Core::Service
Instance Method Summary collapse
-
#create_queue(queue, options = {}) ⇒ Object
Creates a new queue.
-
#create_rule(*p) ⇒ Object
Creates a new rule.
-
#create_subscription(*p) ⇒ Object
Creates a new subscription.
-
#create_topic(topic, options = {}) ⇒ Object
Creates a new topic.
-
#delete_queue(queue) ⇒ Object
Deletes an existing queue.
-
#delete_queue_message(message) ⇒ Object
Completes processing on a locked message and delete it from the queue.
-
#delete_rule(*p) ⇒ Object
Deletes an existing rule.
-
#delete_subscription(*p) ⇒ Object
Deletes an existing subscription.
-
#delete_subscription_message(message) ⇒ Object
Completes processing on a locked message and delete it from the subscription.
-
#delete_topic(topic) ⇒ Object
Deletes an existing topic.
-
#get_queue(queue) ⇒ Object
Retrieves an existing queue.
-
#get_rule(*p) ⇒ Object
Retrieves the description for the specified rule.
-
#get_subscription(*p) ⇒ Object
Gets an existing subscription.
-
#get_topic(topic) ⇒ Object
Retrieves the description for the specified topic.
-
#initialize(host = Azure.config.service_bus_host) ⇒ ServiceBusService
constructor
A new instance of ServiceBusService.
-
#list_queues(options = {}) ⇒ Object
Enumerates the queues in the service namespace.
-
#list_rules(*p) ⇒ Object
Retrieves the rules that exist under the specified subscription.
-
#list_subscriptions(topic, options = {}) ⇒ Object
Retrieves the subscriptions in the specified topic.
-
#list_topics(options = {}) ⇒ Object
Retrieves the topics in the service namespace.
-
#peek_lock_queue_message(queue, options = {}) ⇒ Object
Automatically retrieves and locks a message from a queue for processing.
-
#peek_lock_subscription_message(topic, subscription, options = {}) ⇒ Object
This operation is used to atomically retrieve and lock a message for processing.
-
#read_delete_queue_message(queue, options = {}) ⇒ Object
Reads and deletes a message from a queue as an atomic operation.
-
#read_delete_subscription_message(topic, subscription, options = {}) ⇒ Object
Read and delete a message from a subscription as an atomic operation.
-
#receive_queue_message(queue, options = {}) ⇒ Object
Public: Receives a queue message.
-
#receive_subscription_message(topic, subscription, options = {}) ⇒ Object
Public: Receives a subscription message.
-
#send_queue_message(queue, message) ⇒ Object
Sends a message into the specified queue.
-
#send_topic_message(topic, message) ⇒ Object
Enqueues a message into the specified topic.
-
#unlock_queue_message(message) ⇒ Object
Unlocks a message for processing by other receivers on a given subscription.
-
#unlock_subscription_message(message) ⇒ Object
Unlock a message for processing by other receivers on a given subscription.
Methods inherited from Core::SignedService
Methods inherited from Core::FilteredService
Methods inherited from Core::Service
Constructor Details
#initialize(host = Azure.config.service_bus_host) ⇒ ServiceBusService
Returns a new instance of ServiceBusService.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 28 def initialize(host=Azure.config.service_bus_host) super(Azure::ServiceBus::Auth::WrapSigner.new) @host = host with_filter do |req, res| req.headers.delete "x-ms-date" req.headers.delete "x-ms-version" req.headers.delete "DataServiceVersion" req.headers.delete "MaxDataServiceVersion" res.call end end |
Instance Method Details
#create_queue(queue, options = {}) ⇒ Object
Creates a new queue. Once created, this queue’s resource manifest is immutable.
Attributes
-
queue
- Azure::ServiceBus::Queue instance to create on server, or a string of the queue name -
options
- Hash. The queue properties.
Options
Accepted key/value pairs in options parameter are:
-
:default_message_time_to_live
- XML datetime. Determines how long a message lives in the associated subscriptions. -
:duplicate_detection_history_time_window
- XML datetime. Specifies the time span during which the Service Bus will detect message duplication. -
:enable_batched_operations
- Boolean. Enables or disables service side batching behavior when performing operations for the specific queue. -
:dead_lettering_on_message_expiration:
- Boolean. This field controls how the Service Bus handles a message whose TTL has expired. -
:lock_duration
- XML datetime. Determines the amount of time in seconds in which a message should be locked for processing by a receiver. -
:max_delivery_count
- Number. A message is automatically deadlettered after this number of deliveries. -
:max_size_in_megabytes
- Number. Specifies the maximum topic size in megabytes -
:message_count
- Number. Displays the number of messages currently in the queue. -
:requires_duplicate_detection
- Boolean. If enabled, the topic will detect duplicate messages within the time span specified by the DuplicateDetectionHistoryTimeWindow property -
:requires_session
- Boolean. If set to true, the queue will be session-aware and only SessionReceiver will be supported. -
:size_in_bytes
- Number. Reflects the actual bytes toward the topic quota that messages in the topic currently occupy.
63 64 65 66 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 63 def create_queue(queue, ={}) queue = _new_or_existing(Azure::ServiceBus::Queue, queue, ? : {}) create_resource_entry(:queue, queue, queue.name) end |
#create_rule(*p) ⇒ Object
Creates a new rule. Once created, this rule’s resource manifest is immutable.
Attributes
Pass either (topic_name, subscription_name, rule_name) as strings, or (rule) a rule object. When using (topic_name, subscription_name, rule_name, options) overload, you may also pass the properties for the rule.
Options
Accepted key/value pairs in options parameter are:
-
:filter
- String. The rule filter. -
:action
- String. The rule action.
180 181 182 183 184 185 186 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 180 def create_rule(*p) rule = _rule_from(*p) result = create_resource_entry(:rule, rule, rule.topic, rule.subscription, rule.name) result.topic = rule.topic result.subscription = rule.subscription result end |
#create_subscription(*p) ⇒ Object
Creates a new subscription. Once created, this subscription resource manifest is immutable.
Attributes
Pass either (topic_name, subscription_name) as strings, or (subscription) a object. When using (topic_name, subscription_name) overload, you may also pass optional properties for the subscription.
Options
Accepted key/value pairs in options parameter are:
-
:lock_duration
- XML datetime. Determines the amount of time in seconds in which a message should be locked for processing by a receiver. -
:requires_session
- Boolean. If set to true, the queue will be session-aware and only SessionReceiver will be supported. -
:default_message_time_to_live
- XML datetime. Determines how long a message lives in the associated subscriptions. -
:dead_lettering_on_message_expiration:
- Boolean. This field controls how the Service Bus handles a message whose TTL has expired. -
:dead_lettering_on_filter_evaluation_exceptions
- Boolean. Determines how the Service Bus handles a message that causes an exception during a subscription’s filter evaluation. -
:enable_batched_operations
- Boolean. Enables or disables service side batching behavior when performing operations for the specific queue. -
:max_delivery_count
- Number. A message is automatically deadlettered after this number of deliveries. -
:message_count
- Number. Displays the number of messages currently in the queue.
266 267 268 269 270 271 272 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 266 def create_subscription(*p) subscription = _subscription_from(*p) result = create_resource_entry(:subscription, subscription, subscription.topic, subscription.name) result.topic = subscription.topic result end |
#create_topic(topic, options = {}) ⇒ Object
Creates a new topic. Once created, this topic resource manifest is immutable.
Attributes
-
topic
- Azure::ServiceBus::Topic instance to create on server, or a string of the topic name -
options
- Hash. The topic properties.
Options
Accepted key/value pairs in options parameter are:
-
:default_message_time_to_tive
- XML datetime. Determines how long a message lives in the associated subscriptions. -
:maximum_number_of_subscriptions
- Number. Specifies the maximum number of subscriptions that can be associated with the topic. -
:max_size_in_megabytes
- Number. Specifies the maximum topic size in megabytes -
:requires_duplicate_detection
- Boolean. If enabled, the topic will detect duplicate messages within the time span specified by the DuplicateDetectionHistoryTimeWindow property -
:dead_lettering_on_filter_evaluation_exceptions
- Boolean. Determines how the Service Bus handles a message that causes an exception during a subscription’s filter evaluation. -
:duplicate_detection_history_time_window
- XML datetime. Specifies the time span during which the Service Bus will detect message duplication. -
:enable_batched_operations
- Boolean. Enables or disables service side batching behavior when performing operations for the specific queue.
124 125 126 127 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 124 def create_topic(topic, ={}) topic = _new_or_existing(Azure::ServiceBus::Topic, topic, ? : {}) create_resource_entry(:topic, topic, topic.name) end |
#delete_queue(queue) ⇒ Object
Deletes an existing queue. This operation will also remove all associated state including messages in the queue.
Attributes
-
queue
- Azure::ServiceBus::Queue instance to delete or a string of the queue name
74 75 76 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 74 def delete_queue(queue) delete_resource_entry(:queue, _name_for(queue)) end |
#delete_queue_message(message) ⇒ Object
Completes processing on a locked message and delete it from the queue. This operation should only be called after processing a previously locked message is successful to maintain At-Least-Once delivery assurances.
Attributes
-
message
- String. Either the message location URL or a message object.
495 496 497 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 495 def () () end |
#delete_rule(*p) ⇒ Object
Deletes an existing rule.
Attributes
Pass either (topic_name, subscription_name, rule_name) as strings, or (rule) a object with .name, .topic, and .subscription methods such as Azure::ServiceBus::Rule instance.
Note: The default rule name is ‘$Default’. Use this name to delete the default rule for the subscription.
196 197 198 199 200 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 196 def delete_rule(*p) topic_name, subscription_name, rule_name = _rule_args(*p) delete_resource_entry(:rule, topic_name, subscription_name, rule_name) end |
#delete_subscription(*p) ⇒ Object
Deletes an existing subscription.
Attributes
Pass either (topic_name, subscription_name) as strings, or (subscription) a object with .name and .topic methods such as Azure::ServiceBus::Subscription instance.
281 282 283 284 285 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 281 def delete_subscription(*p) topic_name, subscription_name = _subscription_args(*p) delete_resource_entry(:subscription, topic_name, subscription_name) end |
#delete_subscription_message(message) ⇒ Object
Completes processing on a locked message and delete it from the subscription. This operation should only be called after processing a previously locked message is successful to maintain At-Least-Once delivery assurances.
Attributes
-
message
- String. Either the message location URL or a message object.
412 413 414 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 412 def () () end |
#delete_topic(topic) ⇒ Object
Deletes an existing topic. This operation will also remove all associated state including associated subscriptions.
Attributes
-
topic
- Azure::ServiceBus::Topic instance to delete or a string of the topic name
135 136 137 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 135 def delete_topic(topic) delete_resource_entry(:topic, _name_for(topic)) end |
#get_queue(queue) ⇒ Object
Retrieves an existing queue.
Attributes
-
queue
- Azure::ServiceBus::Queue instance to retrieve or a string of the queue name
83 84 85 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 83 def get_queue(queue) resource_entry(:queue, _name_for(queue)) end |
#get_rule(*p) ⇒ Object
Retrieves the description for the specified rule.
Attributes
Pass either (topic_name, subscription_name, rule_name) as strings, or (rule) a object with .name, .topic, and .subscription methods such as Azure::ServiceBus::Rule instance.
Note: The default rule name is ‘$Default’. Use this name to retrieve the default rule for the subscription.
210 211 212 213 214 215 216 217 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 210 def get_rule(*p) topic_name, subscription_name, rule_name = _rule_args(*p) result = resource_entry(:rule, topic_name, subscription_name, rule_name) result.topic = topic_name result.subscription = subscription_name result end |
#get_subscription(*p) ⇒ Object
Gets an existing subscription.
Attributes
Pass either (topic_name, subscription_name) as strings, or (subscription) a object with .name and .topic methods such as Azure::ServiceBus::Subscription instance.
293 294 295 296 297 298 299 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 293 def get_subscription(*p) topic_name, subscription_name = _subscription_args(*p) result = resource_entry(:subscription, topic_name, subscription_name) result.topic = topic_name result end |
#get_topic(topic) ⇒ Object
Retrieves the description for the specified topic.
Attributes
-
topic
- Azure::ServiceBus::Topic instance to retrieve or a string of the topic name
144 145 146 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 144 def get_topic(topic) resource_entry(:topic, _name_for(topic)) end |
#list_queues(options = {}) ⇒ Object
Enumerates the queues in the service namespace.
Attributes
-
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:skip
- Integer. Number of queues to skip. -
:top
- Integer. Number of queues to list.
98 99 100 101 102 103 104 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 98 def list_queues(={}) query = {} query["$skip"] = [:skip].to_i.to_s if [:skip] query["$top"] = [:top].to_i.to_s if [:top] resource_list(:queue, query) end |
#list_rules(*p) ⇒ Object
Retrieves the rules that exist under the specified subscription.
Attributes
Pass either (topic_name, subscription_name) as strings, or (subscription) a object with .name and .topic methods such as Azure::ServiceBus::Subscription instance.
-
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:skip
- Integer. Number of topics to skip. -
:top
- Integer. Number of topics to list.
233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 233 def list_rules(*p) topic_name, subscription_name, = _subscription_args(*p) query = {} query["$skip"] = [:skip].to_i.to_s if [:skip] query["$top"] = [:top].to_i.to_s if [:top] results = resource_list(:rule, topic_name, subscription_name, query) results.each{|r| r.topic = topic_name; r.subscription=subscription_name} return results end |
#list_subscriptions(topic, options = {}) ⇒ Object
Retrieves the subscriptions in the specified topic.
Attributes
-
topic
- Either a Azure::ServiceBus::Topic instance or a string of the topic name -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:skip
- Integer. Number of subscriptions to skip. -
:top
- Integer. Number of subscriptions to list.
313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 313 def list_subscriptions(topic, ={}) topic = _name_for(topic) query = {} query["$skip"] = [:skip].to_i.to_s if [:skip] query["$top"] = [:top].to_i.to_s if [:top] results = resource_list(:subscription, topic, query) results.each { |s| s.topic = topic } return results end |
#list_topics(options = {}) ⇒ Object
Retrieves the topics in the service namespace.
Attributes
-
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:skip
- Integer. Number of topics to skip. -
:top
- Integer. Number of topics to list.
159 160 161 162 163 164 165 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 159 def list_topics(={}) query = {} query["$skip"] = [:skip].to_i.to_s if [:skip] query["$top"] = [:top].to_i.to_s if [:top] resource_list(:topic, query) end |
#peek_lock_queue_message(queue, options = {}) ⇒ Object
Automatically retrieves and locks a message from a queue for processing. The message is guaranteed not to be delivered to other receivers (on the same subscription only) during the lock duration period specified in the queue description. Once the lock expires, the message will be available to other receivers. In order to complete processing of the message, the receiver should issue a delete command with the lock ID received from this operation. To abandon processing of the message and unlock it for other receivers, an Unlock Message command should be issued, or the lock duration period can expire.
Attributes
-
queue
- String. Either a Azure::ServiceBus::Queue instance or a string of the queue name -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. Timeout for the REST call.
451 452 453 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 451 def (queue, ={}) (_name_for(queue), [:timeout] ? [:timeout] : DEFAULT_TIMEOUT) end |
#peek_lock_subscription_message(topic, subscription, options = {}) ⇒ Object
This operation is used to atomically retrieve and lock a message for processing. The message is guaranteed not to be delivered to other receivers during the lock duration period specified in buffer description. Once the lock expires, the message will be available to other receivers (on the same subscription only) during the lock duration period specified in the topic description. Once the lock expires, the message will be available to other receivers. In order to complete processing of the message, the receiver should issue a delete command with the lock ID received from this operation. To abandon processing of the message and unlock it for other receivers, an Unlock Message command should be issued, or the lock duration period can expire.
Attributes
-
topic
- String. The name of the topic or a Topic instance -
subscription
- String. The name of the subscription or a Subscription instance -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. Timeout for the REST call.
360 361 362 363 364 365 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 360 def (topic, subscription, ={}) topic = _name_for(topic) subscription = _name_for(subscription) (subscriptions_path(topic, subscription), [:timeout] ? [:timeout] : DEFAULT_TIMEOUT) end |
#read_delete_queue_message(queue, options = {}) ⇒ Object
Reads and deletes a message from a queue as an atomic operation. This operation should be used when a best-effort guarantee is sufficient for an application; that is, using this operation it is possible for messages to be lost if processing fails.
Attributes
-
queue
- Either a Azure::ServiceBus::Queue instance or a string of the queue name -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. Timeout for the REST call.
483 484 485 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 483 def (queue, ={}) (_name_for(queue), [:timeout] ? [:timeout] : DEFAULT_TIMEOUT) end |
#read_delete_subscription_message(topic, subscription, options = {}) ⇒ Object
Read and delete a message from a subscription as an atomic operation. This operation should be used when a best-effort guarantee is sufficient for an application; that is, using this operation it is possible for messages to be lost if processing fails.
Attributes
-
topic
- The name of the topic or a Topic instance -
subscription
- The name of the subscription or a Subscription instance -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:timeout
- Integer. Timeout for the REST call.
397 398 399 400 401 402 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 397 def (topic, subscription, ={}) topic = _name_for(topic) subscription = _name_for(subscription) (subscriptions_path(topic, subscription), [:timeout] ? [:timeout] : DEFAULT_TIMEOUT) end |
#receive_queue_message(queue, options = {}) ⇒ Object
Public: Receives a queue message.
Attributes
-
queue
- String. The queue name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:peek_lock
- Boolean. Lock when peeking. -
:timeout
- Integer. Timeout for the REST call.
512 513 514 515 516 517 518 519 520 521 522 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 512 def (queue, ={}) peek_lock = true peek_lock = [:peek_lock] if [:peek_lock] [:timeout] = [:timeout] ? [:timeout] : DEFAULT_TIMEOUT if peek_lock (queue, ) else (queue, ) end end |
#receive_subscription_message(topic, subscription, options = {}) ⇒ Object
Public: Receives a subscription message.
Attributes
-
topic
- String. The topic name. -
options
- Hash. Optional parameters.
Options
Accepted key/value pairs in options parameter are:
-
:peek_lock
- Boolean. Lock when peeking. -
:timeout
- Integer. Timeout for the REST call.
537 538 539 540 541 542 543 544 545 546 547 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 537 def (topic, subscription, ={}) peek_lock = true peek_lock = [:peek_lock] if [:peek_lock] [:timeout] = [:timeout] ? [:timeout] : DEFAULT_TIMEOUT if peek_lock (topic, subscription, ) else (topic, subscription, ) end end |
#send_queue_message(queue, message) ⇒ Object
Sends a message into the specified queue. The limit to the number of messages which may be present in the topic is governed by the message size the MaxTopicSizeInMegaBytes. If this message will cause the queue to exceed its quota, a quota exceeded error is returned and the message will be rejected.
Attributes
-
queue
- Either a Azure::ServiceBus::Queue instance or a string of the queue name -
message
- An Azure::ServiceBus::BrokeredMessage object containing message body and properties, or a string of the message body (a default BrokeredMessage will be created from the string).
426 427 428 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 426 def (queue, ) (_name_for(queue), ) end |
#send_topic_message(topic, message) ⇒ Object
Enqueues a message into the specified topic. The limit to the number of messages which may be present in the topic is governed by the message size in MaxTopicSizeInBytes. If this message causes the topic to exceed its quota, a quota exceeded error is returned and the message will be rejected.
Attributes
-
topic
- Either a Azure::ServiceBus::Topic instance or a string of the topic name -
message
- An Azure::ServiceBus::BrokeredMessage object containing message body and properties, or a string of the message body (a default BrokeredMessage will be created from the string).
335 336 337 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 335 def (topic, ) (_name_for(topic), ) end |
#unlock_queue_message(message) ⇒ Object
Unlocks a message for processing by other receivers on a given subscription. This operation deletes the lock object, causing the message to be unlocked. A message must have first been locked by a receiver before this operation is called.
Attributes
-
message
- String. Either the message location URL or a message object.
464 465 466 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 464 def () () end |
#unlock_subscription_message(message) ⇒ Object
Unlock a message for processing by other receivers on a given subscription. This operation deletes the lock object, causing the message to be unlocked. A message must have first been locked by a receiver before this operation is called.
Attributes
-
message
- String. Either the message location URL or a message object.
377 378 379 |
# File 'lib/azure/service_bus/service_bus_service.rb', line 377 def () () end |