title: Mule 4 - Empty VM queue error consuming messages
body: <p>I have a flow in Mule 4 that reads data from a CSV file and inserts it into Salesforce using a <code>Batch</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/XzjgX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XzjgX.jpg" alt="mule flow"></a></p>
  
  <p>All Salesforce results are inserted into a <strong>non-persistent VM queue</strong> (transient by default).</p>
  
  <p>All messages are inserted for each block of records and are consumed without problems at the end of the batch.</p>
  
  <p>However, when I have finished, the following error appears after 10 seconds:</p>
  
  <pre><code>Message               : Tried to consume messages from VM queue 'productQueue' but it was empty after timeout of 10 SECONDS.
  Error type            : VM:EMPTY_QUEUE
  Element               : testing-threadingSub_Flow/processors/0/processors/0 @ testing-threading:testing-threading.xml:95 (Consume)
  Element XML           : &lt;vm:consume doc:name="Consume" doc:id="6b7b2df6-c986-425c-a6f0-29613a876d37" config-ref="VM_Config" queueName="demoQueue" timeout="10"&gt;&lt;/vm:consume&gt;
  </code></pre>
  
  <p><strong>Why does the consumer of the queue run if there are no more messages to process?</strong> </p>
  
  <p>I want this component to only read messages when it is his turn. Maybe I'm using the wrong kind of VM?</p>