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

A Session represents a distinct conversation between end points.

Methods

Public Instance methods

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

Arguments

  • :message - if specified, then only the Message specified is acknowledged
  • :sync - if true then the call will block until processed by the server (def. false)

Examples

  session.acknowledge                     # acknowledges all received messages
  session.acknowledge :message => message # acknowledge one message
  session.acknowledge :sync => true       # blocks until the call completes

Closes the Session and all associated Sender and Receiver instances.

NOTE: All Session instances for a Connection are closed when the Connection is closed.

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 a string that describes an address endpoint.

Arguments

  • address The end point address.

Examples

  receiver = session.create_receiver "my-queue"

Creates a new endpoint for sending messages.

The address can either be an instance Address or else a string that describes an address endpoint.

Arguments

  • address The end point address.

Examples

  sender = session.create_sender "my-queue;{create:always}"

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.

Examples

  if @session.errors?
    begin
      @session.errors
    rescue Exception => error
      puts "An error occurred: #{error}"
    end
  end

Returns true if there were exceptions on this session.

Examples

  puts "There were session errors." if @session.errors?

Fetches the Receiver for the next message.

Arguments

  • timeout - time to wait for a Receiver before timing out

Examples

  recv = session.next_receiver # wait forever for the next +Receiver+
  # execute a block on the next receiver
  session.next_receiver do |recv|
    msg = recv.get
    puts "Received message: #{msg.content}"
  end

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.

The Receiver must have been previously created using the create_receiver method.

Arguments

Examples

  receiver = session.receiver "my-queue"

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.

The Sender must have been previously created using the create_sender method.

Arguments

Examples

  sender = session.sender "my-queue"

Requests synchronization with the server.

Arguments

  • :block - if true then the call blocks until the server acknowledges it (def. false)

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

[Validate]