Class: Qpid::Messaging::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/qpid_messaging/address.rb

Overview

Address represents an address to which messages can be sent or from which they can be received.

An Address can be described using the following pattern:

<address> [ / <subject> ] ; [ { <key> : <value> , … } ]

where address is a simple name and subject is a subject or subject pattern.

The options, enclosed in curly braces, are key:value pairs delimited by a comma. The values can be nested maps also enclosed in curly braces. Or they can be lists of values, where they are contained within square brackets but still comma delimited, such as:

[value1,value2,value3]

The following are the list of supported options:

:create

Indicates if the address should be created; values are always, never, sender or reciever.

:assert

Indicates whether or not to assert any specified node properties; values are always, never, sender or receiver.

:delete

Indicates whether or not to delete the addressed node when a sender or receiver is cancelled; values are always, never, sender or receiver.

:node

A nested map describing properties for the addressed node. Properties are type (topic or queue), durable (a boolean), x-declare (a nested map of amqp 0.10-specific options) and x-bindings. (nested list which specifies a queue, exchange or a binding key and arguments.

:link

A nested map through which properties of the link can be specified; properties are durable, reliability, x-declare, x-subscribe and x-bindings.

:mode

(*For receivers only*) indicates whether the receiver should consume or browse messages; values are consume (the default) and browse.

Instance Method Summary collapse

Constructor Details

#initialize(name, subject, options = {}, _type = "", address_impl = nil) ⇒ Address

Creates a new Address object.

Options

  • name - The name for the Address.

  • subject - The subject for the Address

  • :create - See the class documentation.

  • :assert - See the class documentation.

  • :delete - See the class documentation.

  • :node - See the class documentation.

  • :link - See the class documentation.

  • :mode - See the class documentation.

Examples

addr = Qpid::Messaging::Address.new "my-queue"
addr = Qpid::Messaging::Address.new "my-queue", "testing", :create => :always


91
92
93
# File 'lib/qpid_messaging/address.rb', line 91

def initialize(name, subject, options = {}, _type = "", address_impl = nil)
  @address_impl = address_impl || Cqpid::Address.new(name, subject, convert_options(options), _type)
end

Instance Method Details

#address_implObject

:nodoc:



95
96
97
# File 'lib/qpid_messaging/address.rb', line 95

def address_impl # :nodoc:
  @address_impl
end

#address_typeObject

Returns the type for the Address.

Examples

puts "The address is a #{address.address_type}."

We cannot use “type” since that clashes with the Ruby object.type identifier.



140
# File 'lib/qpid_messaging/address.rb', line 140

def address_type; @address_impl.getType; end

#address_type=(type) ⇒ Object

Sets the type for the Address.

The type of the address determines how Sender and Receiver objects are constructed for it. If no type is specified then it will be determined by querying the broker.

Options
  • type - the address type



152
# File 'lib/qpid_messaging/address.rb', line 152

def address_type=(type); @address_impl.setType(type); end

#nameObject

Returns the name for the Address.

Examples

puts "The address name is #{addr.name}."


105
# File 'lib/qpid_messaging/address.rb', line 105

def name; @address_impl.getName; end

#name=(name) ⇒ Object

Sets the name for the Address.

Examples

addr.name = "my-new-queue"


113
# File 'lib/qpid_messaging/address.rb', line 113

def name=(name); @address_impl.setName name; end

#optionsObject

Returns the options.



155
# File 'lib/qpid_messaging/address.rb', line 155

def options; @address_impl.getOptions; end

#options=(options = {}) ⇒ Object

Sets the options for the address.

NOTE: See the class documentation for more details on options.

Examples

addr.options = :create => :always


165
# File 'lib/qpid_messaging/address.rb', line 165

def options=(options = {}); @address_impl.setOptions(convert_options(options)); end

#subjectObject

Returns the subject for the Address.

Examples

puts "The subject is #{addr.subject}."


121
# File 'lib/qpid_messaging/address.rb', line 121

def subject; @address_impl.getSubject; end

#subject=(subject) ⇒ Object

Sets the subject for the Address.

Examples

addr.subject = "testing"


129
# File 'lib/qpid_messaging/address.rb', line 129

def subject=(subject); @address_impl.setSubject(subject); end

#to_sObject

:nodoc:



167
168
169
# File 'lib/qpid_messaging/address.rb', line 167

def to_s # :nodoc:
  @address_impl.str
end