class Qpid::Messaging::Address

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

The Address String

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.

Options

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.

Public Class Methods

new(address, address_impl = nil) click to toggle source

Creates a new Address from an address string.

Attributes

  • address - the address string

Examples

# create a new address for a queue named "my-queue" that will
# be created if it doesn't already exist
addr = Qpid::Messaging::Address.new "my-queue;{create:always}"
# File qpid/ruby/lib/qpid_messaging/address.rb, line 88
def initialize(address, address_impl = nil)
  @address_impl = address_impl || Cqpid::Address.new(address)
end

Public Instance Methods

address_type() click to toggle source

Returns the type for the Address.

# File qpid/ruby/lib/qpid_messaging/address.rb, line 143
def address_type; @address_impl.getType; end
address_type=(type) click to toggle source

Sets the type for the Address.

The type of the address determines how Sender and Receiver objects are constructed for it. It also affects how a reply-to address is encoded.

If no type is specified then it will be determined by querying the broker. Explicitly setting the type prevents this.

Values are either queue or topic.

Options

  • type - the address type

Examples

# creates an queue address
addr = Qpid::Messaging::Address.new "my-queue;{create:always}"
addr.address_type = "queue"
# File qpid/ruby/lib/qpid_messaging/address.rb, line 166
def address_type=(type); @address_impl.setType(type); end
name() click to toggle source

Returns the name for the Address.

Examples

# display the name of the address
addr = Qpid::Messaging::Address.new "foo;{create:always}"
# outputs the word 'foo'
puts addr.name
# File qpid/ruby/lib/qpid_messaging/address.rb, line 105
def name; @address_impl.getName; end
name=(name) click to toggle source

Sets the name for the Address.

Examples

# create a new address with the name "my-queue"
addr = Qpid::Messaging::Address.new "my-queue/my-subject;{create:always}"
# changes the name to "my-new-queue"
addr.name = "my-new-queue"
# File qpid/ruby/lib/qpid_messaging/address.rb, line 116
def name=(name); @address_impl.setName name; end
options() click to toggle source

Returns the options.

# File qpid/ruby/lib/qpid_messaging/address.rb, line 169
def options; @address_impl.getOptions; end
options=(options = {}) click to toggle source

Sets the options for the address.

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

Examples

addr.options = :create => :always
addr.options = :create => :always, :delete => :always
# File qpid/ruby/lib/qpid_messaging/address.rb, line 180
def options=(options = {}); @address_impl.setOptions(convert_options(options)); end
subject() click to toggle source

Returns the subject for the Address.

Examples

# creates a new address with the subject "bar"
addr = Qpid::Messaging::Address.new "my-queue/bar;{create:always}"
# File qpid/ruby/lib/qpid_messaging/address.rb, line 125
def subject; @address_impl.getSubject; end
subject=(subject) click to toggle source

Sets the subject for the Address.

Examples

# creates an address with the subject "example"
addr = Qpid::Messaging::Address.new "my-queue/example;{create:always}"
# changes the subject to "test"
addr.subject = "test"
# File qpid/ruby/lib/qpid_messaging/address.rb, line 136
def subject=(subject); @address_impl.setSubject(subject); end