stompgem / stomp

A ruby gem for sending and receiving messages from a Stomp protocol compliant message queue. Includes: failover logic, ssl support.
http://stomp.github.com
Apache License 2.0
152 stars 80 forks source link

How to test if connection is currently failing? #47

Closed spilliton closed 12 years ago

spilliton commented 12 years ago

Hello,

I'm needing to implement some logic to occur when our stomp client is unable to connect to our message server.

I was trying to use client.open?. This returned true just fine, but when I killed my message server to test the failure condition, it continued to report true, even though 'on_connectfail' log messages were being logged.

After checking out the socket method in connection.rb, It looks like I might be able to check @connection_attempts > 0 but was wondering if there is a better way, or if maybe I'm going about this all wrong...

Thanks!

gmallard commented 12 years ago

Please show me your call to Client#new or Client#open.

Right now, I do not think you are doing anything wrong.......

Regards.

gmallard commented 12 years ago

Do you have a small example program that displays this behavior? If so, please post it here.

Thanks.

gmallard commented 12 years ago

You are making the argument that the instance variable @closed should be set to true during retries for a failing connection, and then set to false again when a reconnect occurs.

I agree. Accepted. It is a one line code change, and will be in the next release.

Regards, Guy

gmallard commented 12 years ago

Closed: 270512b

spilliton commented 12 years ago

That is it exactly. Thanks for jumping on this so quick!

I was gonna try and repro in a unit test on the gem, but had some other stuff come up this morning.

Thanks!