简体   繁体   中英

Initializing Service Fabric Actors using DataPackages

I am building a proof of concept application using Azure Service Fabric and would like to initialize a few 'demo' user actors in my cluster when it starts up. I've found a few brief articles that talk about loading data from a DataPackage , which shows how to load the data itself, but nothing about how to create actors from this data.

Can this be done with DataPackages or is there a better way to accomplish this?

Data packages are just opaque directories with whatever files you want in there for each deployment. It doesn't load or process the data itself, you have to do all the heavy lifting as only your code knows what the data means. For example, if you had a data package named "SvcData", it would deploy the files in that package during deployment. If you had a file StaticDataMaster.json in that directory, you'd be able to access it when you service ran (either in your actor, or somewhere else). For example:

// get the data package
var DataPkg = ServiceInitializationParameters.CodePackageActivationContext.
    GetDataPackageObject("SvcData");

// fabric doesn't load data it is just manages for you. data is opaque to Fabric
var customDataFilePath = DataPkg.Path + @"\StaticDataMaster.json";   

// TODO: read customDatafilePath, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM