Class: Azure::ServiceBus::Subscription

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

Instance Attribute Summary collapse

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 = {}) ⇒ Subscription

Public: Initialize the subscription.

Attributes

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

  • options - The resource options Hash

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.



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

def initialize(name, options = {})
  normalized_options = {}
  normalized_options["LockDuration"] = options[:lock_duration].to_s if options.has_key?(:lock_duration)
  normalized_options["RequiresSession"] = options[:requires_session].to_s if options.has_key?(:requires_session)
  normalized_options["DefaultMessageTimeToLive"] = options[:default_message_time_to_live].to_s if options.has_key?(:default_message_time_to_live)
  normalized_options["DeadLetteringOnMessageExpiration"] = options[:dead_lettering_on_message_expiration].to_s if options.has_key?(:dead_lettering_on_message_expiration)
  normalized_options["DeadLetteringOnFilterEvaluationExceptions"] = options[:dead_lettering_on_filter_evaluation_exceptions].to_s if options.has_key?(:dead_lettering_on_filter_evaluation_exceptions)
  normalized_options["EnableBatchedOperations"] = options[:enable_batched_operations].to_s if options.has_key?(:enable_batched_operations)
  normalized_options["MaxDeliveryCount"] = options[:max_delivery_count].to_s if options.has_key?(:max_delivery_count)
  normalized_options["MessageCount"] = options[:message_count].to_s if options.has_key?(:message_count)

  super(name, normalized_options)
end

Instance Attribute Details

#topicObject

Returns the value of attribute topic.



21
22
23
# File 'lib/azure/service_bus/subscription.rb', line 21

def topic
  @topic
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



127
128
129
# File 'lib/azure/service_bus/subscription.rb', line 127

def dead_lettering_on_filter_evaluation_exceptions
  to_bool description['DeadLetteringOnFilterEvaluationExceptions']
end

#dead_lettering_on_filter_evaluation_exceptions=(val) ⇒ Object



131
132
133
# File 'lib/azure/service_bus/subscription.rb', line 131

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

#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 subscription’s dead-letter sub-queue. If disabled, message will be permanently deleted from the subscription’s main queue. Settable only at subscription creation time.

Default: false



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

def dead_lettering_on_message_expiration
  to_bool description['DeadLetteringOnMessageExpiration']
end

#dead_lettering_on_message_expiration=(val) ⇒ Object



113
114
115
# File 'lib/azure/service_bus/subscription.rb', line 113

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

#default_message_time_to_liveObject

DefaultMessageTimeToLive: PTnHnMnS

Determines how long a message lives in the subscription. Based on whether dead-lettering is enabled, a message whose TTL has expired will either be moved to the subscription’s associated DeadLtterQueue or permanently deleted.

Range: 1 second - TimeSpan.MaxValue Default: TimeSpan.MaxValue if the topic also does not specify a TTL. Otherwise the setting from topic is inherited.



93
94
95
# File 'lib/azure/service_bus/subscription.rb', line 93

def default_message_time_to_live
  to_interval description['DefaultMessageTimeToLive']
end

#default_message_time_to_live=(val) ⇒ Object



97
98
99
# File 'lib/azure/service_bus/subscription.rb', line 97

def default_message_time_to_live=(val)
  _set 'DefaultMessageTimeToLive', 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.



140
141
142
# File 'lib/azure/service_bus/subscription.rb', line 140

def enable_batched_operations
  to_bool description['EnableBatchedOperations']
end

#enable_batched_operations=(val) ⇒ Object



144
145
146
# File 'lib/azure/service_bus/subscription.rb', line 144

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

#lock_durationObject

LockDuration: XML datetime

The default lock duration is applied to subscriptions that do not define a lock duration. Settable only at subscription creation time:

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



63
64
65
# File 'lib/azure/service_bus/subscription.rb', line 63

def lock_duration
  to_interval description['LockDuration']
end

#lock_duration=(val) ⇒ Object



67
68
69
# File 'lib/azure/service_bus/subscription.rb', line 67

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

#max_delivery_countObject

MaxDeliveryCount

The maximum number of times a message SB will try to deliver before being dead lettered or discarded.



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

def max_delivery_count
  to_i description['MaxDeliveryCount']
end

#max_delivery_count=(val) ⇒ Object



155
156
157
# File 'lib/azure/service_bus/subscription.rb', line 155

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

#message_countObject

MessageCount

Reports the number of messages in the queue as reported by the monitoring system.



162
163
164
# File 'lib/azure/service_bus/subscription.rb', line 162

def message_count
  to_i description['MessageCount']
end

#message_count=(val) ⇒ Object



166
167
168
# File 'lib/azure/service_bus/subscription.rb', line 166

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

#ordered_propsObject



170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/azure/service_bus/subscription.rb', line 170

def ordered_props
  [
    "LockDuration",
    "RequiresSession",
    "DefaultMessageTimeToLive",
    "DeadLetteringOnMessageExpiration",
    "DeadLetteringOnFilterEvaluationExceptions",
    "MessageCount",
    "MaxDeliveryCount",
    "EnableBatchedOperations"
  ]
end

#requires_sessionObject

RequiresSession: True, False

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

Default: false



77
78
79
# File 'lib/azure/service_bus/subscription.rb', line 77

def requires_session
  to_bool description['RequiresSession']
end

#requires_session=(val) ⇒ Object



81
82
83
# File 'lib/azure/service_bus/subscription.rb', line 81

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