Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,026 | Comments: 44,842

filter by tags archive

1st April Post – The multi purpose method

time to read 2 min | 365 words

Since it appears to be customary, I decided that I need to make a few posts for April 1st. Here is the second of them.

public void RemoveReversalsMoveCompletedMessagesAndFinishSubQueueMove(Guid transactionId)
    Api.JetSetCurrentIndex(session, txs, "by_tx_id");
    Api.MakeKey(session, txs, transactionId.ToByteArray(), MakeKeyGrbit.NewKey);

    if (Api.TrySeek(session, txs, SeekGrbit.SeekEQ) == false)
    Api.MakeKey(session, txs, transactionId.ToByteArray(), MakeKeyGrbit.NewKey);
    Api.JetSetIndexRange(session, txs, SetIndexRangeGrbit.RangeInclusive | SetIndexRangeGrbit.RangeUpperLimit);
        var queue = Api.RetrieveColumnAsString(session, txs, txsColumns["queue"], Encoding.Unicode);
        var bookmarkData = Api.RetrieveColumn(session, txs, txsColumns["bookmark_data"]);
        var bookmarkSize = Api.RetrieveColumnAsInt32(session, txs, txsColumns["bookmark_size"]).Value;

        var actions = GetQueue(queue);

        var bookmark = new MessageBookmark
            Bookmark = bookmarkData,
            QueueName = queue,
            Size = bookmarkSize

        if (actions.GetMessageStatus(bookmark) == MessageStatus.Processing)
            actions.SetMessageStatus(bookmark, MessageStatus.ReadyToDeliver);

        Api.JetDelete(session, txs);
    } while (Api.TryMoveNext(session, txs));

And yes, it is from real code, and it is going to production soon.


Neal Blomfield

Do you loose a little bit of hope every time you come across code like this (and your previous post)?

What are we doing so wrong that software is continually written so poorly as to make a grown developer cry ( or mumble and rant under his breath)?

Comment preview

Comments have been closed on this topic.


No future posts left, oh my!


  1. Technical observations from my wife (3):
    13 Nov 2015 - Production issues
  2. Production postmortem (13):
    13 Nov 2015 - The case of the “it is slow on that machine (only)”
  3. Speaking (5):
    09 Nov 2015 - Community talk in Kiev, Ukraine–What does it take to be a good developer
  4. Find the bug (5):
    11 Sep 2015 - The concurrent memory buster
  5. Buffer allocation strategies (3):
    09 Sep 2015 - Bad usage patterns
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats