| Class | Qpid::Messaging::Receiver |
| In: |
lib/qpid/receiver.rb
|
| Parent: | Object |
Receiver is the entity through which messages are received.
An instance of Receiver 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 receiver = session.create_receiver "my-sender-queue"
Retrieves a message from the receiver‘s subscription, or waits for up to the duration specified for one to become available.
If a block is given, then it will be invaked after the next message is received or the call times out, passing in the message or nil respectively.
msg = rcvr.fetch # Uses the default timeout of forever
msg = rcvr.fetch Qpid::Messaging::Duration::IMMEDIATE # returns a message or exits immediately
# passes in a block to handle the received message
rcvr.fetch Qpid::Messaging::Duration::SECOND do |message|
if message.nil?
puts "No message was received."
else
puts "Received this message: #{message.content}"
end
end
Retrieves a message from the local queue, or waits for up to the duration specified for one to become available.
If a block is given, then it will be invaked after the next message is received or the call times out, passing in the message or nil respectively.
msg = rcvr.get # Uses the default timeout of forever
msg = rcvr.get Qpid::Messaging::Duration::IMMEDIATE # returns a message or exits immediately
# passes in a block to handle the received message
rcvr.get Qpid::Messaging::Duration::SECOND do |message|
if message.nil?
puts "No message was received."
else
puts "Received this message: #{message.content}"
end
end