Facing issue while upgrading NServiceBus 5.x to 6.x


(Chetan Agrawal) #1

Hi,

I am upgrading my NServiceBus 5.2.5 to NServiceBus 6.4.0.

I am getting the error at mapper section.
An error occurred creating the configuration section handler for AzureSagaPersisterConfig: Could not load file or assembly ‘NServiceBus.Azure’ or one of its dependencies. The system cannot find the file specified.

Below are my code details.
EndPointConfig

public void Customize(EndpointConfiguration configuration)
        {
            string storageConnectionString = ConfigurationManager.AppSettings["StorageConnectionString"];
            string sourceQueue = ConfigurationManager.AppSettings["DCKissImageNSBEndPoint"];
            configuration.DefineEndpointName(sourceQueue);
            configuration.Conventions().DefiningCommandsAs(type => type.GetCustomAttributes(true).Any(t => t.GetType().Name == "CommandAttribute"));
            var persistence = configuration.UsePersistence<AzureStoragePersistence>();
            persistence.ConnectionString(storageConnectionString);
            configuration.UsePersistence<AzureStoragePersistence, StorageType.Sagas>();
            configuration.UsePersistence<AzureStoragePersistence, StorageType.Timeouts>();
            configuration.UseSerialization<JsonSerializer>();
        }

Saga Code

public class InventoryImageImportSaga : Saga<InventoryImageSagaData>,
                                        IAmStartedByMessages<StartImportInventoryImagesMessage>,
                                        IHandleMessages<UploadImageMessage>,
                                        IHandleMessages<CancelImageUploadProcessMessage>
    {
        static ILog log = LogManager.GetLogger<InventoryImageImportSaga>();
        protected override void ConfigureHowToFindSaga(SagaPropertyMapper<InventoryImageSagaData> mapper)
        {
            mapper.ConfigureMapping<StartImportInventoryImagesMessage>(m => m.InventoryId).ToSaga(s => s.InventorySagaId);
            mapper.ConfigureMapping<UploadImageMessage>(message => $"{message.InventoryId}_{message.SecondaryKey}")
               .ToSaga(sagaData => sagaData.InventorySagaId);
        }

        public Task Handle(StartImportInventoryImagesMessage message, IMessageHandlerContext context)
        {
            var secondaryKey = Guid.NewGuid().ToString();
            string DCImages = Newtonsoft.Json.JsonConvert.SerializeObject(message.DCImages);
            var inventoryImageSagaData = new InventoryImageSagaData
            {
                CompanyId = message.CompanyId,
                InventorySagaId = message.InventoryId + "_" + secondaryKey,
            };
            return RequestTimeout(context, TimeSpan.FromSeconds(5), inventoryImageSagaData);
        }

        public Task Handle(UploadImageMessage message, IMessageHandlerContext context)
        {
            log.Info($"Received CancelImageUploadProcessMessage message for InventoryId = '{Data.InventorySagaId}'");
            // code to handle order completion
            return Task.CompletedTask;
        }

        public Task Handle(CancelImageUploadProcessMessage message, IMessageHandlerContext context)
        {
            log.Info($"Received CancelImageUploadProcessMessage message for InventoryId = '{Data.InventorySagaId}'");
            log.Info("Marking as completed");
            MarkAsComplete();
            return Task.CompletedTask;
        }
    }

Packages


(Sean Feldman) #2

Hi Chetan,

With NServiceBus version 6 and above, Azure Storage Persistence has moved to a new package, NServiceBus.Persistence.AzureStorage and is not longer provided by NServiceBus.Azure. XML based configuration has been converted to code based configuration. You can find more details on the upgrade steps in the upgrade documentation here.

Thank you,
Sean Feldman