Class Stomp::Connection
In: lib/stomp/connection.rb
lib/connection/utils.rb
lib/connection/utf8.rb
lib/connection/netio.rb
lib/connection/heartbeats.rb
lib/connection/heartbeats.rb
lib/connection/netio.rb
lib/connection/utf8.rb
lib/connection/utils.rb
lib/stomp/connection.rb
Parent: Object

Low level connection which maps commands and supports synchronous receives

Methods

Attributes

autoflush  [RW]  Autoflush forces a flush on each transmit. This may be changed dynamically by calling code.
autoflush  [RW]  Autoflush forces a flush on each transmit. This may be changed dynamically by calling code.
connection_frame  [R]  The CONNECTED frame from the broker.
connection_frame  [R]  The CONNECTED frame from the broker.
disconnect_receipt  [R]  Any disconnect RECEIPT frame if requested.
disconnect_receipt  [R]  Any disconnect RECEIPT frame if requested.
hb_received  [R]  Heartbeat receive has been on time.
hb_received  [R]  Heartbeat receive has been on time.
hb_sent  [R]  Heartbeat send has been successful.
hb_sent  [R]  Heartbeat send has been successful.
host  [R]  Currently-connected host and port
host  [R]  Currently-connected host and port
jruby  [R]  JRuby detected
jruby  [R]  JRuby detected
port  [R]  Currently-connected host and port
port  [R]  Currently-connected host and port
protocol  [R]  The Stomp Protocol version.
protocol  [R]  The Stomp Protocol version.
session  [R]  A unique session ID, assigned by the broker.
session  [R]  A unique session ID, assigned by the broker.

Public Class methods

default_port returns the default port used by the gem for TCP or SSL.

default_port returns the default port used by the gem for TCP or SSL.

A new Connection object can be initialized using two forms:

Hash (this is the recommended Connection initialization method):

  hash = {
    :hosts => [
      {:login => "login1", :passcode => "passcode1", :host => "localhost", :port => 61616, :ssl => false},
      {:login => "login2", :passcode => "passcode2", :host => "remotehost", :port => 61617, :ssl => false}
    ],
    :reliable => true,
    :initial_reconnect_delay => 0.01,
    :max_reconnect_delay => 30.0,
    :use_exponential_back_off => true,
    :back_off_multiplier => 2,
    :max_reconnect_attempts => 0,
    :randomize => false,
    :connect_timeout => 0,
    :connect_headers => {},
    :parse_timeout => 5,
    :logger => nil,
    :dmh => false,
    :closed_check => true,
    :hbser => false,
    :stompconn => false,
    :usecrlf => false,
    :max_hbread_fails => 0,
    :max_hbrlck_fails => 0,
    :fast_hbs_adjust => 0.0,
    :connread_timeout => 0,
    :tcp_nodelay => true,
    :start_timeout => 10,
  }

  e.g. c = Stomp::Connection.new(hash)

Positional parameters:

  login             (String,  default : '')
  passcode          (String,  default : '')
  host              (String,  default : 'localhost')
  port              (Integer, default : 61613)
  reliable          (Boolean, default : false)
  reconnect_delay   (Integer, default : 5)

  e.g. c = Stomp::Connection.new("username", "password", "localhost", 61613, true)

A new Connection object can be initialized using two forms:

Hash (this is the recommended Connection initialization method):

  hash = {
    :hosts => [
      {:login => "login1", :passcode => "passcode1", :host => "localhost", :port => 61616, :ssl => false},
      {:login => "login2", :passcode => "passcode2", :host => "remotehost", :port => 61617, :ssl => false}
    ],
    :reliable => true,
    :initial_reconnect_delay => 0.01,
    :max_reconnect_delay => 30.0,
    :use_exponential_back_off => true,
    :back_off_multiplier => 2,
    :max_reconnect_attempts => 0,
    :randomize => false,
    :connect_timeout => 0,
    :connect_headers => {},
    :parse_timeout => 5,
    :logger => nil,
    :dmh => false,
    :closed_check => true,
    :hbser => false,
    :stompconn => false,
    :usecrlf => false,
    :max_hbread_fails => 0,
    :max_hbrlck_fails => 0,
    :fast_hbs_adjust => 0.0,
    :connread_timeout => 0,
    :tcp_nodelay => true,
    :start_timeout => 10,
  }

  e.g. c = Stomp::Connection.new(hash)

