Closed nour-s closed 10 years ago
Hi Nour
That sounds correct. Do you have the NServiceBus configuration hook in place? e.g.
Configure.With()
.Log4Net()
.DefaultBuilder()
.JsonSerializer()
.NES(); // This line
Also if this is happening too late you can configure NServiceBus before you configure NEventStore.
Hi, Actually my NServiceBus configuration is a bit different:
Configure.Transactions.Advanced(t => t.DefaultTimeout(new TimeSpan(0, 5, 0)));
Configure.Serialization.Json();
Configure.With()
.Log4Net()
.UnityBuilder(container)
.UseTransport<Msmq>()
.UnicastBus()
.LoadMessageHandlers()
.NES();
And this is my NES configuration:
Wireup.Init()
.UsingSqlPersistence("EventStoreDB")
.WithDialect(new MsSqlDialect())
.InitializeStorageEngine()
.NES()
.UsingJsonSerialization()
.Build();
However, I tried to configure NServiceBus before NES, but same error with the same stack trace occurred. Is it a bug? or I'm missing something?
Thanks Nour, it sounds like a bug. Configuration of the commit dispatcher needs to be delayed until the bus has been started for un-dispatched events. I'll let you know asap when there's a fix.
It is my pleasure, Is there a quick work-around? or at least a clue?
Yeah this should work -
public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization, IWantToRunWhenBusStartsAndStops
{
public void Init()
{
Configure.Transactions.Advanced(t => t.DefaultTimeout(new TimeSpan(0, 5, 0)));
Configure.Serialization.Json();
Configure.With()
.Log4Net()
.UnityBuilder(container)
.UseTransport<Msmq>()
.UnicastBus()
.LoadMessageHandlers()
.NES();
}
public void Start()
{
Wireup.Init()
.UsingSqlPersistence("EventStoreDB")
.WithDialect(new MsSqlDialect())
.InitializeStorageEngine()
.NES()
.UsingJsonSerialization()
.Build();
}
public void Stop()
{
}
}
After looking through the latest NServiceBus source the above workaround actually looks like the recommended way of configuring services that depend on the bus. I'll also update the NES sample project with the same approach.
Doh! I spent the last few hours trying to figure out why NEventStore was throwing a null reference error! Moving Wireup to Start() fixed it right away
@elliotritchie The approach you mentioned works fine for me, shall we close the issue?
Hello, I'm getting (Object reference not set to an instance of an object). exception when there are un-dispatched commits in database, The error is because _eventPublisherFactory() failed to resolve the (IEventPublisher) interface, which I believe is because the start-up process is not yet completed and the interface is not registered yet,
Here is the stack trace: