Closed abhishek538 closed 9 years ago
It is not clear whether this is a bug report or merely a question. Post:
Please repost that documentation here, not just to my private mail.
Frankly, I suspect that you do not understand the difference between AMQ durable and non-durable subscriptions. Particularly as the concept applies to 'topics'. Review and understand the AMQ documentation for details on that.
A couple of notes to this ....
I can not use the code you sent in mail. What is "zmq_helper"? It does not appear to be on RubyForge.
What version of AMQ? There have been difficulties in the past with missing queues/topics.
Please post (here) code that shows this behaviour without all the ZMQ logic.
At present ..... I do not believe this to be a stomp gem problem. All of my failover tests here work perfectly. As well as a new test that ..... tries to do what you described.
And ...... why exactly ....... are you trying to use STOMP to monitor ZMQ traffic ? That design makes no sense to me.
Sorry for the late reply and the messed up code. Here is the code -
require 'rubygems'
require 'set'
require 'time'
require 'stomp'
active_mq_broker_monitor = Stomp::Client.new("failover:(stomp://localhost:61613)")
class ActivityMonitor
def initialize(activemq_broker, monitor_topic, hold_period)
@activemq_broker = activemq_broker
@monitor_topic = monitor_topic
@hold_period = hold_period
end
def send_message
headers = {}
message = [Time.now.strftime("%H:%M:%S")]
@activemq_broker.publish(@monitor_topic, message.join("\n"), headers)
end
def run
begin
ticks = 0
while true
ticks += 1
if ticks >= @hold_period
send_message
ticks = 0
end
end
return
rescue Exception => e
puts "exception: #{e}"
puts e.backtrace.join("\n")
end
end
end
t = Thread.new do
activity_monitor = ActivityMonitor.new(active_mq_broker_monitor,"/topic/topicAbhi",10000)
activity_monitor.run
end
t.join()
And the problem i face is: If i restart activemq i get this exception, by restarting i mean manually stopping activemq ( using stop command) and then starting it:
exception: Stomp::Error::NoCurrentConnection
/usr/lib64/ruby/gems/1.8/gems/stomp-1.3.4/lib/stomp/connection.rb:359:in `publish'
/usr/lib64/ruby/gems/1.8/gems/stomp-1.3.4/lib/stomp/client.rb:240:in `publish'
activity_monitor_test.rb:18:in `send_message'
activity_monitor_test.rb:27:in `run'
activity_monitor_test.rb:41
activity_monitor_test.rb:39:in `initialize'
activity_monitor_test.rb:39:in `new'
activity_monitor_test.rb:39
after investigation i found out that this exception is thrown because @closed becomes "true" in "connection.rb"
Activemq Version Used: "5.5.1"
This is happening because you have asked for it to happen that way.
Do the following:
1) Change to a hashed connect (which is the recommended technique in any case.) 2) Specify :closed_check => false in the hash.
Example connect code:
hash = { :hosts => [
{:login => 'guest', :passcode => 'guest', :host => 'localhost', :port => 61613, :ssl => false}, # AMQ
],
:reliable => true,
:closed_check => false, # THIS is your problem, default is true
:connect_headers => {:host => "localhost", :"accept-version" => "1.0",
}
}
active_mq_broker_monitor = Stomp::Client.open(hash)
With the above, fail over retries will be triggered.
okay.. thanks. sorry for such a lame question but can you please explain the purpose of closed_check parameter?
The purpose was to allow the caller to disable a hard coded check for no connection in each protocol method. The closed_check parameter was added on 10 SEP 2012, here:
0a24463 Provide the ability to disable raises of NoCurrentConnection in protocol methods.
That hard coded check went in ........ between v1.1.10 and v1.2.0. Most of that work was STOMP 1.1 related.
7dd9397 Raise if called after Connection#disconnect or Client#close.
Incidentally I would recommend that you be using the STOMP 1.2 protocol, rather than 1.0.
In any case, all these are meant to give the user the maximum of flexibility. I frankly admit that the README is the only documentation for much of this. Most folks I knw just read the code to figure out what the best course of actions is / are.
I also suggest that you look at the examples subdirectory of the STOMP install. There is a lot of good information there.
thanks a lot.
I have an activemq topic with no subscribers (just for debugging purposes), so when i start my application it works fine, messages are produced but if activemq is restarted, then the topic never appears again i get the error: Stomp::Error::NoCurrentConnection /usr/lib64/ruby/gems/1.8/gems/stomp-1.3.4/lib/stomp/connection.rb:359:in
publish' /usr/lib64/ruby/gems/1.8/gems/stomp-1.3.4/lib/stomp/client.rb:240:in
publish' ./lib/activity_monitor.rb:50:insend_message' ./lib/activity_monitor.rb:85:in
run' ./lib/activity_monitor.rb:74:ineach' ./lib/activity_monitor.rb:74:in
run' because the value of @closed becomes "true" even when i am using failover with stomp. In activity_monitor.rb, send_message method I am calling publish() method to publish messages in a loop as the messages are produced. but if the topic has a subscriber then the topic appears again on restarting activemq, but why is its behavior different with no subscribers?