vendor/bundle/ruby/1.8/gems/activemessaging-0.9.0/lib/activemessaging/gateway.rb
# Starts up an message listener to start polling for messages on each configured connection, and dispatching processing
Starts up an message listener to start polling for messages on each configured connection, and dispatching processing
Starts up an message listener to start polling for messages on each configured connection and dispatching processing
def receive destination_name, receiver=nil, subscribe_headers={}, timeout=10
        raise "You cannot have a nil or empty destination name." if destination_name.nil?
        conn = nil
        dest = find_destination destination_name
        config = load_connection_configuration(dest.broker_name)
        subscribe_headers['id'] = receiver.name.underscore unless (receiver.nil? or subscribe_headers.key? 'id') 
        Timeout.timeout timeout do
          conn = Gateway.adapters[config[:adapter]].new(config)
          conn.subscribe(dest.value, subscribe_headers)
          message = conn.receive
          conn.received message, subscribe_headers
          return message
        end
      rescue Timeout::Error=>toe
        ActiveMessaging.logger.error("Timed out trying to receive a message on destination #{destination_name}")
        raise toe
      ensure
        conn.disconnect unless conn.nil?
      end
def receive destination_name , receiver = nil , subscribe_headers = { } , timeout = 10 raise "You cannot have a nil or empty destination name." if destination_name . nil? conn = nil dest = find_destination destination_name config = load_connection_configuration ( dest . broker_name ) subscribe_headers [ 'id' ] = receiver . name . underscore unless ( receiver . nil? or subscribe_headers . key? 'id' ) Timeout . timeout timeout do conn = Gateway . adapters [ config [ :adapter ] ] . new ( config ) conn . subscribe ( dest . value , subscribe_headers ) message = conn . receive conn . received message , subscribe_headers return message end rescue Timeout :: Error => toe ActiveMessaging . logger . error ( "Timed out trying to receive a message on destination #{destination_name}" ) raise toe ensure conn . disconnect unless conn . nil? end
Starts up an message listener to start polling for messages on each configured connection, and dispatching processing
Starts up an message listener to start polling for messages on each configured connection and dispatching processing
destination_name
receiver
subscribe_headers
timeout