Class Stomp::Client
In: lib/stomp/client.rb
lib/client/utils.rb
lib/client/utils.rb
lib/stomp/client.rb
Parent: Object

Typical Stomp client class. Uses a listener thread to receive frames from the server, any thread can send.

Receives all happen in one thread, so consider not doing much processing in that thread if you have much message volume.

Methods

Attributes

parameters  [R]  Parameters hash
parameters  [R]  Parameters hash

Public Class methods

A new Client object can be initialized using three forms:

Hash (this is the recommended Client 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::Client.new(hash)

Positional parameters:

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

  e.g. c = Stomp::Client.new('login', 'passcode', 'localhost', 61613, true)

Stomp URL :

  A Stomp URL must begin with 'stomp://' and can be in one of the following forms:

  stomp://host:port
  stomp://host.domain.tld:port
  stomp://login:passcode@host:port
  stomp://login:passcode@host.domain.tld:port

  e.g. c = Stomp::Client.new(urlstring)

A new Client object can be initialized using three forms:

Hash (this is the recommended Client 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::Client.new(hash)

Positional parameters:

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

  e.g. c = Stomp::Client.new('login', 'passcode', 'localhost', 61613, true)

Stomp URL :

  A Stomp URL must begin with 'stomp://' and can be in one of the following forms:

  stomp://host:port
  stomp://host.domain.tld:port
  stomp://login:passcode@host:port
  stomp://login:passcode@host.domain.tld:port

  e.g. c = Stomp::Client.new(urlstring)

Public Instance methods

Abort aborts work in a transaction by name.

Abort aborts work in a transaction by name.

Acknowledge a message, used when a subscription has specified client acknowledgement ( connection.subscribe("/queue/a",{:ack => ‘client’}). Accepts a transaction header ( :transaction => ‘some_transaction_id’ ).

Acknowledge a message, used when a subscription has specified client acknowledgement ( connection.subscribe("/queue/a",{:ack => ‘client’}). Accepts a transaction header ( :transaction => ‘some_transaction_id’ ).

acknowledge(message, headers = {})

Alias for ack

acknowledge(message, headers = {})

Alias for ack

autoflush returns the current connection‘s autoflush setting.

autoflush returns the current connection‘s autoflush setting.

autoflush= sets the current connection‘s autoflush setting.

autoflush= sets the current connection‘s autoflush setting.

Begin starts work in a a transaction by name.

Begin starts work in a a transaction by name.

close frees resources in use by this client. The listener thread is terminated, and disconnect on the connection is called.

close frees resources in use by this client. The listener thread is terminated, and disconnect on the connection is called.

close? tests if this client connection is closed.

close? tests if this client connection is closed.

Commit commits work in a transaction by name.

Commit commits work in a transaction by name.

Return the broker‘s CONNECTED frame to the client. Misnamed.

Return the broker‘s CONNECTED frame to the client. Misnamed.

Return any RECEIPT frame received by DISCONNECT.

Return any RECEIPT frame received by DISCONNECT.

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.

join the listener thread for this client, generally used to wait for a quit signal.

join the listener thread for this client, generally used to wait for a quit signal.

jruby? tests if the connection has detcted a JRuby environment

jruby? tests if the connection has detcted a JRuby environment

open? tests if this client connection is open.

open? tests if this client connection is open.

Poll for asynchronous messages issued by broker. Return nil of no message available, else the message

Poll for asynchronous messages issued by broker. Return nil of no message available, else the message

protocol returns the current client‘s protocol level.

protocol returns the current client‘s protocol level.

Publishes message to destination. If a block is given a receipt will be requested and passed to the block on receipt. Accepts a transaction header ( :transaction => ‘some_transaction_id’ ).

Publishes message to destination. If a block is given a receipt will be requested and passed to the block on receipt. Accepts a transaction header ( :transaction => ‘some_transaction_id’ ).

running checks if the thread was created and is not dead.

running checks if the thread was created and is not dead.

set_logger identifies a new callback logger.

set_logger identifies a new callback logger.

sha1 returns a SHA1 sum of a given string.

sha1 returns a SHA1 sum of a given string.

Subscribe to a destination, must be passed a block which will be used as a callback listener. Accepts a transaction header ( :transaction => ‘some_transaction_id’ ).

Subscribe to a destination, must be passed a block which will be used as a callback listener. Accepts a transaction header ( :transaction => ‘some_transaction_id’ ).

Unreceive a message, sending it back to its queue or to the DLQ.

Unreceive a message, sending it back to its queue or to the DLQ.

Unsubscribe from a subscription by name.

Unsubscribe from a subscription by name.

uuid returns a type 4 UUID.

uuid returns a type 4 UUID.

valid_utf8? validates any given string for UTF8 compliance.

valid_utf8? validates any given string for UTF8 compliance.

[Validate]