Method: Azure::Queue::QueueService#create_message

Defined in:
lib/azure/queue/queue_service.rb

#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 server time. 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 maximum time-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.

See msdn.microsoft.com/en-us/library/windowsazure/dd179346

Returns nil on success



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/azure/queue/queue_service.rb', line 304

def create_message(queue_name, message_text, options={})
  query = { }

  unless options.empty?
    query["visibilitytimeout"] = options[:visibility_timeout] if options[:visibility_timeout]
    query["messagettl"] = options[:message_ttl] if options[:message_ttl]
    query["timeout"] = options[:timeout].to_s if options[:timeout]
  end

  uri = messages_uri(queue_name, query)
  body = Serialization.message_to_xml(message_text, options[:encode])

  call(:post, uri, body, {})
  nil
end