Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9023401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:45:11+00:00 2026-06-16T05:45:11+00:00

I am curious as to if MassTransit consumers can Peek() a MSMQ queue before

  • 0

I am curious as to if MassTransit consumers can Peek() a MSMQ queue before actually retrieving the msg.

What the steps/process is:

1) Msg sent to queue

2) Consumers gets it and has to do a DB update — takes about 5 seconds

3) Consumer has to do second round of updates if the first worked.

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).

Currently as soon as it reads the msg from the queue it removes it and then it just disappears if the DB updates fail..

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?

I have read up that I could Peek() 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…

Additionally I am aware that Masstransit has .RetryLater but then do I use that in the process? Is it Initially –> When –> Then –> .RetryLater in the saga??

Any pointers would be appeciated

Kindest Regards
Robin

EDIT

PS: I am using a saga….

Define(() =>
            {
                RemoveWhen(saga => saga.CurrentState == Completed);

                Initially(
                    When(NewAC)
                        .Then((saga, message) => saga.ProcessPSM(message),
                            InCaseOf<Exception>()
                               .TransitionTo(Problem)                                  
                                )
                        .Then((saga, message) => saga.PostProcessPSM())
                        .Complete()
                    );
                During(Problem,
                    When(Waiting)
                               // NOTE: THIS DOES NOT WORK!!!!
                        .RetryLater()
                    );
                });

The RetryLater throw an error of:
“The message cannot be accepted by an existing saga”

I am not sure how else I can access the ‘RetryLater”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:45:12+00:00Added an answer on June 16, 2026 at 5:45 am

    MassTransit abstracts the concepts of the underlying queues. So Peek is not the solution,
    but it does have other means for retrying messages. If you are just interested in handling error and failure conditions the following mechanisms are sufficient.

    By default if a consumer throws an exception the message will be retried N times:

    • where N is configured on the bus and defaults to 5. It can be changed in
      the bus initilisation using SetDefaultRetryLimit on the ServiceBusConfigurator
    • Where retried means the message will be added to the end of the queue

    If you would like a finer grained approach to error handling you can implement a Context Consumer, catch recoverable or transient exceptions and manually call RetryLater. There is no limit to how many times this can be done as I understand it.

    public class RetryConsumer : Consumes<AwesomeMessage>.Context
    {
    
        public void Consume(IConsumeContext<AwesomeMessage> message)
        {
            try
            {
                Console.WriteLine("This is Attempt " + message.RetryCount);
                // Do Something
            }
            catch (SomeTransientException e)
            {
                message.RetryLater();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Curious how messages sent via C2DM for Android and APNS for iOS actually make
Just curious, is there a format string I can use to output something like
Curious, if I can invoke some 3rd party activity, and then in onActivityResult read
Just curious how are these implemented. I can't see where I would start. Do
Curious if I can get a little help here. I'm a perl newbie, and
Curious if anyone can help me on this. I am using WooThemes to create
curious if someone can help with one thing: I'm just trying to tell Xcode
Curious to know if I can use System.Xml.Linq from a C++/CX metro app. A
Curious what practices people have learned before making their final build and submitting to
Just curious, if django has already proven that auto-admin can be done well, why

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.