RagtimeWilly
RagtimeWilly

Reputation: 5445

Find partition key of stateful service at runtime

I need to find the current partition key of a Service Fabric Stateful Service at run time.

I have looked in the ICodePackageActivationContext and the StatefulServiceContext but can't seem to see this information anywhere.

Edit:

As LoekD pointed out in his answer this information is available from within the StatefulService class. Just to be explicitly clear, here is how I accessed:

var info = (Int64RangePartitionInformation) this.Partition.PartitionInfo;

var highKey = info.HighKey;
var lowKey = info.LowKey;

Upvotes: 2

Views: 191

Answers (1)

LoekD
LoekD

Reputation: 11470

From within the service itself, you can use the Partition.PartitionInfo property.

Upvotes: 2

Related Questions