/// <summary> /// This method should be called by all derived message handlers that write the message to a repository /// to set the message sequence (if not already set). It should not be called by message handlers that /// only call other message handlers. /// </summary> protected void SetMessageSequence(EventMessage message) { if (message.Sequence == 0) { int sequence = Interlocked.Increment(ref _currentSequence); message.SetSequence(sequence); } }
/// <summary> /// Sets the sequence number on a message to the specified value. This method should be called by /// derived readers that store the sequence number separately from the message itself (ie. do not /// serialize the EventMessage object to binary or XML. /// </summary> protected void SetMessageSequence(EventMessage message, int sequence) { Debug.Assert(message.Sequence == 0, "Setting the Sequence value on a message to " + sequence + ", but it's already set to " + message.Sequence); message.SetSequence(sequence); }