Class: Azure::ServiceBus::Queue

Inherits:
Resource
  • Object
show all
Defined in:
lib/azure/service_bus/queue.rb

Instance Attribute Summary

Attributes inherited from Resource

#author_name, #description, #id, #name, #published, #updated

Instance Method Summary collapse

Methods inherited from Resource

#get_props

Constructor Details

#initialize(name, options = {}) ⇒ Queue

Public: Initialize the queue.

Attributes

  • name - A String with the name of the queue.

  • options - The resource options Hash

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.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/azure/service_bus/queue.rb', line 42

def initialize(name, options = {})
  normalized_options = {}
  normalized_options["DefaultMessageTimeToLive"] = options[:default_message_time_to_live].to_s if options.has_key?(:default_message_time_to_live)
  normalized_options["DuplicateDetectionHistoryTimeWindow"] = options[:duplicate_detection_history_time_window].to_s if options.has_key?(:duplicate_detection_history_time_window)
  normalized_options["EnableBatchedOperations"] = options[:enable_batched_operations].to_s if options.has_key?(:enable_batched_operations)
  normalized_options["DeadLetteringOnMessageExpiration"] = options[:dead_lettering_on_message_expiration].to_s if options.has_key?(:dead_lettering_on_message_expiration)
  normalized_options["LockDuration"] = options[:lock_duration].to_s if options.has_key?(:lock_duration)
  normalized_options["MaxDeliveryCount"] = options[:max_delivery_count].to_s if options.has_key?(:max_delivery_count)
  normalized_options["MaxSizeInMegabytes"] = options[:max_size_in_megabytes].to_s if options.has_key?(:max_size_in_megabytes)
  normalized_options["MessageCount"] = options[:message_count].to_s if options.has_key?(:message_count)
  normalized_options["RequiresDuplicateDetection"] = options[:requires_duplicate_detection].to_s if options.has_key?(:requires_duplicate_detection)
  normalized_options["RequiresSession"] = options[:requires_session].to_s if options.has_key?(:requires_session)
  normalized_options["SizeInBytes"] = options[:size_in_bytes].to_s if options.has_key?(:size_in_bytes)

  super(name, normalized_options)
end

Instance Method Details

#dead_lettering_on_message_expirationObject

DeadLetteringOnMessageExpiration: True, False

This field controls how the Service Bus handles a message whose TTL has expired. If it is enabled and a message expires, the Service Bus moves the message from the queue into the queue’s dead-letter sub-queue. If disabled, message will be permanently deleted from the queue. Settable only at queue creation time.

Default: false



107
108
109
# File 'lib/azure/service_bus/queue.rb', line 107

def dead_lettering_on_message_expiration
  to_bool description['DeadLetteringOnMessageExpiration']
end

#default_message_time_to_liveObject

DefaultMessageTimeToLive: XML datetime

Depending on whether DeadLettering is enabled, a message is automatically moved to the DeadLetterQueue or deleted if it has been stored in the queue for longer than the specified time. This value is overwritten by a TTL specified on the message if and only if the message TTL is smaller than the TTL set on the queue. This value is immutable after the Queue has been created:

Range: 1 second - TimeSpan.MaxValue Default: TimeSpan.MaxValue



164
165
166
# File 'lib/azure/service_bus/queue.rb', line 164

def default_message_time_to_live
  to_interval description['DefaultMessageTimeToLive']
end

#default_message_time_to_live=(val) ⇒ Object



168
169
170
# File 'lib/azure/service_bus/queue.rb', line 168

def default_message_time_to_live=(val)
  _set 'DefaultMessageTimeToLive', val
end

#duplicate_detection_history_time_windowObject

DuplicateDetectionHistoryTimeWindow

Specifies the time span during which the Service Bus will detect message duplication.

Range: 1 second - 7 days Default: 10 minutes



191
192
193
# File 'lib/azure/service_bus/queue.rb', line 191

def duplicate_detection_history_time_window
  to_interval description['DuplicateDetectionHistoryTimeWindow']
end

#duplicate_detection_history_time_window=(val) ⇒ Object



195
196
197
# File 'lib/azure/service_bus/queue.rb', line 195

def duplicate_detection_history_time_window=(val)
  _set 'DuplicateDetectionHistoryTimeWindow', val
end

#enable_batched_operationsObject

EnableBatchedOperations

Enables or disables service side batching behavior when performing operations for the specific queue. When enabled, service bus will collect/batch multiple operations to the backend to be more connection efficient.

If user wants lower operation latency then they can disable this feature.



205
206
207
# File 'lib/azure/service_bus/queue.rb', line 205

def enable_batched_operations
  to_bool description['EnableBatchedOperations']
end

#enable_batched_operations=(val) ⇒ Object



209
210
211
# File 'lib/azure/service_bus/queue.rb', line 209

