May 30, 2008, 9:09 pm
I have an Ubuntu server that I use a file server for imaging my other machines. After upgrading, networking no longer seemed to work. I also kept getting an error when trying to run sudo:
unable to resolve host mymachinename
After a bit of searching, I landed on this bug which apparently has affected a number of people:
https://bugs.launchpad.net/ubuntu/+source/linux-meta/+bug/195308
Using ‘gksu gedit’ and fixing /etc/hosts solved my problem. To get Internet connectivity back, I had to disable IPv6:
https://help.ubuntu.com/community/WebBrowsingSlowIPv6IPv4
May 22, 2008, 10:09 pm
I’ve been spending some time working with NServiceBus lately as we are looking for an open source publish/subscribe framework written in .NET. I like what I have seen so far, although I think that the development model could be a little simpler. My biggest gripe is that messages have to implement an IMessage interface and there is no mechanism for supporting headers on message envelopes. That aside, Udi’s responsiveness (and politeness) to everyone who posts on the NServiceBus forum is refreshing and he seems to listen to people who make good suggestions.
A discussion came up on the list about implementing a retry strategy for when a message handler fails to execute (maybe a database is down for instance). The nice thing about NServiceBus is that adding something like this is just a matter of doing some simple programming. No worries implementing of custom behaviors or adding XML required.
My simple solution (which is just some prototype code):
1: public interface IReplayableMessage : IMessage
2: {
3: int RetryCount { get; set; }
4: DateTime LastReplayAttempt { get; set; }
5: }
6:
7: public abstract class RetryMessageHandler<TMessage> : IMessageHandler<TMessage>
8: where TMessage : IReplayableMessage
9: {
10:
11: public IBus Bus { get; set; }
12:
13: public void HandleMessage(TMessage message)
14: {
15: if (DateTime.Now - message.LastReplayAttempt < 5.Seconds())
16: {
17: Bus.HandleMessageLater();
18: return;
19: }
20: try
21: {
22: HandleMessageInternal(message);
23: }
24: catch (Exception e)
25: {
26: if (message.RetryCount < 5)
27: {
28: message.RetryCount = message.RetryCount++;
29: message.LastReplayAttempt = DateTime.Now;
30: Bus.Send(message);
31: }
32: else
33: {
34: ..log error and move to dead letter queue..
35: }
36: }
37: }
38:
39: public abstract void HandleMessageInternal(TMessage message);
40:
41: }
This is just some simple prototype code, but as you can see, NServiceBus handlers are easy to write and test. For a more complicated implementation, Apache Camel has an implementation of the dead letter channel pattern to get some ideas from. It keeps the message in memory while trying to retry and sleeps while waiting to reprocess. The example I gave sends the message back to the end of the queue.
Category:
.NET |
Comments Off