Marcos Placona Blog

Programming, technology and the taming of the web.

Month: July 2012

Enterprise queuing applications

Reading time: 2 – 4 minutes

At work, we’ve decided to start using enterprise queuing applications for ease of communication between our ColdFusion and .Net projects.

For those who don’t know how queues work, if I had to summarize it I would say it’s like a database that stores all the messages sent from diverse systems (even in different clusters), and awaits until a consumer (queue subscriber)  picks them up.

Queues accept pretty much any kind of string you throw at them, so you could for example give it JSON or XML if you wanted to store anything a bit more complex than an ID for example.

You then write specific consumers that only listen to certain queues, and once they have received and acknowledged the message, they then move on to pick up the next item in the queue.

The queues we will be seeing in this post are FIFO type queues, which means the first item you chuck into the queue, will be theoretically the first to come out. I say “theoretically” because you could tinker with this and prioritise the order your queue serves stuff.

A simple queue with multiple consumers could be represented the following way:

Queue with two consumers

What is important to notice here, is that items will be picked up on a round-robin fashion, meaning no one item could be picked up by two consumers, and no one consumer would be “greedy” and pick up more items than the others.

To illustrate this, I will use an email queue as an example. So image the following scenario:

  • You have an emailing system, and all it does is… well send emails.
  • Your online store sends a confirmation email to every client after they have purchased an item. And this step is important, as it provides the customer with information about their purchase.
  • Your application does not need to know it sends emails, therefore all it needs to do is say: “Hey, someone’s made an order and I’ve processed it”

What the last point it trying to say, is that an application doesn’t necessarily need to have things that aren’t related to its main purpose (selling products in this case). Obviously this solution won’t be suitable for every single case, but in a similar occasion, it came to be really suitable at the company I currently work for.

Continue reading

Upgrading Castle from 2.1 to 2.5

Reading time: 2 – 3 minutes

I was recently working on a .Net project that uses Castle as it’s IoC Container. At some point I realized it would be beneficial to have Castle running on its latest version, so I could benefit of the new functionalities. More specifically I was hoping to be able to use Startable Facility in order to get the objects to be started as soon as they are loaded.

The post linked above does describe how you can accomplish the same on older versions, but I thought it would be a nice touch to actually get the library updated, since we could potentially benefit of bug fixes and improvements.

The first thing I tried was to simply drop all of Castle’s dlls, and replace them with the new ones. At that point I had about 170 compiling errors, and most of them looked like this:

Error 6 The type or namespace name ‘DictionaryComponent’ could not be found (are you missing a using directive or an assembly reference?)


Error 64 The type or namespace name ‘DictionaryKey’ could not be found (are you missing a using directive or an assembly reference?)


Error 27 The type or namespace name ‘DictionaryKeyAttribute’ could not be found (are you missing a using directive or an assembly reference?)

For starters, DictionaryAdapter.dll was now part of the Core dll, so it now comes bundled with it when you add Castle.Core.dll into the references of your project.

I then had DictionaryComponentDictionaryKey and DictionaryKeyAttributeerror’ing. That is because when the library’s author moved DictionaryAdapter.dll into Castle.Core.dll, he also renamed the methods to be ComponentAttribute, KeyKeyAttribute. It could have been just me, but I haven’t seen any mention on this on the release notes. And while it makes sense that they get renamed, I would rather have not had to find out the hard way.

Another thing I had to do, was change all of my container registration to use “container_name”.Register. Although this doesn’t error, the author recommends you initialize them this way for future compatibility.

I’ve not been able to find anything about this kind of upgrade, so I reckon either I’ve gone wrong somewhere, or no one has actually tried to upgrade from castle 2.1 to Castle 2.5.

Hope that helps someone then.