Note that there are some explanatory texts on larger screens.

plurals
  1. PONServiceBus Host that Subscribes to his own Published Messages
    primarykey
    data
    text
    <p>Used Version of NServiceBus: 2.0.0.1145</p> <h2>Question:</h2> <p>Is it possible to configure a NServiceBus Host in such a way that, it consumes (subcribes to) his own published messages?</p> <h2>Answer:</h2> <p>It seems possible, but in the following Configuration it gives me a Transaction deadlocked Exception while trying to insert Subscriptions into the SubscriptionStorage. It happens when you use DbSubscriptionStorage and more than 1 "NumberOfWorkerThreads".</p> <h2>Error:</h2> <p><code>Could not execute command:<br> INSERT INTO Subscription (SubscriberEndpoint, MessageType) VALUES (@p0, @p1)<br> System.Data.SqlClinet.SqlException:<br> Transaction was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.</code></p> <p>After that NServiceBus tries to disconnect but fails because there is a transaction still in progress and throws an UnhandledException.</p> <h1>How to reproduce:</h1> <h3>Here is my App.Config:</h3> <pre><code>&lt;!-- Publishing Configuration --&gt; &lt;MsmqTransportConfig InputQueue="test_publisher_output" ErrorQueue="test_error" NumberOfWorkerThreads="3" MaxRetries="5" /&gt; &lt;!-- Subscription Configuration --&gt; &lt;UnicastBusConfig DistributorControlAddress="" DistributorDataAddress="" ForwardReceivedMessagesTo=""&gt; &lt;MessageEndpointMappings&gt; &lt;add Messages="MessageAssembly" Endpoint="test_publisher_output" /&gt; &lt;/MessageEndpointMappings&gt; &lt;/UnicastBusConfig&gt; </code></pre> <h3>My Bus-Configuration:</h3> <pre><code>var bus = Configure.With() .Log4Net() .StructureMapBuilder(container) .XmlSerializer() .MsmqTransport() .IsTransactional(true) .PurgeOnStartup(false) .DBSubcriptionStorage(subscriptionDbProperties, true) .Sagas() .NHibernateSagaPersister(sagaDbProperties, true) .UnicastBus() .ImpersonateSender(false) .LoadMessageHandlers(First&lt;GridInterceptingMessageHandler&gt; .Then&lt;SagaMessageHandler&gt;()) .CreateBus() .Start(); </code></pre> <p>and here are my dbProperties for both the subscription and the saga db:</p> <pre><code>connection.provider NHibernate.Connection.DriverConnectionProvider connection.driver_class NHibernate.Driver.SqlClientDriver dialect NHibernate.Dialect.MsSql2005Dialect </code></pre> <p>Everything works fine as long as i don't increase the NumberOfWorkerThreads above 1. Everything higher than that and it will throw the above stated errors.</p> <p>I hope i haven't forgotten anything. Thanks for your help in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload