4
votes

I'm fairly new to NServiceBus and I've got a question.

I have a WCF service that is my publisher (I know I shouldn't use publish by wcf). I have another WCF service as subscriber.

My problem is that, when second wcf service is going to subscribe to publisher, my publisher doesn't store this information in msmq (when using .MsmqSubscriptionStorage()). But it works when publisher stores subscribers in memory (.InMemorySubscriptionStorage())

How to force my bus to use msmq?

Below I'll give code of publisher and subscriber.

Publisher bus initialization:

Bus = NServiceBus.Configure.WithWeb()
                .DefaultBuilder()
                .XmlSerializer()
                .MsmqTransport()
                .IsTransactional( false )
                .PurgeOnStartup( false )
                .UnicastBus()
                .LoadMessageHandlers()
                .ImpersonateSender( false )
                .MsmqSubscriptionStorage()
                .CreateBus()
                .Start(() => Configure.Instance.ForInstallationOn<NServiceBus.Installation.Environments.Windows>().Install());

Publishers config:

<configSections>
        <section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />
        <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
        <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
    </configSections>
    <MessageForwardingInCaseOfFaultConfig ErrorQueue="error"/>

Subscribers bus init:

Bus = NServiceBus.Configure.WithWeb()
                .DefaultBuilder()
                .XmlSerializer()
                .MsmqTransport()
                .IsTransactional(false)
                .PurgeOnStartup(false)
                .UnicastBus()
                .ImpersonateSender(false)
                .LoadMessageHandlers()
                .CreateBus()
                .Start(() => Confgure.Instance.ForInstallationOn<NServiceBus.Installation.Environments.Windows>().Install());

Subscribers config:

    <configSections>
        <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
        <section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />
        <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
    </configSections>

    <MessageForwardingInCaseOfFaultConfig ErrorQueue="error"/>

    <UnicastBusConfig>
        <MessageEndpointMappings>
            <add Messages="Messages" Endpoint="FirstService" />
        </MessageEndpointMappings>
    </UnicastBusConfig>
1
Ok, I figured out what was wrong... In my publisher I should set .IsTransactional( true ), that fixes problem...mandrive
You should answer your own question then so that people in the future see that there is an answer if they have the same problem, see blog.stackoverflow.com/2012/05/encyclopedia-stack-exchange SO encourages answering your own question.Glenn Slaven

1 Answers

3
votes

I figured out what was wrong. Publisher should be set with .IsTransactional(true) to use MSMQ storage for subscribers.