lib/activemessaging/adapters/asqs.rb
def receive
          raise "No subscriptions to receive messages from." if (@subscriptions.nil? || @subscriptions.empty?)
          start = @current_subscription
          while true
            @current_subscription = ((@current_subscription < @subscriptions.length-1) ? @current_subscription + 1 : 0)
            sleep poll_interval if (@current_subscription == start)
            queue_name = @subscriptions.keys.sort[@current_subscription]
            queue = queues[queue_name]
            unless queue.nil?
              messages = retrieve_messsages queue, 1
              return messages[0] unless (messages.nil? or messages.empty? or messages[0].nil?)
            end
          end
        end
# receive a single message from any of the subscribed queues
# check each queue once, then sleep for poll_interval
receive a single message from any of the subscribed queues
check each queue once, then sleep for poll_interval
receive a single message from any of the subscribed queues check each queue once then sleep for poll_interval
def receive
          raise "No subscriptions to receive messages from." if (@subscriptions.nil? || @subscriptions.empty?)
          start = @current_subscription
          while true
            @current_subscription = ((@current_subscription < @subscriptions.length-1) ? @current_subscription + 1 : 0)
            sleep poll_interval if (@current_subscription == start)
            queue_name = @subscriptions.keys.sort[@current_subscription]
            queue = queues[queue_name]
            unless queue.nil?
              messages = retrieve_messsages queue, 1
              return messages[0] unless (messages.nil? or messages.empty? or messages[0].nil?)
            end
          end
        end
def receive raise "No subscriptions to receive messages from." if ( @subscriptions . nil? || @subscriptions . empty? ) start = @current_subscription while true @current_subscription = ( ( @current_subscription < @subscriptions . length - 1 ) ? @current_subscription + 1 : 0 ) sleep poll_interval if ( @current_subscription == start ) queue_name = @subscriptions . keys . sort [ @current_subscription ] queue = queues [ queue_name ] unless queue . nil? messages = retrieve_messsages queue , 1 return messages [ 0 ] unless ( messages . nil? or messages . empty? or messages [ 0 ] . nil? ) end end end
receive a single message from any of the subscribed queues
check each queue once, then sleep for poll_interval
receive a single message from any of the subscribed queues check each queue once then sleep for poll_interval