Question

We are currently thinking about moving one of our applications from rhino-esb to rebus. Our reasoning behind this is that rhino-esb is pretty much inactive these days.

Today we depend on structuremap to use a nested container per message, and we'd like to keep it that way so we don't need to change a big part of our infrastructure. I've looked through the rebus api a bit, but haven't found a good way of handling nested containers. Does anyone have any suggestions on how to solve it? Or maybe you've implemented it yourself?

Was it helpful?

Solution

Well - I'm not a StructureMap dude myself, and I must admit that I've never tried to make Rebus work with nested containers/child containers.

But I would think that you could make it work if you implement a handler activator and a unit of work manager yourself, which you can enable like this:

Configure.With(yourHandlerActivator)
    .Events(e => e.AddUnitOfWorkManager(yourUnitOfWorkManager)
    .(...)

and then you can use that unit of work manager to create a child container that you stash in the message context like this:

MessageContext.GetCurrent().Items["some-key"] = yourChildContainer;

which you then fetch & use in your handler activator when the time comes to resolve the handlers.

The child container can then be disposed when the unit of work is over, thus releasing stuff properly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top