Class Qpid::Messaging::Sender
In: lib/qpid/sender.rb
Parent: Object

Sender is the entity through which messages sent.

An instance of Sender can only be created using an active (not previously closed) Session.

Examples

  conn    = Qpid::Messaging::Connection.new :url => "mybroker:5762"
  conn.open
  session = conn.create_session
  sender  = session.create_session "my-sender-queue;{create:always}"

Methods

available   capacity   capacity=   close   name   send   session   unsettled  

Public Instance methods

Returns the available slots for sending messages.

This differs from capacity in that it is the available slots in the senders capacity for holding outgoing messages. The difference between capacity and available is the number of messages that have not been delivered yet.

Examples

  puts "You can send #{sender.available} messages before blocking."

Returns the capacity.

The capacity is the total number of outgoing messages that can be sent before a called to send begins to block by default.

Examples

  puts "You can send a maximum of #{sender.capacity} messages."

Sets the capacity for this Sender.

The capacity is the number of outgoing messages that can be held pending confirmation or receipt by the broker.

Options

Examples

  sender.capacity = 50 # sets the outgoing capacity to 50 messages

Closes this Sender.

This does not affect the Session.

Returns the human-readable name for this Sender.

Examples

  puts "Sender: #{sender.name}"

Sends a message.

If a block is given, then it will be invoked after the message is sent.

Options

  • message - The message to send.
  • :sync - See note below on synching.

Synching

If :sync => true, then the call will block until the broker confirms receipt of the message. Otherwise it will only block for available capacity; i.e., until pending is equal to capacity.

Examples

  sender.send message do |message|
    puts "Message sent: #{message.content}"
  end

Returns the Session for this sender.

Examples

  recv.session.close if done

Returns the number of messages sent that are pending receipt confirmation by the broker.

Examples

  if sender.unsettled > 0
    puts "There are #{sender.unsettled} messages pending."
  end

[Validate]