hello,
Given the code
require 'rubygems'
require 'stomp'
require 'pp'
class StompLogger
def on_miscerr(params, errstr)
puts "Unexpected error on connection to stomp://%s@%s:%d %s" % [params[:cur_login], params[:cur_host], params[:cur_port], errstr]
pp caller
end
end
options = { :stompuser => "dev", :stomppass => "secret", :stompserver => "1.2.3.4", :stompport => 6163 }
connection = {:hosts => [
{:login => options[:stompuser], :passcode => options[:stomppass], :host => options[:stompserver], :port => options[:stompport]},
], :logger => StompLogger.new, :connect_headers => {:"heart-beat" => "10000,10000", :host => "stomp", :"accept-version" => "1.1,1.0"}}
conn = Stomp::Connection.open(connection)
p conn.connection_frame.headers
Thread.new(conn) do |conn|
while true
p conn.receive
end
end
puts "Sleeping....."
sleep 10000
So there's a background thread that just loops and receives and prints what it gets while the rest of the program continues. I am not sure if this is the intended use pattern for achiving this but it does work in 1.0 mode quite well and I've used this style of code all over.
When 1.1 protocol heartbeats are enabled this happens after some time:
{"heart-beat"=>"10000,10000", "version"=>"1.1", "session"=>"ID:stomp-34412-1340368192346-3:100", "server"=>"ActiveMQ/5.6.0"}
Sleeping.....
Unexpected error on connection to stomp://[email protected]:6163 receive failed: execution expired
["/home/rip/.gem/gems/stomp-1.2.3/lib/stomp/connection.rb:428:in `__old_receive'",
"/home/rip/.gem/gems/stomp-1.2.3/lib/stomp/connection.rb:438:in `receive'",
"test.rb:24",