1

I have a system that receives MSMQ messages and performs (close to) real-time analysis using NEsper. It is possible that some messages come late and perhaps in different order. This situation shall be flagged up and reported. Write not this is how it is working (meta code):

//shows how many messages came in wrong order
private int error;

//processing function
void MessageReceived(Message m)
{
    //the message is from the `past`
    //if compared to the engine time
    if(m.Occured < currentEngineTime)
    {
        error++; // I think there is a beter way to do this
    }

    // update engine time if required
    //engine time is manually adjusted with
    //each newest message

    //perform analysis of the message    
    //pass message to the engine processing pipeline
}

How do I better handle the situation where a message arrives "from the past", I cannot throw an exception as I still need the message to be processed, but I want the user to know more details about the message rather just saying that there was N incorrectly received messages. I was thinking to do something like AggregateException, but not sure how that works. Any ideas?

oleksii
  • 35,458
  • 16
  • 93
  • 163
  • What is your user supposed to do with this information? Is there actually anything she can do to prevent this from happening? Or is it actually a bug you don't know how to fix? Consider raising an event that the UI can do something with or log it somewhere. – Hans Passant Dec 13 '11 at 14:01
  • @Hans At this stage the user is supposed to be aware of the event and get details of which message came with a delay. Seems like the idea of firing an event is what I really need, could you post this as an answer? – oleksii Dec 13 '11 at 15:27

0 Answers0