Multiple EndpointInstances with NinjectBuilder fails with "Error activating IObjectBuilderPropertyHeuristic"

nservicebus

(Jeremy M) #1

Hello!

We’re trying to host more than 1 Endpoint using TopShelf 4 and Ninject 3.3.4. The EndpointConfiguration fails when assigning an existing kernel more than once. We are using NServiceBus v6.

Error activating IObjectBuilderPropertyHeuristic
More than one matching bindings are available.
Matching bindings:

  1. binding from IObjectBuilderPropertyHeuristic to ObjectBuilderPropertyHeuristic
  2. binding from IObjectBuilderPropertyHeuristic to ObjectBuilderPropertyHeuristic
    Activation path:
  3. Request for IObjectBuilderPropertyHeuristic
    Suggestions:
  4. Ensure that you have defined a binding for IObjectBuilderPropertyHeuristic only once

Any insights on this is appreciated!

Thanks - Jeremy


(Tim Bussmann) #2

Hey @jrmy

Multiple NServiceBus endpoints cannot share the same container directly. This doesn’t work as every Endpoint registers instances with the container and the two different endpoints cannot distinguish these instances between each other.

I’d recommend to use a dedicated ninject container for every endpoint and register shared dependencies on each of the containers instead.


(Ramon Smits) #3

In my experience it does work, just make sure that you create a child container for each NServiceBus endpoint instance which is then passed into the NServiceBus configuration but potentially it doesn’t work with every object builder implementation.


(Jeremy M) #4

This is what we ended up doing to resolve the issue. We borrowed the ChildKernel implementation from the Ninject Extension and multiple endpoints are able to share the master/root/parent container.

Thanks for the replies.


Troubleshooting Saga Persistence
(Jeremy M) #5

This did get us further but we seemed to have uncovered another issue related to this that was awfully difficult to track down. A summary can be found in this thread.


(Ramon Smits) #6

The following repo shows 2 NServiceBus endpoints. Each endpoint has its own childcontainer but share a singleton defined in a parent container:

It is using NServiceBus 6, Ninject, Ninject.Extensions.ChildKernel, Topshelf, and log4net. The endpoints are configure to use RabbitMQ, SQL persistance, Outbox and Ninject for DI.

– Ramon