Archive

Archive for the ‘SOA’ Category

Windows Service Bus Setup Guide

September 30, 2014 Leave a comment

In this post I am going to show you step by step installation of Windows Service Bus on a Windows 8.Windows Service Bus is the On-Premise version of Azure Service Bus and it is a nice way for companies to start using the on premise service bus specially in Australia where the Azure Data Center is still not available.I think it will also benefits businesses to see the potential of the service bus in terms of integration and they can start planning their systems for the cloud.This will make their system migration more manageable and less risky.

The good thing from a developer point of view is that with this setup guide you can do a quick proof of concept without having full-blown Windows Server 2012 and SQL Server and start showing its capability for building up an Enterprise Service Bus.

So lets first start with installing SQL 2012 Express and you can download a copy from here. Just run the installer and select all the features to be installed as shown below.

SQL Server all features

For all of my development work I prefer to have mixed mode authentication for SQL Server and in the wizard select the mixed mode authentication and continue with rest of the installation steps.If everything goes smoothly you will see the SQL Server installation is complete.

SQL Server successfully installed

Before we can start installing the windows service bus make sure you have Web Platform Installer (WPI) on your machine and I know if you are doing any .NET development you probably have it.Search for Service Bus from WPI search and you will see the following results.

search for service bus

Select the first and third option i.e. "Windows Azure Pack:Service Bus 1.1" and the update associated with this pack and follow the installation as shown below.

search for service bus

search for service bus

search for service bus

search for service bus

Now through your Windows Search look for "Service Bus" and you should be able to see two results as shown below.

Select Create a New Farm and continue.

search for service bus

It will show you the SQL Server instance running on your machine and click to test whether the connection to the database server is working or not.

Along with the "Service Bus Configuration" you also get "Service Bus Powershell" so lets open up the Service Bus Powershell and type in the following command.

PS C:\Program Files\Service Bus\1.1> Get-SBClientConfiguration

This will give you the connection string to your service bus and you are good to go. So now you have a service bus environment up and running on your developer machine.

Please follow my Azure Service Bus post to see how we can send and receive messages from the service bus and how to use the "Service Bus Explorer".

That is all for today folks.

Advertisements

NServiceBus: The Magic of Generic Host

April 29, 2012 2 comments

I have done a few posts on NServiceBus and have talked in great details about how it works with messages and MSMQ. However I haven’t talked much about the Generic Host and today’s post is just about that.And hope you will find quite amazing and valuable for your SOA development.

As you had seen in my previous post that it is a means to host your NServiceBus application, whether it’s the client sending a message to the bus or the server reading the message from the queue they both are assemblies and are hosted in this executable called the “Generic Host Process” for NServiceBusIt is this host which takes of wiring up messages, handler and endpoints to MSMQ etc.

When we run the generic host using command line we can see some interesting options as shown below.

NServiceBus Generic Host options

This means that you can configure any message endpoint as a Windows Service and Generic host will take care of installation. You don’t have to do a windows service host application, installer etc. All the plumbing and hard work is taken care by the generic host and you have to focus on writing your messages,message handlers and endpoints.

Let’s try installing the server component in the Full-Duplex sample as a windows service.

Installing NServiceBus component as a windows service

The Command Line:

NServiceBus.Host.exe /install /serviceName:MyServer.dll
/displayName:"My Super Duper service"
/description:"My server installed by NService Magic"

As you can see the command line is very self-explanatory, we have an assembly called MyServer.dll which implements a handler of a specific type and we want it’s display name to be My Super Duper Service and the description to be My server installed by NService Magic.

Lets verify this by opening the Windows Service Management Console and we can see our NServiceBus Server component installed as a windows service. When i did this for the first time it was not less than a magic.

Viewing service in windows services management console

To test whether it is doing what it is supposed to do I am going to run the Client only project from Visual Studio and our message gets picked by the windows service and our handler processes it successfully.

That’s it for now and I hope you guys will find a lot of value in using NServiceBus 🙂

NServiceBus Integration Pattern – Part 2

April 16, 2012 1 comment

Continuing with my previous post on NServiceBus in this part I am going to implement what we had discuss about integration and how NServiceBus can be used. Based on the previous architecture diagram I am doing to drill into component architecture and for easy illustration I am going to use the FullDuplex example which is part of the samples provided by NServiceBus.

NServiceBus Component Architecture

And let’s see how it looks from the visual studio.

NServiceBus VS Solution Explorer

And when we look into the project properties you can see that the project type is an output library and it is configured to run with an external program which is the NServiceBus.Host.exe.

NServiceBus VS Solution Explorer

So let’s run a typical failover / offline scenario and run the client application in isolation

Running client with out the server

and as you can see in the above diagram that the client can send messages even if the server is not running.

Let’s run the server application with debugging and mimic as if there is a failure. For example the finance system is down, exchange server in unavailable or any system to system integration failure. So in this scenario when we run the server application we see this exception thrown and seen like this in the console window.

NServiceBus exception

Interesting thing is that if you have a break point in the server application set correctly you will see that the code gets retried 5 times before the exception is shown in the console.
This happens due to the fact that the server application is configured to use transactional queues and in the config file it has been configured to retry 5 times.

Upon close inspection of error queue this is what it looks like

NServiceBus error queue

And when we click to open the message you will see this is how the message looks like.

Detailed error message

Next thing we have to do is fix the problem and whether the problem was due to hardware, software infrastructure failures let’s pretend those problems are resolved. So now what we have to do is put the message(s) back into where they belong and run our server component and there is exactly a tool called “ReturnedToSourceQueue” in the tools folder.Let’s run the tool.

Return to Source queue

This first thing you have to enter is the name of your error queue and after that you can specify a specific message with the Guid or all of it. For demonstration sake I’ll specify the keyword ‘all’ and you will see the message gets disappeared from the error queue and reappears in the server input queue.

Returning all message to their source queue
and the message reappears in the input queue.
message back to its source queue

And now when we run our server component you will see the message gets processed.

Message processed successfully

As you can see we can fine tune and design these components to integrated different integration points and have that failover/durability scenario taken care by NServiceBus, we can take the message and transform into different type and let the handler of the new type take care of it.

For example our FinanceMessageHandler talks to the Finance system and processes the order if it fails to do so the order remains in the error. We don’t have to hack into some database or ask user to reenter the order. As soon as we resolved the Finance system failure/downtime the message will be processed successfully.On succesfully processing of this business process we can transform the message into an Email message and puts it into EmailQueue.

Now our EmailMessageHandler picks up the message and tries to process and if it encounters any problem with the mail server the message gets routed to the error queue that’s it. This is like creating a messaging eco-system where each system talks to each other in terms of a message and we are building this orchestration.This is what I meant by “Pass the Parcel (message)” pattern in my previous post.

That’s it for now and in my next post I am going to talk about the Generic host and what wonders it can create for your enterprise.