-
-
Save amarwadi/a887b26e14b0d42191b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var system = ActorSystem.Create("example123", config)) | |
{ | |
MongoDbPersistence.Instance.Apply(system); | |
var pActor = system.ActorOf(Props.Create<SectionActor>(), "section-actor"); | |
pActor.Tell(new CheckSeatMessage("1", "1", new List<string> {"A", "B"})); | |
Console.ReadLine(); | |
} | |
public class SectionActor : PersistentActor | |
{ | |
public SectionActor() | |
{ | |
} | |
protected override bool ReceiveRecover(object message) | |
{ | |
//throw new NotImplementedException(); | |
if (message is SnapshotOffer) | |
{ | |
var snap = ((SnapshotOffer) message).Snapshot; | |
} | |
return true; | |
} | |
protected override bool ReceiveCommand(object message) | |
{ | |
try | |
{ | |
PatternMatch.Match(message) | |
.With<CheckSeatMessage>(CheckIfSeatsAvailable); | |
} | |
catch (Exception ex) | |
{ | |
} | |
return true; | |
} | |
private void CheckIfSeatsAvailable(CheckSeatMessage message) | |
{ | |
Console.WriteLine("Checking for seats."); | |
Persist(message, PersistCheckSeatsMessage); | |
} | |
private void PersistCheckSeatsMessage(CheckSeatMessage obj) | |
{ | |
Console.WriteLine("Persisted"); | |
} | |
public override string PersistenceId => "SectionActor"; | |
} | |
public class CheckSeatMessage | |
{ | |
public List<string> SeatKeys { get; set; } | |
public string RowKey { get; set; } | |
public string SectionKey { get; set; } | |
public CheckSeatMessage(string sectionKey, string rowKey, List<string> seatKeys) | |
{ | |
SeatKeys = seatKeys; | |
RowKey = rowKey; | |
SectionKey = sectionKey; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment