Azure Service Bus MQ first few handled messages fail with NullReferenceException

When there are messages on the Azure Service Bus MQ before my app starts, the first few handled messages end up on the DLQ due to a NRE. This is coming from ServiceStack.ServiceStackHost.d__310.MoveNext()

I presume this is because the SS app is not fully initialised when the MQ handlers start to receive messages. I’m starting the queue at the end of my Configure method.

I have an repo for this issue that just needs a Azure Service Bus connection string to run. This result is a msg on the DLQ.

I have resolved this by manually called PopulateArrayFilters before mqServer.Start() but I don’t know if this is a hack or the correct fix.

I really need a place (or need to know the place) where I can start the MQ server knowing the app is in a state where is can handle them.

You can register a callback in your AppHosts AfterInitCallbacks which gets called after the AppHost has initialised.

1 Like

@mythz Cheers that’s perfect.