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 Service Bus Transport (Legacy) Upgrade Version 7 to 8
- Azure Storage Queues Transport Upgrade Version 7 to 8
- RabbitMQ Transport Upgrade Version 4 to 5
- SQL Server Transport Upgrade Version 3 to 4
If a subscription queue is not configurate when using MSMQ subscription storage in NServiceBus versions 5 and 6, the subscription storage queue automatically defaults to
NServiceBus.. However, as this queue name is not endpoint specific, endpoints deployed to the same server could potentially share the same subscriptions queue which is not a good practice.
Therefore, starting from NServiceBus.Transport.Msmq version 1, 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 the subscriptions queue
Create a transactional queue called .Subscriptions, substituting the actual name of the endpoint. This can be done by with PowerShell scripts, Windows MMC Snap-in, or other tools like QueueExplorer. When creating queues manually using other 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
Move the subscription messages
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 is shared among multiple endpoints, select only the messages intended for the endpoint that is being upgraded to the
NServiceBus. package. Identify which messages must be moved by inspecting the message body and looking for the event information and by inspecting the subscriber queue name in the
Select the identified messages in the right-hand pane, then right-click and select
Cut. Now select the newly created subscriptions queue by clicking on the name of the queue. Right-click on the messages pane and select
Paste to move the messages.
Once all the subscription messages have been moved, delete the
NServiceBus.Subscriptionsqueue. QueueExplorer can also be used to copy messages, if a copy of the same subscription message must be added to more subscription queues.