def receive_data data
      begin
        # log 'receive_data', data
        @buf << data

        while frame = Frame.parse(@buf)
          log 'receive', frame
          process_frame frame
        end
      rescue Exception => e
        logger.exception("[amqp] Failed processing frame, closing connection", e, :trace) unless ENV['IGNORE_AMQP_FAILURES']
        failed
      end
    end
def receive_data data
      begin
        # log 'receive_data', data
        @buf << data

        while frame = Frame.parse(@buf)
          log 'receive', frame
          process_frame frame
        end
      rescue Exception => e
        logger.exception("[amqp] Failed processing frame, closing connection", e, :trace) unless ENV['IGNORE_AMQP_FAILURES']
        failed
      end
    end
Catch exceptions that would otherwise cause EM to stop or be in a bad
 state if a top level EM error handler was setup. Instead close the connection and leave EM
 alone.
 Don't log an error if the environment variable IGNORE_AMQP_FAILURES is set (used in the
 enroll script)