def enable_batched_operations=(val)
  _set 'EnableBatchedOperations', val
end

#enable_dead_lettering_on_message_expiration=(val) ⇒ Object



111
112
113
# File 'lib/azure/service_bus/queue.rb', line 111

def enable_dead_lettering_on_message_expiration=(val)
  _set 'DeadLetteringOnMessageExpiration', val
end

#lock_durationObject

LockDuration: XML datetime

Determines the amount of time in seconds in which a message should be locked for processing by a receiver. After this period, the message is unlocked and available for consumption by the next receiver. Settable only at queue creation time:

Range: 0 - 5 minutes. 0 means that the message is not locked Default: 30 seconds



78
79
80
# File 'lib/azure/service_bus/queue.rb', line 78

def lock_duration
  to_interval description['LockDuration']
end

#lock_duration=(val) ⇒ Object



82
83
84
# File 'lib/azure/service_bus/queue.rb', line 82

def lock_duration=(val)
  _set 'LockDuration', val
end

#max_delivery_countObject

MaxDeliveryCount: Number

A message is automatically deadlettered after this number of deliveries.



118
119
120
# File 'lib/azure/service_bus/queue.rb', line 118

def max_delivery_count
  to_i description['MaxDeliveryCount']
end

#max_delivery_count=(val) ⇒ Object



122
123
124
# File 'lib/azure/service_bus/queue.rb', line 122

def max_delivery_count=(val)
  _set 'MaxDeliveryCount', val
end

#max_size_in_megabytesObject

MaxSizeInMegaBytes: Number

Specifies the maximum queue size in megabytes. Any attempt to enqueue a message that will cause the queue to exceed this value will fail. You can only set this parameter at queue creation time using the following values:

Range: 1 - 1024 (valid values are 1024, 2048, 3072, 4096, 5120) Default: 1*1024 (valid values are 1024, 2048, 3072, 4096, 5120)



133
134
135
# File 'lib/azure/service_bus/queue.rb', line 133

def max_size_in_megabytes
  to_i description['MaxSizeInMegabytes']
end

#max_size_in_megabytes=(val) ⇒ Object



137
138
139
# File 'lib/azure/service_bus/queue.rb', line 137

def max_size_in_megabytes=(val)
  _set 'MaxSizeInMegabytes', val
end

#message_countObject

MessageCount: Number

Displays the number of messages currently in the queue.



62
63
64
# File 'lib/azure/service_bus/queue.rb', line 62

def message_count
  to_i description['MessageCount']
end

#message_count=(val) ⇒ Object



66
67
68
# File 'lib/azure/service_bus/queue.rb', line 66

def message_count=(val)
  _set 'MessageCount', val
end

#ordered_propsObject



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/azure/service_bus/queue.rb', line 213

def ordered_props
  [
    'LockDuration',
    'MaxSizeInMegabytes',
    'RequiresDuplicateDetection',
    'RequiresSession',
    'DefaultMessageTimeToLive',
    'DeadLetteringOnMessageExpiration',
    'DuplicateDetectionHistoryTimeWindow',
    'MaxDeliveryCount',
    'EnableBatchedOperations',
    'SizeInBytes',
    'MessageCount'
  ]
end

#requires_duplicate_detectionObject

RequiresDuplicateDetection: True, False

Settable only at queue creation time.

Default for durable queue: false



177
178
179
# File 'lib/azure/service_bus/queue.rb', line 177

def requires_duplicate_detection
  to_bool description['RequiresDuplicateDetection']
end

#requires_duplicate_detection=(val) ⇒ Object



181
182
183
# File 'lib/azure/service_bus/queue.rb', line 181

def requires_duplicate_detection=(val)
  _set 'RequiresDuplicateDetection', val
end

#requires_sessionObject

RequiresSession: True, False

Settable only at queue creation time. If set to true, the queue will be session-aware and only SessionReceiver will be supported. Session-aware queues are not supported through REST.

Default for durable queue: false



92
93
94
# File 'lib/azure/service_bus/queue.rb', line 92

def requires_session
  to_bool description['RequiresSession']
end

#requires_session=(val) ⇒ Object



96
97
98
# File 'lib/azure/service_bus/queue.rb', line 96

def requires_session=(val)
  _set 'RequiresSession', val
end

#size_in_bytesObject

SizeinBytes: Number

Reflects the actual bytes that messages in the queue currently occupy toward the queue’s quota.

Range: 0 - MaxTopicSizeinMegaBytes



146
147
148
# File 'lib/azure/service_bus/queue.rb', line 146

def size_in_bytes
  to_i description['SizeInBytes']
end

#size_in_bytes=(val) ⇒ Object



150
151
152
# File 'lib/azure/service_bus/queue.rb', line 150

def size_in_bytes=(val)
  _set 'SizeInBytes', val
end