Class: Azure::ServiceBus::Topic

Inherits:
Resource
  • Object
show all
Defined in:
lib/azure/service_bus/topic.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 = {}) ⇒ Topic

Public: Initialize the topic.

Attributes

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

  • options - The resource options Hash

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.



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/azure/service_bus/topic.rb', line 38

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["MaximumNumberOfSubscriptions"] = options[:maximum_number_of_subscriptions].to_s if options.has_key?(:maximum_number_of_subscriptions)
  normalized_options["MaxSizeInMegabytes"] = options[:max_size_in_megabytes].to_s if options.has_key?(:max_size_in_megabytes)
  normalized_options["RequiresDuplicateDetection"] = options[:requires_duplicate_detection].to_s if options.has_key?(:requires_duplicate_detection)
  normalized_options["DeadLetteringOnFilterEvaluationExceptions"] = options[:dead_lettering_on_filter_evaluation_exceptions].to_s if options.has_key?(:dead_lettering_on_filter_evaluation_exceptions)
  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)

  super(name, normalized_options)
end

Instance Method Details

#dead_lettering_on_filter_evaluation_exceptionsObject

DeadLetteringOnFilterEvaluationExceptions: True, False

Determines how the Service Bus handles a message that causes an exception during a subscription’s filter evaluation. If the value is set to true, the message that caused the exception will be moved to the subscription’s dead-letter queue. Otherwise, it will be discarded. By default this parameter is set to true, allowing the user a chance to investigate the cause of the exception. It can occur from a malformed message or some incorrect assumptions being made in the filter about the form of the message. Settable only at topic creation time.

Default: true



165
166
167
# File 'lib/azure/service_bus/topic.rb', line 165

def dead_lettering_on_filter_evaluation_exceptions
  to_bool description['DeadLetteringOnFilterEvaluationExceptions']
end

#dead_lettering_on_filter_evaluation_exceptions=(val) ⇒ Object



169
170
171
# File 'lib/azure/service_bus/topic.rb', line 169

def dead_lettering_on_filter_evaluation_exceptions=(val)
  _set 'DeadLetteringOnFilterEvaluationExceptions', val
end

#default_message_time_to_liveObject

DefaultMessageTimeToLive: XML datetime

Determines how long a message lives in the associated subscriptions. Subscriptions inherit the TTL from the topic unless they are created explicitly with a smaller TTL. Based on whether dead-lettering is enabled, a message whose TTL has expired will either be moved to the subscription’s associated DeadLtterQueue or will be permanently deleted. The following values are settable at topic creation time:

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


91
92
93
# File 'lib/azure/service_bus/topic.rb', line 91

def default_message_time_to_live
  to_interval description['DefaultMessageTimeToLive']
end

#default_message_time_to_live=(val) ⇒ Object



95
96
97
# File 'lib/azure/service_bus/topic.rb', line 95

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



119
120
121
# File 'lib/azure/service_bus/topic.rb', line 119

def duplicate_detection_history_time_window
  to_interval description['DuplicateDetectionHistoryTimeWindow']
end

#duplicate_detection_history_time_window=(val) ⇒ Object



123
124
125
# File 'lib/azure/service_bus/topic.rb', line 123

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.



147
148
149
# File 'lib/azure/service_bus/topic.rb', line 147

def enable_batched_operations
  to_bool description['EnableBatchedOperations']
end

#enable_batched_operations=(val) ⇒ Object



151
152
153
# File 'lib/azure/service_bus/topic.rb', line 151

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

#max_size_in_megabytesObject

MaxSizeInMegabytes: Number

Specifies the maximum topic size in megabytes. Any attempt to enqueue a message that will cause the topic to exceed this value will fail. All messages that are stored in the topic or any of its subscriptions count towards this value. Multiple copies of a message that reside in one or multiple subscriptions count as a single messages. For example, if message m exists once in subscription s1 and twice in subscription s2, m is counted as a single message. You can only set this parameter at topic creation time using the following values:

Range: 1 - 5*1024 MB
Default: 1*1024


61
62
63
# File 'lib/azure/service_bus/topic.rb', line 61

def max_size_in_megabytes
  to_i description['MaxSizeInMegabytes']
end

#max_size_in_megabytes=(val) ⇒ Object



65
66
67
# File 'lib/azure/service_bus/topic.rb', line 65

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

#maximum_number_of_subscriptionsObject

MaximumNumberOfSubscriptions

Specifies the maximum number of subscriptions that can be associated with the topic.

Range: 1 - 2000 Default: 2000 subscriptions



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

def maximum_number_of_subscriptions
  to_i description['MaximumNumberOfSubscriptions']
end

#maximum_number_of_subscriptions=(val) ⇒ Object



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

def maximum_number_of_subscriptions=(val)
  _set 'MaximumNumberOfSubscriptions', val
end

#ordered_propsObject



173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/azure/service_bus/topic.rb', line 173

def ordered_props
  [
    'DefaultMessageTimeToLive',
    'MaximumNumberOfSubscriptions',
    'MaxSizeInMegabytes',
    'RequiresDuplicateDetection',
    'DeadLetteringOnFilterEvaluationExceptions',
    'DuplicateDetectionHistoryTimeWindow',
    'EnableBatchedOperations',
    'SizeInBytes'
  ]
end

#requires_duplicate_detectionObject

RequiresDuplicateDetection: True, False

If enabled, the topic will detect duplicate messages within the time span specified by the DuplicateDetectionHistoryTimeWindow property. Settable only at topic creation time.

Default: false



105
106
107
# File 'lib/azure/service_bus/topic.rb', line 105

def requires_duplicate_detection
  to_bool description['RequiresDuplicateDetection']
end

#requires_duplicate_detection=(val) ⇒ Object



109
110
111
# File 'lib/azure/service_bus/topic.rb', line 109

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

#size_in_bytesObject

SizeInBytes: Number

Reflects the actual bytes toward the topic quota that messages in the topic currently occupy. (read-only)

Range: 0 - MaxTopicSizeinMegaBytes



74
75
76
# File 'lib/azure/service_bus/topic.rb', line 74

def size_in_bytes
  to_i description['SizeInBytes']
end

#size_in_bytes=(val) ⇒ Object



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

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