Unable setup Azure Table Storage for Sagapersistance

nservicebus
sagas

(Saravanakumar Subramaniam) #1

Hi,

We have create new NSB worker with Saga using 5.x and using Azure table storage for persisting saga data. We have manually created table storage but while executing code we could not see the persistance information in Table Storage. By default it is using InMemoryPersistance, even though code is set as Azure table storage, it is getting disabled at runtime(check below nsb log)

Please find below information.
Are we missing any settings or code? How to configure system to use Azure table storage for persistance and verify saga data is created.?

Table Storage Name:

  • InventoryImageSagaData
  • Subscription
  • TimeoutDataTableName
  • TimeoutManagerDataTable

EndPointConfig

public void Customize(BusConfiguration configuration)
        {
            NServiceBus.Logging.LogManager.Use<NLogFactory>();

            OptimizeForAzure();

            var endPointName = ConfigurationManager.AppSettings["CarzingImageNSBEndPoint"];
            configuration.EndpointName(endPointName);
            configuration.OverrideLocalAddress(endPointName);

            configuration.AssembliesToScan(AllAssemblies.Matching("NServiceBus").And("Carzing.Image.NSBSaga"));
            configuration.DoNotCreateQueues();
            //configuration.Conventions().DefiningCommandsAs(type => type.GetCustomAttributes(true).Any(t => t.GetType().Name == "CommandAttribute"));
            configuration.UseTransport<AzureStorageQueueTransport>();
            var a =  configuration.UsePersistence<NServiceBus.AzureStoragePersistence>();

        }

Handlers:

 class InventoryImageImportSaga : 
        Saga<InventoryImageSagaData>,
        IAmStartedByMessages<StartImportInventoryImagesMessage>,
        IHandleMessages<UploadImageMessage>, 
        IHandleTimeouts<CancelImageUploadProcessMessage>
    {
        protected override void ConfigureHowToFindSaga(SagaPropertyMapper<InventoryImageSagaData> mapper)
        {
            //mapper.ConfigureMapping<StartImportInventoryImagesMessage>(message => $"{message.InventoryId}_{message.SecondaryKey}")
            //   .ToSaga(sagaData => sagaData.InventorySagaId);

            mapper.ConfigureMapping<UploadImageMessage>(message => $"{message.InventoryId}_{message.SecondaryKey}")
                .ToSaga(sagaData => sagaData.InventorySagaId);
        }

        public void Handle(StartImportInventoryImagesMessage message)
        {
            var secondaryKey = Guid.NewGuid().ToString();
            
            //Persist request information to Saga
            //Initialize processing information to Saga 'ImageProcessingInfo'
            //this.Data.Originator = message.DCImages.FirstOrDefault().ImportSource;
            
            this.Data.InventorySagaId = message.InventoryId + "_" + secondaryKey;
            this.Data.UploadUserId = message.UploadUserId;
            this.Data.UploadPassword = message.UploadPassword;
            this.Data.ImportImageUrls = message.ImportImageUrls;
            this.Data.DCImages = message.DCImages;
            //Request Timeout
            RequestTimeout<CancelImageUploadProcessMessage>(TimeSpan.FromMinutes(1));
            //request to upload multiple images. UploadImage

            //var bus = ServiceBusInitialization.GetBusInstance();
            Bus.Send(new UploadImageMessage { InventoryId = message.InventoryId, SecondaryKey = secondaryKey, RetryCount = 3 });
        }

        public void Handle(UploadImageMessage message)
        {
            // logic to compare goes here. 

            
            Console.WriteLine(string.Format("{0} {1}{2}{3}",this.Data.UploadUserId,this.Data.InventorySagaId,this.Data.DCImages,this.Data.ImportImageUrls));
            
        }


        public void Timeout(CancelImageUploadProcessMessage state)
        {
            //read Saga instance and check current image upload process
            MarkAsComplete();
            // Queue message to update DCKiss status . DCInventory Status Update Message. 
        }

NSB Logs file:

Name: AzureDataBusPersistence
Version: 6.2.7
Enabled by Default: No
Status: Disabled
Deactivation reason: Did not meet one of the dependencies: [DataBus]

Name: AzureStorageSagaPersistence
Version: 6.2.7
Enabled by Default: No
Status: Disabled
Deactivation reason: Did not meet one of the dependencies: [Sagas]

Name: AzureStorageSubscriptionPersistence
Version: 6.2.7
Enabled by Default: No
Status: Disabled
Deactivation reason: Did not meet one of the dependencies: [MessageDrivenSubscriptions]

Name: AzureStorageTimeoutPersistence
Version: 6.2.7
Enabled by Default: No
Status: Disabled
Deactivation reason: Did not meet one of the dependencies: [TimeoutManager]

Config:

  AzureSagaPersisterConfig ConnectionString="DefaultEndpointsProtocol=https;AccountName=xyz;AccountKey=abc"  />
  AzureTimeoutPersisterConfig ConnectionString="DefaultEndpointsProtocol=https;AccountName=xyz;AccountKey=abc"  />
  AzureSubscriptionStorageConfig ConnectionString="DefaultEndpointsProtocol=https;AccountName=xyz;AccountKey=abc" />
  <AuditConfig QueueName="dcimg-nsbsaga-worker-audit" />

Package:

  package id="Microsoft.Data.Edm" version="5.7.0" targetFramework="net451" />
  package id="Microsoft.Data.OData" version="5.7.0" targetFramework="net451" />
  package id="Microsoft.Data.Services.Client" version="5.7.0" targetFramework="net451" />
  package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.1.0" targetFramework="net451" />
  package id="Newtonsoft.Json" version="9.0.1" targetFramework="net451" />
  package id="NLog" version="3.2.1" targetFramework="net451" />
  package id="NLog.Extended" version="3.2.1" targetFramework="net451" />
  package id="NLog.Targets.NowGelf" version="1.0.5" targetFramework="net451" />
  package id="NServiceBus" version="5.2.8" targetFramework="net451" />
  package id="NServiceBus.Azure" version="6.2.7" targetFramework="net451" />
  package id="NServiceBus.Azure.Transports.WindowsAzureStorageQueues" version="6.2.1" targetFramework="net451" />
  package id="NServiceBus.Host" version="6.0.0" targetFramework="net451" />
  package id="NServiceBus.NLog" version="1.0.0" targetFramework="net451" />
  package id="System.Spatial" version="5.7.0" targetFramework="net451" />
  package id="WindowsAzure.Storage" version="4.3.0" targetFramework="net451" />

Thanks,


Help needed in implementing AzureStorageSagaPersistence to store data in Azure Storage Table
(Sean Feldman) #2

Duplicate of another issue


(Sean Feldman) #3