0

I have a couple of reliable collections across different stateful services. I need to access one reliable collection from another stateful service (e.g. Employees collection from Department stateful service).

Although the Employees collection is populated with data, when I try to get a reference to the collection

var myDictionary = await this.StateManager.GetOrAddAsync>("employees");

var allEmployees = await mydictionary.CreateEnumerableAsync(tx, EnumerationMode.Unordered)

var enum = allEmployees.GetAsyncEnumerator()

the enumeration count on allEmployees collection returns count of 0.

The same approach works correctly when I try to access the employees in Employee collection in the Employee stateful service.

This doesnt work when I try to access the employees in Employee collection in the Department stateful service.

Is this a correct way to access data across collections? If not what is the correct way?

Upendra
  • 21
  • 2
  • Possible duplicate of [Share queue with two or more stateful services within Service Fabric](https://stackoverflow.com/questions/41207612/share-queue-with-two-or-more-stateful-services-within-service-fabric) – PatrickSteele Feb 18 '18 at 22:58

1 Answers1

1

A stateful service contains it's own state that can be accessed only with that service, it can't be shared with another stateful service. Don't think of it as a database. Each stateful service can contain multiple collections or queues, but that service owns that state. If you want to expose it, create an API using your favorite communication stack and make an API call from the other service.

Todd Abel
  • 429
  • 2
  • 5