Class Qpid::Messaging::Session
In: qpid/ruby/lib/qpid_messaging/session.rb
Parent: Object

A Session represents a distinct conversation between end points. They are created from an active (i.e., not closed) Connection.

A Session is used to acknowledge individual or all messages that have passed through it


Public Instance methods

Acknowledges one or more outstanding messages that have been received on this session.


  • options - the set of options


  • :message - if specified, then only that Message is acknowledged
  • :sync - if true, the call will block until processed by the broker


  # acknowledge all received messages

  # acknowledge a single message
  session.acknowledge :message => message

  # acknowledge all messages, wait until the call finishes
  session.acknowledge :sync => true

Closes the Session and all associated Sender and Receiver instances.

*NOTE:* All Session instances for a Connection are closed when the Connection is closed. But closing a Session does not affect the owning Connection.

Commits any pending transactions for a transactional session.

Returns the Connection associated with this session.

Creates a new endpoint for receiving messages.

The address can either be an instance Address or else an address string.


  • address - the end point address.

Creates a new endpoint for sending messages.

The address can either be an instance Address or else an address string.


  • address - the end point address.

If the Session has been rendered invalid due to some exception, this method will result in that exception being raised.

If none have occurred, then no exceptions are raised.


  # show any errors that occurred during the Session
  if @session.errors?
    rescue Exception => error
      puts "An error occurred: #{error}"

Returns true if there were exceptions on this session.

Fetches the next Receiver with a message pending. Waits the specified number of milliseconds before timing out.

For a Receiver to be returned, it must have a capacity > 0 and have Messages locally queued.

If no Receiver is found within the time out period, then a MessageError is raised.


  • timeout - the duration


  loop do

      # wait a maximum of one minute for the next receiver to be ready
      recv = session.next_receiver Qpid::Messaging::Duration::MINUTE

      # get and dispatch the message
      msg = recv.get
      dispatch_message msg

      puts "No receivers were returned"


Returns the total number of receivable messages, and messages already received, by Receiver instances associated with this Session.

Retrieves the Receiver with the specified name, or nil if no such Receiver exists.


Rejects the specified message. A rejected message will not be redelivered.

NOTE: A message cannot be rejected once it has been acknowledged.

Releases the message, which allows the broker to attempt to redeliver it.

NOTE: A message connot be released once it has been acknowled.

Rolls back any uncommitted transactions on a transactional session.

Retrieves the Sender with the specified name.

Raises an exception if no such Sender exists.


  • name - the name of the Sender

Requests synchronization with the broker.


  • options - the list of options


  • +:block+ - if true, the call blocks until the broker acknowledges it

Returns the number of messages that have been acknowledged by this Session whose acknowledgements have not been confirmed as processed by the broker.