class Qpid::Messaging::Sender

Sender is the entity through which messages sent.

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


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

Public Instance Methods

available() click to toggle source

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.


puts "You can send #{sender.available} messages before blocking."
# File qpid/ruby/lib/qpid_messaging/sender.rb, line 135
def available
capacity() click to toggle source

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.


puts "You can send a maximum of #{sender.capacity} messages."
# File qpid/ruby/lib/qpid_messaging/sender.rb, line 111
def capacity; @sender_impl.getCapacity; end
capacity=(capacity) click to toggle source

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.


  • capacity - the capacity


sender.capacity = 50 # sets the outgoing capacity to 50 messages
# File qpid/ruby/lib/qpid_messaging/sender.rb, line 100
def capacity=(capacity); @sender_impl.setCapacity capacity; end
close() click to toggle source

Closes this Sender.

This does not affect the Session.

# File qpid/ruby/lib/qpid_messaging/sender.rb, line 77
def close; @sender_impl.close; end
name() click to toggle source

Returns the human-readable name for this Sender.


puts "Sender: #{}"
# File qpid/ruby/lib/qpid_messaging/sender.rb, line 85
def name; @sender_impl.getName; end
send(message, args = {}, &block) click to toggle source

Sends a message.

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


  • message - The message to send.

  • :sync - See note below on 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.


sender.send message do |message|
  puts "Message sent: #{message.content}"
# File qpid/ruby/lib/qpid_messaging/sender.rb, line 68
def send(message, args = {}, &block)
  sync = args[:sync] || false
  @sender_impl.send message.message_impl, sync message unless block.nil?
session() click to toggle source

Returns the Session for this sender.


recv.session.close if done
# File qpid/ruby/lib/qpid_messaging/sender.rb, line 145
def session; @session; end
unsettled() click to toggle source

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


if sender.unsettled > 0
  puts "There are #{sender.unsettled} messages pending."
# File qpid/ruby/lib/qpid_messaging/sender.rb, line 122
def unsettled; @sender_impl.getUnsettled; end