title: node module.export and recursion
body: <p>I am working on a node app that essentially is a simple AWS SQS poller that should sit and listen to new items in different queues.</p>
  
  <p>Here is my <code>module.export</code>:</p>
  
  <pre><code>module.exports = {
      readMessage: function(qParams, qType, tableName) {
          logger.debug(qType);
  
          SQS.receiveMessage(qParams, handleSqsResponse);
  
          function handleSqsResponse (err, data) {
              if(err) logger.error("handleSqsResponse error:" + err);
              if (data &amp;&amp; data.Messages) {
                  data.Messages.forEach(processMessage)
                  readMessage(); // continue reading until draining the queue (or UPTIME reached)
              }
              else{
                  logger.debug("no data in sqs.");
                  // process.exit();
              }
          }
  
          // 'processing' is mainly writing to logs using winston. Could add here any transformations and transmission to remote systems
          function processMessage(sqsMessage){
              // Parse sqs messag
              var msgObj = JSON.parse(sqsMessage.Body);
  
              // Process
              logger.info(msgObj.Message);
  
              _.extend(qParams, { "ReceiptHandle": sqsMessage.ReceiptHandle });
  
              dbMap[qType](msgObj, qParams, tableName);
          }
      }
  }
  </code></pre>
  
  <p>The issue I am running into is when I attempt to call <code>readMessage();</code> again. I get the error of <code>ReferenceError: readMessage is not defined</code></p>