Tuesday, August 13, 2013

How messaging can help your system grow

Lately I’ve been thinking a lot about distributed systems and all the challenges that you’ll have to deal with. I find it very interesting to think about software that isn’t hosted in a single process on a single machine. How do you integrate seamlessly between different parts of a big system that aren’t hosted on the same machine? How does your e-commerce site communicate with the warehouse system that is versioned independently and has a whole other release cycle? What if the warehouse system is down for maintenance, how will the e-commerce site react?

One thing that I’ve found really effective in solving these kind of integration problems is messaging, and in particular events. A event is a message that broadcasts to anyone who’s interested that a certain thing has happened in the particular system. The system publishing the event doesn’t care what you do with it, it only knows that you’re interested in that particular event.

If you have a application that publish events each time anything interesting happens, then it’s very easy to integrate with that system. All you need to do is tell that system you’re interested in a event. Lets say that we have a OrderAccepted event in this case. If you’re a warehouse system listening to the OrderAccepted event you probably want to make sure that the products associated with that order gets sent to the correct address. If you’re some kind of economy system you’re probably interested in the value of the order. What you do when you receive the event doesn’t matter to the e-commerce application. As far as its concerned, the job is done after publishing the OrderAccepted event.

The same goes the other way around of course. When the warehouse system ships the order. It will publish a event, OrderShipped, which the e-commerce system listens to. In this case we probably want to update the status of the order and tell the customer that the order is on it’s way.

When using messaging as our way of integrating systems, we keep the systems separated from each other, and they only have a dependency on the message schema. As long as the schema is the same we can easily version them independently. If we use a persistent messaging infrastructure we can also handle things like applications being down. Lets say our warehouse system is down while the e-commerce application publishes a OrderAccepted event. In this case the e-commerce application will just continue it’s business as usual. When the warehouse system gets back up it will find a bunch of events waiting and process them one by one, the customer won't notice anything.

There are lots of ways to handle system integrations, and there is no silver bullet solution that solves everything. You need to find the best way for your case. The nice thing about messaging is how it keeps your different applications independent of each other while, at the same time, offer a very nice integration point.

Friday, July 19, 2013

Dynamic branch web applications with IIS + Web deploy + Teamcity + Github (SVN also maybe)

We are using a lot of branches. But have had the problem that we can't really let people that aren't not developers test those branches. I did just come up with a solution to this problem. So now for each project we have. We are setting up a web site on our testserver for example : http://test.mynewproject.com. And after that teamcity will build all our branches and publish them like this: http://test.mynewproject.com/[branchname]. So that's very cool if you want to be able to let Testers test your branches before you merge.

I will do a step by step guide here. (this will require that you installed Web Deploy 3 on your IIS Server)

 
  Start with setup a new teamcity project and a build configuration
Start with settings up a new VCS root

Fill out the details needed. But the important part is Branch specification. So teamcity builds all your branches. "+:refs/heads/*" 

Add a build step that looks like this. "%build.file.directory%%build.file.projectname%"

Add the following "Build Parameters" and set so they match your configuration.

That should be it! Hope you can enjoy "dynamic branch test sites"


First time with Ruby

I'm back to school, and this time it's to learn Ruby. It's a distance course and my first lab is as good as done.

What i do like about Ruby is that it's a fully dynamic programming language and i do think it's good to learn now when dynamic starts to get introduced into .NET

This first lab was about doing an easy console application. It had to have a menu, and then you needed to be able to add information into an class and be able to view that information. Nothing hard but new language new syntax.

But here is some getting started info and syntax, i'm going to write some nice syntax that i would love in c#, also try to give an example of same in c#.

In Ruby, to get an array from 1 to 10 you can write
(1..10)
In c# i would write
Enumerable.Range(1, 10);

In Ruby to loop all items in a list i could do
myArray.each do |item| [...] end 
In c#
foreach(var item in myArray){ [...] }

In ruby to loop all with index you could do:
myArray.each_with_index do |item, index| [...] end
In c# i don't know a nice way to do this either using for or declaring an index before. Or maybe my own extension

Creating a class in ruby, can be done by following. the variables will then be public
class MyClass attr_accessor :variable1, :variable2 [...] end
Same in c#
public class MyClass{ public dynamic variable1; public dynamic variable2; }

Another nice thing in Ruby is when creating variables within a method, it can be created anywhere
if(myNewVariable = true)
By this i have declared the variable and it's ready to be used. Might be confusing but still nice.

Another nice thing was
foo = "HI THERE"
foo.downcase!
foo is now "hi there" becouse "!" at the end tells Ruby to set the active variable directly


Thats it for now!
Best regards
Pontus Bremdahl

Friday, August 5, 2011

Love chrome but wtf?

I think that chrome is the best webbrowser out there. But I do have a complaint.

Who in thier right mind came up with the smart feature, an empty src on an html img should load the same page again.

At work we have had problem with this more than ones, and it's really anoying. It gives a very wierd error on some pages, or slows up due that it loads the same source again.

I know it's just not chrome that have had this "feature" but all other browser seems to have had this feature removed.

Back to the feature, loading the same url again when src is empty on an html img.

Why should it, it's not that we are on an image, we are on an html page and when does a html page looks lika an image?

Now chrome team, please remove this feature so we don't have to make some sweat fixes on all pages we are doing.

Wednesday, March 23, 2011

Really easy webdeployment with Appharbor

It’s a cloud service. You create your account on http://www.appharbor.com.

Create a new project in Visual Studio and then push it to a Git Repository given from the appharbor site.

If your new to git and on windows you will need Gitextensions it includes everything you need to get up and running with Git.
When you have installed git. Just locate your project with atleast one .sln file and a web project. And commit them to your local git repository ( right click > Gitextensions > commit ).

When your done with this next up is to push it to Appharbor. So they can build and publish your website in the Azure Cloud.
Right click on your folder > Gitextensions > Push. Here you should add a new remote ( http://[username]@appharbor.com/[myapp].git ) Then if you check the site you will see the status of your build and if it succeeded else you will need to click “show” and it will tell you why it failed. And then you can access your site http://[myapp].apphb.com/ ( You can of course add your own domain also )

This work really like a charm!