title: Masstransit consumer death - Peek()
body: <p>I am curious as to if MassTransit consumers can Peek() a MSMQ queue before actually retrieving the msg.</p>
  
  <p>What the steps/process is:</p>
  
  <p>1) Msg sent to queue</p>
  
  <p>2) Consumers gets it and has to do a DB update -- takes about 5 seconds</p>
  
  <p>3) Consumer has to do second round of updates if the first worked.</p>
  
  <p>My problem is, how can I handle the case that if the first DB update fails that the message stays in the queue (i.e. network problem and can't get to db).</p>
  
  <p>Currently as soon as it reads the msg from the queue it removes it and then it just disappears if the DB updates fail..</p>
  
  <p>Additionally, how can I handle a power failure -- I mean if half way through a 'job' by a consumer, whatever that is (db update or something else) and the power dies etc, how can I re-run the process on the msg in the queue? Lets say the job (in my current instance anyway) is pushing a new row to a table. I mean I can write the code to first check if the row is there and if it is then drop the message and if not then run the task, but how can I get it to re-run the whole process in the first place?</p>
  
  <p>I have read up that I could <code>Peek()</code> the queue and then run the task and then read the queue msg for real and remove it, but I cannot for the life of me figure out if that works with mass transit... bit lost...</p>
  
  <p>Additionally I am aware that Masstransit has <code>.RetryLater</code> but then do I use that in the process? Is it  <code>Initially</code> --> <code>When</code> --> <code>Then</code>  --> <code>.RetryLater</code> in the saga??</p>
  
  <p>Any pointers would be appeciated</p>
  
  <p>Kindest Regards
  Robin</p>
  
  <p>EDIT</p>
  
  <p>PS: I am using a saga....</p>
  
  <pre><code>Define(() =&gt;
              {
                  RemoveWhen(saga =&gt; saga.CurrentState == Completed);
  
                  Initially(
                      When(NewAC)
                          .Then((saga, message) =&gt; saga.ProcessPSM(message),
                              InCaseOf&lt;Exception&gt;()
                                 .TransitionTo(Problem)                                  
                                  )
                          .Then((saga, message) =&gt; saga.PostProcessPSM())
                          .Complete()
                      );
                  During(Problem,
                      When(Waiting)
                                 // NOTE: THIS DOES NOT WORK!!!!
                          .RetryLater()
                      );
                  });
  </code></pre>
  
  <p>The RetryLater throw an error of: 
  "The message cannot be accepted by an existing saga"</p>
  
  <p>I am not sure how else I can access the 'RetryLater". </p>