Positional parameters:

  login             (String,  default : '')
  passcode          (String,  default : '')
  host              (String,  default : 'localhost')
  port              (Integer, default : 61613)
  reliable          (Boolean, default : false)
  reconnect_delay   (Integer, default : 5)

  e.g. c = Stomp::Connection.new("username", "password", "localhost", 61613, true)

Public Instance methods

Abort aborts a transaction by name.

Abort aborts a transaction by name.

Acknowledge a message, used when a subscription has specified client acknowledgement i.e. connection.subscribe("/queue/a", :ack => ‘client’). Accepts an optional transaction header ( :transaction => ‘some_transaction_id’ ) Behavior is protocol level dependent, see the specifications or comments below.

Acknowledge a message, used when a subscription has specified client acknowledgement i.e. connection.subscribe("/queue/a", :ack => ‘client’). Accepts an optional transaction header ( :transaction => ‘some_transaction_id’ ) Behavior is protocol level dependent, see the specifications or comments below.

Begin starts a transaction, and requires a name for the transaction

Begin starts a transaction, and requires a name for the transaction

client_ack? determines if headers contain :ack => "client".

client_ack? determines if headers contain :ack => "client".

closed? tests if this connection is closed.

closed? tests if this connection is closed.

Commit commits a transaction by name.

Commit commits a transaction by name.

disconnect closes this connection. If requested, a disconnect RECEIPT will be received.

disconnect closes this connection. If requested, a disconnect RECEIPT will be received.

hashed_initialize prepares a new connection with a Hash of initialization parameters.

hashed_initialize prepares a new connection with a Hash of initialization parameters.

hbrecv_count returns the current connection‘s heartbeat receive count.

hbrecv_count returns the current connection‘s heartbeat receive count.

hbrecv_interval returns the connection‘s heartbeat receive interval.

hbrecv_interval returns the connection‘s heartbeat receive interval.

hbsend_count returns the current connection‘s heartbeat send count.

hbsend_count returns the current connection‘s heartbeat send count.

hbsend_interval returns the connection‘s heartbeat send interval.

hbsend_interval returns the connection‘s heartbeat send interval.

open? tests if this connection is open.

open? tests if this connection is open.

poll returns a pending message if one is available, otherwise returns nil.

poll returns a pending message if one is available, otherwise returns nil.

Publish message to destination. To disable content length header use header ( :suppress_content_length => true ). Accepts a transaction header ( :transaction => ‘some_transaction_id’ ).

Publish message to destination. To disable content length header use header ( :suppress_content_length => true ). Accepts a transaction header ( :transaction => ‘some_transaction_id’ ).

receive returns the next Message off of the wire. this can return nil in cases where:

  • the broker has closed the connection
  • the connection is not reliable

receive returns the next Message off of the wire. this can return nil in cases where:

  • the broker has closed the connection
  • the connection is not reliable

set_logger selects a new callback logger instance.

set_logger selects a new callback logger instance.

sha1 returns a SHA1 digest for arbitrary string data.

sha1 returns a SHA1 digest for arbitrary string data.

log call router

log call router

Subscribe subscribes to a destination. A subscription name is required. For Stomp 1.1+ a session unique subscription ID is also required.

Subscribe subscribes to a destination. A subscription name is required. For Stomp 1.1+ a session unique subscription ID is also required.

Send a message back to the source or to the dead letter queue. Accepts a dead letter queue option ( :dead_letter_queue => "/queue/DLQ" ). Accepts a limit number of redeliveries option ( :max_redeliveries => 6 ). Accepts a force client acknowledgement option (:force_client_ack => true).

Send a message back to the source or to the dead letter queue. Accepts a dead letter queue option ( :dead_letter_queue => "/queue/DLQ" ). Accepts a limit number of redeliveries option ( :max_redeliveries => 6 ). Accepts a force client acknowledgement option (:force_client_ack => true).

Unsubscribe from a destination. A subscription name is required. For Stomp 1.1+ a session unique subscription ID is also required.

Unsubscribe from a destination. A subscription name is required. For Stomp 1.1+ a session unique subscription ID is also required.

uuid returns a type 4 UUID.

uuid returns a type 4 UUID.

valid_utf8? returns an indicator if the given string is a valid UTF8 string.

valid_utf8? returns an indicator if the given string is a valid UTF8 string.

[Validate]