{"action":"closed","issue":{"url":"https://api.github.com/repos/akkadotnet/akka.net/issues/1035","labels_url":"https://api.github.com/repos/akkadotnet/akka.net/issues/1035/labels{/name}","comments_url":"https://api.github.com/repos/akkadotnet/akka.net/issues/1035/comments","events_url":"https://api.github.com/repos/akkadotnet/akka.net/issues/1035/events","html_url":"https://github.com/akkadotnet/akka.net/issues/1035","id":84320032,"number":1035,"title":"Two phase commit during persisting and raising events","user":{"login":"varghesep","id":12233474,"avatar_url":"https://avatars.githubusercontent.com/u/12233474?v=3","gravatar_id":"","url":"https://api.github.com/users/varghesep","html_url":"https://github.com/varghesep","followers_url":"https://api.github.com/users/varghesep/followers","following_url":"https://api.github.com/users/varghesep/following{/other_user}","gists_url":"https://api.github.com/users/varghesep/gists{/gist_id}","starred_url":"https://api.github.com/users/varghesep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/varghesep/subscriptions","organizations_url":"https://api.github.com/users/varghesep/orgs","repos_url":"https://api.github.com/users/varghesep/repos","events_url":"https://api.github.com/users/varghesep/events{/privacy}","received_events_url":"https://api.github.com/users/varghesep/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-06-03T02:38:44Z","updated_at":"2015-06-27T19:23:10Z","closed_at":"2015-06-27T19:23:10Z","body":"The following code is taken from the file EventSourced.cs. As I understand from this code, the event (for example an event like ProductCostReduced) is persisted first and the handler is called. Take a case where the event is persisted but the handler that sets the state threw an exception. You can also assume the system crashed after the event is persisted. This will cause the event is stored and possibly the particular actor dies?\r\n\r\nMy question is, shouldn't the persistence of the event and the handler action be a transaction so both succeed or fail together? \r\n\r\n        public void Persist<TEvent>(TEvent @event, Action<TEvent> handler)\r\n        {\r\n            _pendingStashingPersistInvocations++;\r\n            _pendingInvocations.AddLast(new StashingHandlerInvocation(@event, o => handler((TEvent)o)));\r\n            _eventBatch.AddFirst(new Persistent(@event));\r\n        }"}}