This is part of the NServiceBus Upgrade Guide from Version 6 to 7, which also includes the following individual upgrade guides for specific components:
- Migrating Msmq subscription messages
- Azure Storage Queues Transport Upgrade Version 7 to 8
- RabbitMQ Transport Upgrade Version 4 to 5
- SQL Server Transport Upgrade Version 3 to 4
- Upgrade from Azure Storage persistence Version 1 to Version 2
- NHibernate Persistence Upgrade Version 8.0 to 8.1
- RavenDB Persistence Upgrade from 4 to 5
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 with the NServiceBus.Transport.Msmq NuGet package and is copied to a subfolder called
NServiceBus. in the output folder of any project referencing it. Browse to the output 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.