amq-client 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
    
        data/.travis.yml
    CHANGED
    
    
| @@ -442,6 +442,20 @@ module AMQ | |
| 442 442 | 
             
                    end # start_automatic_recovery
         | 
| 443 443 |  | 
| 444 444 |  | 
| 445 | 
            +
                    # Defines a callback that will be executed after time since last broker heartbeat is greater
         | 
| 446 | 
            +
                    # than or equal to the heartbeat interval (skipped heartbeat is detected).
         | 
| 447 | 
            +
                    # Only one callback can be defined (the one defined last replaces previously added ones).
         | 
| 448 | 
            +
                    #
         | 
| 449 | 
            +
                    # @api public
         | 
| 450 | 
            +
                    def on_skipped_heartbeats(&block)
         | 
| 451 | 
            +
                      self.redefine_callback(:skipped_heartbeats, &block)
         | 
| 452 | 
            +
                    end # on_skipped_heartbeats(&block)
         | 
| 453 | 
            +
             | 
| 454 | 
            +
                    # @private
         | 
| 455 | 
            +
                    def run_skipped_heartbeats_callbacks
         | 
| 456 | 
            +
                      self.exec_callback_yielding_self(:skipped_heartbeats, @settings)
         | 
| 457 | 
            +
                    end
         | 
| 458 | 
            +
             | 
| 445 459 | 
             
                    # @endgroup
         | 
| 446 460 |  | 
| 447 461 |  | 
| @@ -528,10 +542,10 @@ module AMQ | |
| 528 542 | 
             
                    # Sends a heartbeat frame if connection is open.
         | 
| 529 543 | 
             
                    # @api plugin
         | 
| 530 544 | 
             
                    def send_heartbeat
         | 
| 531 | 
            -
                      if tcp_connection_established?
         | 
| 532 | 
            -
                        if @last_server_heartbeat < (Time.now - (self.heartbeat_interval * 2))
         | 
| 533 | 
            -
                          logger.error " | 
| 534 | 
            -
                           | 
| 545 | 
            +
                      if tcp_connection_established? && !@handling_skipped_hearbeats
         | 
| 546 | 
            +
                        if @last_server_heartbeat < (Time.now - (self.heartbeat_interval * 2)) && !reconnecting?
         | 
| 547 | 
            +
                          logger.error "[amqp] Detected missing server heartbeats"
         | 
| 548 | 
            +
                          self.handle_skipped_hearbeats
         | 
| 535 549 | 
             
                        end
         | 
| 536 550 | 
             
                        send_frame(Protocol::HeartbeatFrame)
         | 
| 537 551 | 
             
                      end
         | 
| @@ -274,6 +274,11 @@ module AMQ | |
| 274 274 | 
             
                      AMQ::Client::TCPConnectionFailed
         | 
| 275 275 | 
             
                    end # self.tcp_connection_failure_exception_class
         | 
| 276 276 |  | 
| 277 | 
            +
                    def handle_skipped_hearbeats
         | 
| 278 | 
            +
                      # TODO
         | 
| 279 | 
            +
                    end
         | 
| 280 | 
            +
             | 
| 281 | 
            +
             | 
| 277 282 | 
             
                    protected
         | 
| 278 283 |  | 
| 279 284 | 
             
                    # @api private
         | 
| @@ -291,7 +296,8 @@ module AMQ | |
| 291 296 |  | 
| 292 297 | 
             
                      # now we can set it. MK.
         | 
| 293 298 | 
             
                      @had_successfully_connected_before = true
         | 
| 294 | 
            -
                      @reconnecting | 
| 299 | 
            +
                      @reconnecting                      = false
         | 
| 300 | 
            +
                      @handling_skipped_hearbeats        = false
         | 
| 295 301 |  | 
| 296 302 | 
             
                      self.reset
         | 
| 297 303 | 
             
                      self.handshake
         | 
| @@ -173,8 +173,7 @@ module AMQ | |
| 173 173 | 
             
                      self.set_pending_connect_timeout((@settings[:timeout] || 3).to_f) unless defined?(JRUBY_VERSION)
         | 
| 174 174 |  | 
| 175 175 | 
             
                      if self.heartbeat_interval > 0
         | 
