Class | Qpid::Messaging::Sender |
In: |
lib/qpid_messaging/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.
conn = Qpid::Messaging::Connection.new :url => "mybroker:5762" conn.open session = conn.create_session sender = session.create_session "my-sender-queue;{create:always}"
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."
Sends a message.
If a block is given, then it will be invoked after the message is sent.
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}" end