Class | Stomp::Connection |
In: |
lib/connection/heartbeats.rb
lib/connection/utils.rb lib/connection/netio.rb lib/connection/utf8.rb lib/stomp/connection.rb |
Parent: | Object |
Low level connection which maps commands and supports synchronous receives
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. |
disconnect_receipt | [R] | Any disconnect RECEIPT frame if requested. |
hb_received | [R] | Heartbeat receive has been on time. |
hb_sent | [R] | Heartbeat send has been successful. |
host | [R] | Currently-connected host and port |
jruby | [R] | JRuby detected |
port | [R] | Currently-connected host and port |
protocol | [R] | The Stomp Protocol version. |
session | [R] | A unique session ID, assigned by the broker. |
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} ], # These are the default parameters and do not need to be set :reliable => true, # reliable (use failover) :initial_reconnect_delay => 0.01, # initial delay before reconnect (secs) :max_reconnect_delay => 30.0, # max delay before reconnect :use_exponential_back_off => true, # increase delay between reconnect attpempts :back_off_multiplier => 2, # next delay multiplier :max_reconnect_attempts => 0, # retry forever, use # for maximum attempts :randomize => false, # do not radomize hosts hash before reconnect :connect_timeout => 0, # Timeout for TCP/TLS connects, use # for max seconds :connect_headers => {}, # user supplied CONNECT headers (req'd for Stomp 1.1+) :parse_timeout => 5, # IO::select wait time on socket reads :logger => nil, # user suplied callback logger instance :dmh => false, # do not support multihomed IPV4 / IPV6 hosts during failover :closed_check => true, # check first if closed in each protocol method :hbser => false, # raise on heartbeat send exception :stompconn => false, # Use STOMP instead of CONNECT :usecrlf => false, # Use CRLF command and header line ends (1.2+) :max_hbread_fails => 0, # Max HB read fails before retry. 0 => never retry :max_hbrlck_fails => 0, # Max HB read lock obtain fails before retry. 0 => never retry :fast_hbs_adjust => 0.0, # Fast heartbeat senders sleep adjustment, seconds, needed ... # For fast heartbeat senders. 'fast' == YMMV. If not # correct for your environment, expect unnecessary fail overs :connread_timeout => 0, # Timeout during CONNECT for read of CONNECTED/ERROR, secs :tcp_nodelay => true, # Turns on the TCP_NODELAY socket option; disables Nagle's algorithm :start_timeout => 0, # Timeout around Stomp::Client initialization :sslctx_newparm => nil, # Param for SSLContext.new :ssl_post_conn_check => true, # Further verify broker identity :nto_cmd_read => true, # No timeout on COMMAND read } 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)
open is syntactic sugar for ‘Connection.new’, see ‘initialize’ for usage.
Acknowledge a message, used when a subscription has specified client acknowledgement e.g.:
connection.subscribe("/queue/a", :ack => 'client') connection.subscribe("/queue/a", :ack => 'client-individual')
as appropriate for the protocol level.
Accepts an optional transaction header ( :transaction => ‘some_transaction_id’ ).
When the connection protocol level is 1.0 or 1.1 the message_or_ack_id parameter should match the message-id header of the MESSAGE being acknowledged e.g.:
connection.ack(message.headers['message-id'])
When the connection protocol level is 1.2 the message_or_ack_id parameter should match the ack header of the MESSAGE being acknowledged e.g.:
connection.ack(message.headers['ack'])
In summary, the behavior is protocol level dependent, see the specifications and comments in the code.
disconnect closes this connection. If requested, a disconnect RECEIPT will be received.
hashed_initialize prepares a new connection with a Hash of initialization parameters.
STOMP 1.1+ NACK.
When the connection protocol level is 1.1 the message_or_ack_id parameter should match the message-id header of the MESSAGE being acknowledged.
When the connection protocol level is 1.2 the message_or_ack_id parameter should match the ack header of the MESSAGE being acknowledged.
Behavior is protocol level dependent, see the specifications and comments below.
Publish message to destination. To disable content length header use header ( :suppress_content_length => true ). Accepts a transaction header ( :transaction => ‘some_transaction_id’ ).
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).
Unsubscribe from a destination. A subscription name is required. For Stomp 1.1+ a session unique subscription ID is also required.