When using Msmq Subscription storage in NServiceBus Versions 5.x and Versions 6.x, when a subscription queue is not configured, the subscription storage queue automatically defaulted to
NServiceBus.. However, as this queue name was not endpoint specific, endpoints deployed to the same server could potentially share the same subscriptions queue which is undesirable.
To rectify this, starting from Versions 1.0 and above of NServiceBus.Transport.Msmq, if a queue called
NServiceBus. is detected, an exception will be thrown to prevent potential loss of messages.
To move messages from the
NServiceBus. queue to the new queue, refer to the instructions outlined below.
Create a transactional queue called [EndpointName].Subscriptions and substitute the actual name of the endpoint. This can be done by using the PowerShell scripts, Windows MMC Snap-in or other tools like QueueExplorer. If creating queues manually using UI tools, ensure that the queues are marked, "transactional".
CreateQueue function that's part of
CreateQueues.. This PowerShell script comes packaged with the NServiceBus.Transport.Msmq NuGet package. Browse to the lib folder to locate the scripts, for example,
- Load the
CreateQueues.PowerShell script and run the
CreateQueuefunction as shown below:
# CreateQueue -QueueName "EndpointName.Subscriptions" -Account $env:USERNAME
Once the new queue is created, use a tool like QueueExplorer to locate the messages in the
NServiceBus. queue and move them to the newly created subscriptions queue. If the
NServiceBus.queue was being shared among multiple endpoints, select only the messages intended for the endpoint that is being upgraded to NServiceBus.Transport.Msmq package. Identify which messages need to be moved by inspecting the message body and looking for the event information and also by inspecting the subscriber queue name in the
Select the identified messages first on the right-hand pane and then right click to select the
Cut option. Now select the newly created subscriptions queue by clicking on the name of the queue. Right click on the messages pane and select the
Paste option to move the messages.
Once all the subscription messages have been moved, delete the
NServiceBus.queue. QueueExplorer can also be used to copy messages, if a copy of the same subscription message needs to be added to more subscription queues.