| 176 | 
            -
                         | 
| 177 | 
            -
                        EventMachine.add_periodic_timer(self.heartbeat_interval, &method(:send_heartbeat))
         | 
| 176 | 
            +
                        self.initialize_heartbeat_sender
         | 
| 178 177 | 
             
                      end
         | 
| 179 178 | 
             
                    end # initialize(*args)
         | 
| 180 179 |  | 
| @@ -265,7 +264,11 @@ module AMQ | |
| 265 264 |  | 
| 266 265 | 
             
                      # now we can set it. MK.
         | 
| 267 266 | 
             
                      @had_successfully_connected_before = true
         | 
| 268 | 
            -
                      @reconnecting | 
| 267 | 
            +
                      @reconnecting                      = false
         | 
| 268 | 
            +
                      @handling_skipped_hearbeats        = false
         | 
| 269 | 
            +
                      @last_server_heartbeat             = Time.now
         | 
| 270 | 
            +
             | 
| 271 | 
            +
                      self.initialize_heartbeat_sender if self.heartbeat_interval > 0
         | 
| 269 272 |  | 
| 270 273 | 
             
                      self.handshake
         | 
| 271 274 | 
             
                    end
         | 
| @@ -287,6 +290,7 @@ module AMQ | |
| 287 290 | 
             
                    def unbind(exception = nil)
         | 
| 288 291 | 
             
                      if !@tcp_connection_established && !@had_successfully_connected_before && !@intentionally_closing_connection
         | 
| 289 292 | 
             
                        @tcp_connection_failed = true
         | 
| 293 | 
            +
                        logger.error "[amqp] Detected TCP connection failure"
         | 
| 290 294 | 
             
                        self.tcp_connection_failed
         | 
| 291 295 | 
             
                      end
         | 
| 292 296 |  | 
| @@ -346,7 +350,24 @@ module AMQ | |
| 346 350 | 
             
                      closed!
         | 
| 347 351 | 
             
                    end # disconnection_successful
         | 
| 348 352 |  | 
| 353 | 
            +
                    # Called when time since last server heartbeat received is greater or equal to the
         | 
| 354 | 
            +
                    # heartbeat interval set via :heartbeat_interval option on connection.
         | 
| 355 | 
            +
                    #
         | 
| 356 | 
            +
                    # @api plugin
         | 
| 357 | 
            +
                    def handle_skipped_hearbeats
         | 
| 358 | 
            +
                      if !@handling_skipped_hearbeats && @tcp_connection_established && !@intentionally_closing_connection
         | 
| 359 | 
            +
                        @handling_skipped_hearbeats = true
         | 
| 360 | 
            +
                        @heartbeats_timer.cancel
         | 
| 349 361 |  | 
| 362 | 
            +
                        self.run_skipped_heartbeats_callbacks
         | 
| 363 | 
            +
                      end
         | 
| 364 | 
            +
                    end
         | 
| 365 | 
            +
             | 
| 366 | 
            +
                    # @private
         | 
| 367 | 
            +
                    def initialize_heartbeat_sender
         | 
| 368 | 
            +
                      @last_server_heartbeat = Time.now
         | 
| 369 | 
            +
                      @heartbeats_timer      = EventMachine::PeriodicTimer.new(self.heartbeat_interval, &method(:send_heartbeat))
         | 
| 370 | 
            +
                    end
         | 
| 350 371 |  | 
| 351 372 |  | 
| 352 373 |  | 
    
        data/lib/amq/client/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: amq-client
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 59
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 8
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.8. | 
| 9 | 
            +
              - 2
         | 
| 10 | 
            +
              version: 0.8.2
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Jakub Stastny
         | 
| @@ -18,7 +18,7 @@ autorequire: | |
| 18 18 | 
             
            bindir: bin
         | 
| 19 19 | 
             
            cert_chain: []
         | 
| 20 20 |  | 
| 21 | 
            -
            date: 2011-08- | 
| 21 | 
            +
            date: 2011-08-28 00:00:00 +04:00
         | 
| 22 22 | 
             
            default_executable: 
         | 
| 23 23 | 
             
            dependencies: 
         | 
| 24 24 | 
             
            - !ruby/object:Gem::Dependency 
         |