14

Anyone using NServiceBus 2.0 successfully with Unity 2.0?

I've tried to compile sources of NServiceBus.ObjectBuilder.Unity.dll against Unity 2.0 assemblies but got several compile-time errors because of changed/deleted signatures of many object methods in new Unity.

In the documentation Udi Dahan says that attaching any container is as easy as implementing 5 methods of IContainer. But when i look into NServiceBus.ObjectBuilder.Unity implementation i see that there is a LOT more work to be done. Why it is so?

shenku
  • 11,969
  • 12
  • 64
  • 118
Dmitry Schetnikovich
  • 1,752
  • 17
  • 26
  • What do you mean with "a LOT more work to be done" (can you be more specific)? The implementation just calls the appropriate Unity methods and returns the created objects according to the semantic of the Interface. – tobsen Mar 23 '11 at 08:14
  • @tobsen When i look to this sources, i don't see simplicity: https://github.com/NServiceBus/NServiceBus/tree/master/src/impl/ObjectBuilder/ObjectBuilder.Unity. Seems that implementor should be aware of internal architecture of NServiceBus. Let me know if i'm wrong... – Dmitry Schetnikovich Mar 24 '11 at 12:31

1 Answers1

3

Unity, by default, behaves different from what NSB expects. That's why there is a need for some custom extensions to make it compatible with ObjectBuilder contract. There are two major differences:

  • Unity requires DependencyAttribute to inject dependency into the property. NSB expects ObjectBuilder to inject in any property that with matching type
  • When doing property injection unity treats property dependencies as mandatory whereas NSB expects them to be optional.

I believe that these features are preserved in version 2.0 and it will be easy to migrate them. I should have some time this week and I hope I will create a Unity v2 implementation. I'll let you know when it's finished.

Edit: Done. The Unit 2 object builder is in the trunk.

Szymon Pobiega
  • 3,358
  • 17
  • 18
  • 1
    Here's the link to the commit: https://github.com/NServiceBus/NServiceBus/commit/324a112229bedd55baaff144eea9a81126a0f343 – Udi Dahan Mar 28 '11 at 13:47
  • 1.2 is still the version deployed on Nuget. Any chance this will be updated? Unity 2.x has been out for a very long time and really should be the default at this point. – Brian Vallelunga Oct 04 '11 at 15:08