开发者

Very simple Error handling with NServiceBus

hey guys, here's a simple scenario

  • NServiceBus Client/Server setup.
  • The "Message" is a custom Class I wrote.

The Client sends a request message. The Server receives the message, and the server does this:

Bus.Reply(new Use开发者_运维技巧rDataResponseMessage { ID = Guid.NewGuid(), Response = users });

Then nothing. The Client never receives a response.

Exception:

By trawling through the log4net NServiceBus logs I find an exception, and it turns out that my customs class "users" is not marked as Serializable.

Ok, how does one got about "throwing" or "handling" that kind of error?

NServiceBus seems to promote the idea of not handling errors, but in this scenario its obvious to see some kind of "throw" would have saved a lot of time.

How do I handle such exceptions, where do they occur, where do they go?


Hey guys, this is how I resolved the issue:

Essentially, I've learned, you really should "handle" errors in nServiceBus, it's just not designed that way. So, the approach I've gone is is twofold:

  1. UnitTesting - Run tests. nServiceBus has a pretty cool Testing namespace where you can write some tests for the communication parts.
  2. Intelligent logging - In this case, separate your error logs to your other logs. Because nServiceBus uses log4net, it's pretty easy to get some cool logging variations using simple config.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