Skip to main content

Patterns in Windows Azure Service Bus - Recipient List Pattern

I will continue the blog series of post about patterns that can be user with Service Bus of Windows Azure with Recipient List Pattern. Did you ever try to send an email to a list of users? Using Exchange Server is quite simple. We can create a group list and send an email to the specific group list. For example we can have groups of email for different products categories. One can be for TVs, another one for Notebooks and so on. If we create a complex system for a company that have different products that want to send we will need to be able to send notifications about new products that are available. To be able to do something like this we will need a system that permits us to send notifications to a “group” – to a list of subscribers. In a system that is based on messages we will not know the list of subscribers for each group. Because of this we can decorate each message with some meta-information about the groups should receive the message. In Windows Azure, we can implement this pattern using Service Bus Topics. For each message we can add a property to the message that specifies the groups of subscribers that will receive the message. This list of messages can be separate with a comma or any kind of character.
BrokeredMessage message = new BrokeredMessage();
message.Properties.Add(“Groups”,”Review, Test”);
…
Each subscriber will need to create a custom filter. For this purpose we can use the ‘LIKE’ operator of SqlFilter.
TopicClient topicClient = TopicClient.CreateFromConnectionString(
CloudConfigurationManager.GetSetting(
    "ServiceBusConnectionString"),
    "myFooTopic");
SqlFilter sqlFilterReviewGroup = new SqlFilter(“Groups LIKE ‘%Review%’”);
topicClient.AddSubscription(“ReviewSubscription”, sqlFilterReviewGroup);
SqlFilter sqlFilterTestGroup = new SqlFilter(“Groups LIKE ‘%Test%’”);
topicClient.AddSubscription(“ReviewSubscription”, sqlFilterTestGroup);
Even if this solution will work without any kind of problem, we should be aware that we use the “LIKE” operator. From performance perspective we know that this is not the fastest solution. If we don’t have a lot of messages that are send on the wire that this is not a reals issue. For better performance we can find different solutions, from complicated one that use bits to simpler one like adding different property for each group. In this way the subscriber of a filter will only need to check if the property is set or not. For this purpose we can use the “EXISTS” operator or SqlFilter.
SqlFilter sqlFilterReviewGroup = new SqlFilter(“EXISTS Review”);
topicClient.AddSubscription(“ReviewSubscription”, sqlFilterReviewGroup);
If you don’t want to have a lot of properties you can a prime numbers. The only problem with this solution is related to how easy the code can be read and maintain. Each prime number can represent a different group. And a message should be received by a subscription if the group property can be divided to the prime number that represents our group. We could imagine another solutions also.
To be able to use this pattern we need to define the list of recipients. This list can be a static list of can be created dynamically and can be change on runtime. Using Service Bus Topics from Windows Azure the list can be dynamically created and changing the list will not require changing the code that send or receive the messages. All this can be done in the configuration files.
The important thing that we need to remember about Recipient List Pattern is when we need to use it and Windows Azure Service Bus supports an implementation of this pattern.
Last edit: A list of all patterns that can be used with Windows Azure Service Bus, that were described by me LINK.  

Comments

Popular posts from this blog

How to check in AngularJS if a service was register or not

There are cases when you need to check in a service or a controller was register in AngularJS.
For example a valid use case is when you have the same implementation running on multiple application. In this case, you may want to intercept the HTTP provider and add a custom step there. This step don’t needs to run on all the application, only in the one where the service exist and register.
A solution for this case would be to have a flag in the configuration that specify this. In the core you would have an IF that would check the value of this flag.
Another solution is to check if a specific service was register in AngularJS or not. If the service was register that you would execute your own logic.
To check if a service was register or not in AngularJS container you need to call the ‘has’ method of ‘inhector’. It will return TRUE if the service was register.
if ($injector.has('httpInterceptorService')) { $httpProvider.interceptors.push('httpInterceptorService&#…

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine:
threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration:

TeamCity.NET 4.51EF 6.0.2VS2013
It seems that there …

Run native .NET application in Docker (.NET Framework 4.6.2)

Scope
The main scope of this post is to see how we can run a legacy application written in .NET Framework in Docker.

Context
First of all, let’s define what is a legacy application in our context. By a legacy application we understand an application that runs .NET Framework 3.5 or higher in a production environment where we don’t have any more the people or documentation that would help us to understand what is happening behind the scene.
In this scenarios, you might want to migrate the current solution from a standard environment to Docker. There are many advantages for such a migration, like:

Continuous DeploymentTestingIsolationSecurity at container levelVersioning ControlEnvironment Standardization
Until now, we didn’t had the possibility to run a .NET application in Docker. With .NET Core, there was support for .NET Core in Docker, but migration from a full .NET framework to .NET Core can be costly and even impossible. Not only because of lack of features, but also because once you…