Mark Lindell
Mark Lindell

Reputation: 852

NServiceBus 2.0 loses first published message when using MsmqSubscriptionStorage

I am using MsmqSubscriptionStorage in a pub/sub scenario and the first message is lost when the subscriptions has not been stored. If I watch the debug messages, while running in the GenericHost, I see that all the subscriptions are setup but the first message is never sent to the subscribers. If more messages are sent, then they are successfully sent to the subscribers (as indicated in the logs)

I am using version 2.0.0.0.

Here is the bus configuration I'm using.

var bus = Configure.With(
    new List<Assembly>
    {
        typeof(Configure).Assembly,
        typeof(IBus).Assembly
    })
    .DefaultBuilder()
    .Log4Net()
    .XmlSerializer()
    .MsmqTransport()
        .IsTransactional(true)
        .PurgeOnStartup(false)
    .UnicastBus()
        .ImpersonateSender(false)
        .LoadMessageHandlers()
    .MsmqSubscriptionStorage()
    .CreateBus()
    .Start();

Upvotes: 0

Views: 302

Answers (2)

Mark Lindell
Mark Lindell

Reputation: 852

I'm answering my own post so no one sees this issue and draws the conclusion that there is something wrong with NServiceBus. This was a GCE - (Gross Conceptual Error) on my part. My hosting environment was deferring resolution of a static reference to the Bus. Changing the initialization of my process to setup the static Bus reference at start up solve the problem.

Upvotes: 1

Adam Fyles
Adam Fyles

Reputation: 6050

If you Publish before any subscription has been registered those messages won't have a destination and will be ignored. You may want to look into the DB subscription storage to have something less transient.

Upvotes: 0

Related Questions