1. Service Broker in a nutshell

    Lately I was looking into different Queuing Technologies to choose the best fit for the upcoming project. In that post I just want to summarize my finding. I was already familiar with Azure Service Bus and Rabbit MQ. But we didn’t need advanced routing capabilities they both provide, hence I decided to look into alternative solutions. By the way here’s a very nice Service Bus for Windows Server & RabbitMQ comparison. We were already using MS SQL Server to persist the data. So using Service Broker was an appealing choice from the very beginning. Advantages

    • Very easy to backup/restore
    • Sequential Delivery & Related Messages Locking (plus it allows to access internal Sequence ID & Sequence Number)
    • To en-queue message you should have a conversation first. It means you en-queue message into one queue and listen for messages to appear on another queue
    • Index fragmentation then Dealing with Large Queues
    Alternative solution is to use tables as queues. The main disadvantage of it is the lack of Activation. Which means you will have to Pull messages from the queue. While Service Broker, Rabbit MQ and others provide Push mechanism to notify listeners about newly added items. I highly recommend you to read in-death book on Service Broker Pro SQL Server 2008 Service Broker  so you will know better in which cases you can leverage Service Broker capabilities. …

  2. Meteor got Cordova support!

    I never mention it on the blog, but I really like Meteor framework it’s a really exciting way to build single page JavaScript application (running on NodeJS).

    Meteor is an open-source platform for building top-quality web apps in a fraction of the time, whether you're an expert developer or just getting started https://www.meteor.com/
    Today I was really excited to read that they are working on Cordova support. Supported Platform(s)
    • Android
    • iOS

  3. Structured Logging

    On weekends I was reading latest Technology Radar from Thought Works. It’s really interesting! Some of things they mentioned we are already using here at Compellotech (such as HAL, Angular JS, Nancy, TypeScript, etc.) Others are good not know about, for example Structured Logging. Structured Logging Lately I was thinking on the best approach to enabled monitoring in our distributed system. The goal is to have some universal solution which will allow us to release something in 1 or 2 sprints (we use one week sprint). I did some research and I suppose it’s a way to go for us.

    • Allows to enable monitoring in all the components without significant changes
    • Allow to setup Alerts for different things (if they appear in the log)
    • Allow to search for issues for example by Customer ID. Just imagine you type CustomerID=”777” and you see all the events in the system related to that customer!
    Technical details There is a great Structured Logging framework http://serilog.net/. It allows you to publish logs to different systems. For example you would use Seq web application. Alternative approach is to publish logs to Elastic Search and use Kibana as a Front End. Another interesting option is to push logs into MongoDB. So you ‘ll be able to do something like  
    db.log.find( { customerId: “777”, application: “PaymentGateway” } )

  4. Command Query Responsibility Segregation (CQRS) pattern

    Time flies, it’s more than two years since I discovered CQRS pattern. If it’s first time you hear about CQRS, there is a great A Journey into CQRS talk on Channel 9. Today we are using CQRS actively at Compellotech. We are using it as a high level architecture on some components. In the same time we are using it inside of our systems to make internal design better. The approach we are using is Very similar to the one described by Steven on .NET Junkie. I really encourage you to check his articles out. By the way he’s the author of easy, flexible, and fast dependency injection framework - Simple Injector. …

  5. MSSQL Activity Monitoring

    At Compellotech we were using Sp_GetWhoIsActive for some time now. It’s VERY convenient for activity monitoring. It was created by very bright guy, but it’s too heavy sometimes (might impact a production performance). So from now on we are using newer query which uses DMO views and does not have any impact on the database performance.

    -- Currently executing batches, with text and wait info
    SELECT dm_tran_locks.request_session_id,
           DB_NAME(dm_tran_locks.resource_database_id) AS dbname,
               WHEN resource_type = 'OBJECT'
                   THEN OBJECT_NAME(dm_tran_locks.resource_associated_entity_id)
               ELSE OBJECT_NAME(partitions.OBJECT_ID)
           END AS ObjectName,
           indexes.name AS index_name,
    FROM sys.dm_tran_locks
    LEFT JOIN sys.partitions ON partitions.hobt_id = dm_tran_locks.resource_associated_entity_id
    LEFT JOIN sys.indexes ON indexes.OBJECT_ID = partitions.OBJECT_ID AND indexes.index_id = partitions.index_id
    WHERE resource_associated_entity_id > 0
      AND resource_database_id = DB_ID()
    ORDER BY request_session_id, resource_associated_entity_id 

  6. Thoughts about Qt 5

    I’m working as a windows developer for the most part of my carrier. I started as a PHP developer and I like linux (especially command line). Recenlty we were making our middleware system to work on Mono to be able to run it on Raspberry Pi and similar low price devices. So I had a chance to play with Linux again. It’s was fun so I decided to do some reading on cross platform development. I did a brief reading on Qt and liked it. Then I found very nice book on Qt5 and QML. I really encoredge you to do at least a brief reading of it. It’s worth to mention that porting our .NET system to Mono wasn’t a painfull process at all. But still now we have 2 support two different platforms .NET & Mono. There some difference on how Mono executes our code. In the same time Qt will execute your code just the same on any plaform. It’s really neat advantage. So it’s very good idea to have Qt5 in a toolbox while choosing architecture for an upcoming project. …

  7. Javascript Unit Tests on Team Foundation Service with Chutzpah

    I was helping my peer developer to setup TFS Build to run Jasmine tests. Thanks to Visual Studio & TFS teams it’s really easy to do since TFS 2012! (I configured TFS Build to run Machine.Specification couple of years ago) We were using the Javascript Unit Tests on Team Foundation Service with Chutzpah guide. It’s very nice and straightforward article. The only thing I don’t like about it is that it needs to set Copy to Output Directory on each test file. Instead of that we added the following Post-build script, so we don’t need to set Copy to Output Directory on each test file.

    for /R $(ProjectDir) %%G IN (*.test.js) DO copy "%%G" $(TargetDir)
    Hope it helps! …

  8. Dependency Injection in .NET. Seemann Mark.

    Recently I had a chat with a peer developer about IT books. I recommended him a great Seemann Mark’s book Dependency Injection in .NET. After that I realized that I never blogged about it! I’d say that in my opinion this is an Must Read book for .NET software developers. At first I was a bit surprised that it’s a 500+ pages book about one pattern, but it’s really worth it. First chapters are an amazing explanation of the Dependency Injection and Inversion of Control patterns. Last chapters dives in details of some popular DI containers. Unfortunately it doesn’t contain a chapter about Ninject which is my favorite DI container, but there are tons of information about it on the Internet. Service Locator is anti-pattern? I was very excited that he lists Service Locator as a DI anti-pattern! We were using Service Locator on a big WPF application couple of years ago. After some time I released that it’s not an ideal choice. Seemann Mark stated the following issues with Service Locator pattern:

    • The module drags along a redundant Dependency
    • It isn't apparent that DI is being used
    I’d like to just add that it’s way easier to read the code if you can see all the dependencies just by looking at the class constructor. Also it’s easier to test such code because you don’t need to configure Service Locator to use Mocks. All you need is just pass the objects you want. In some cases it would be real implementation, in others it would be mock, test double, etc. So even if you aren’t .NET developer I still suppose it makes sense to read first chapters of this amazing book. Highly recommend! …

  9. Mono 3.2.7 is working on a Raspberry Pi running Raspbian (hard float)!

    We were planning to port our application into Mono to give it a try on a Raspberry Pi for a quite a while. What’s interesting now, then we finally started to do this, Alex Rønne Petersen added a hard float support to Mono! I was able to build his armhf branch directly on my Raspberry Pi. So now I’m all set to port our application! Thanks to Alex! Thanks to the Mono team! :) …

  10. Stop your console app the nice way

    This would be obvious for someone. Posting it just in case :)

        class Program
            private static readonly AutoResetEvent AutoResetEvent = new AutoResetEvent(false);
            static void Main(string[] args)
                Console.CancelKeyPress += OnCancelKeyPress;
                //TODO: do work here
                //TODO: shutdown here
            private static void OnCancelKeyPress(object sender, ConsoleCancelEventArgs e)
                e.Cancel = true;