private void HandleDeleteMessagesTo(DeleteMessagesTo message) { var eventStream = Context.System.EventStream; DeleteMessagesToAsync(message.PersistenceId, message.ToSequenceNr) .ContinueWith(t => { return((!t.IsFaulted && !t.IsCanceled) ? (object)new DeleteMessagesSuccess(message.ToSequenceNr) : new DeleteMessagesFailure( t.IsFaulted ? TryUnwrapException(t.Exception) : new OperationCanceledException( "DeleteMessagesToAsync canceled, possibly due to timing out."), message.ToSequenceNr)); }, _continuationOptions) .PipeTo(message.PersistentActor) .ContinueWith(resultTask => { if (!resultTask.IsFaulted && !resultTask.IsCanceled && CanPublish) { eventStream.Publish(message); } }, _continuationOptions); }
private void HandleDeleteMessagesTo(DeleteMessagesTo message) { DeleteMessagesToAsync(message.PersistenceId, message.ToSequenceNr, message.IsPermanent) .ContinueWith(t => { if (!t.IsFaulted && CanPublish) Context.System.EventStream.Publish(message); }, _continuationOptions); }
private void HandleDeleteMessagesTo(DeleteMessagesTo msg) { try { DeleteMessagesTo(msg.PersistenceId, msg.ToSequenceNr, msg.IsPermanent); if (CanPublish) Context.System.EventStream.Publish(msg); } catch (Exception e) { /* do nothing */ } }
private void HandleDeleteMessagesTo(DeleteMessagesTo message) { DeleteMessagesToAsync(message.PersistenceId, message.ToSequenceNr, message.IsPermanent) .ContinueWith(t => { if (!t.IsFaulted && CanPublish) { Context.System.EventStream.Publish(message); } }, _continuationOptions); }
private void HandleDeleteMessagesTo(DeleteMessagesTo msg) { try { DeleteMessagesTo(msg.PersistenceId, msg.ToSequenceNr, msg.IsPermanent); if (CanPublish) { Context.System.EventStream.Publish(msg); } } catch (Exception e) { /* do nothing */ } }
public void Journal_should_not_replay_permanently_deleted_messages_on_range_deletion() { var command = new DeleteMessagesTo(Pid, 3, true); var subscriber = CreateTestProbe(); Subscribe <DeleteMessagesTo>(subscriber.Ref); Journal.Tell(command); subscriber.ExpectMsg <DeleteMessagesTo>(cmd => cmd.PersistenceId == Pid && cmd.ToSequenceNr == 3 && cmd.IsPermanent); Journal.Tell(new ReplayMessages(1, long.MaxValue, long.MaxValue, Pid, _receiverProbe.Ref)); _receiverProbe.ExpectMsg <ReplayedMessage>(m => IsReplayedMessage(m, 4)); _receiverProbe.ExpectMsg <ReplayedMessage>(m => IsReplayedMessage(m, 5)); }
public void Journal_should_not_replay_permanently_deleted_messages_on_range_deletion() { var receiverProbe2 = CreateTestProbe(); var command = new DeleteMessagesTo(Pid, 3, receiverProbe2.Ref); var subscriber = CreateTestProbe(); Subscribe <DeleteMessagesTo>(subscriber.Ref); Journal.Tell(command); subscriber.ExpectMsg <DeleteMessagesTo>(cmd => cmd.PersistenceId == Pid && cmd.ToSequenceNr == 3); receiverProbe2.ExpectMsg <DeleteMessagesSuccess>(m => m.ToSequenceNr == command.ToSequenceNr); Journal.Tell(new ReplayMessages(1, long.MaxValue, long.MaxValue, Pid, _receiverProbe.Ref)); _receiverProbe.ExpectMsg <ReplayedMessage>(m => IsReplayedMessage(m, 4)); _receiverProbe.ExpectMsg <ReplayedMessage>(m => IsReplayedMessage(m, 5)); receiverProbe2.ExpectNoMsg(TimeSpan.FromMilliseconds(200)); }
protected override async Task HandleDeleteMessagesTo(DeleteMessagesTo req, OracleCommand command) { var toSequenceNr = req.ToSequenceNr; var persistenceId = req.PersistenceId; NotifyNewPersistenceIdAdded(persistenceId); try { var highestSequenceNr = await ReadHighestSequenceNr(persistenceId, command); command.CommandText = DeleteBatchSql; command.Parameters.Clear(); AddParameter(command, ":PersistenceId", OracleDbType.NVarchar2, persistenceId); AddParameter(command, ":ToSequenceNr", OracleDbType.Int64, toSequenceNr); await command.ExecuteNonQueryAsync(); if (highestSequenceNr <= toSequenceNr) { command.CommandText = UpdateSequenceNrSql; command.Parameters.Clear(); AddParameter(command, ":PersistenceId", OracleDbType.NVarchar2, persistenceId); AddParameter(command, ":SequenceNr", OracleDbType.Int64, highestSequenceNr); await command.ExecuteNonQueryAsync(); } var response = new DeleteMessagesSuccess(toSequenceNr); req.PersistentActor.Tell(response); } catch (Exception cause) { var response = new DeleteMessagesFailure(cause, toSequenceNr); req.PersistentActor.Tell(response, ActorRefs.NoSender); } }
private void HandleDeleteMessagesTo(DeleteMessagesTo message) { var eventStream = Context.System.EventStream; _breaker.WithCircuitBreaker(() => DeleteMessagesToAsync(message.PersistenceId, message.ToSequenceNr)) .ContinueWith(t => !t.IsFaulted && !t.IsCanceled ? new DeleteMessagesSuccess(message.ToSequenceNr) as object : new DeleteMessagesFailure( t.IsFaulted ? TryUnwrapException(t.Exception) : new OperationCanceledException( "DeleteMessagesToAsync canceled, possibly due to timing out."), message.ToSequenceNr), _continuationOptions) .PipeTo(message.PersistentActor) .ContinueWith(t => { if (!t.IsFaulted && !t.IsCanceled && CanPublish) { eventStream.Publish(message); } }, _continuationOptions); }
private void HandleDeleteMessagesTo(DeleteMessagesTo message) { var eventStream = Context.System.EventStream; DeleteMessagesToAsync(message.PersistenceId, message.ToSequenceNr) .ContinueWith(t => { return (!t.IsFaulted && !t.IsCanceled) ? (object) new DeleteMessagesSuccess(message.ToSequenceNr) : new DeleteMessagesFailure( t.IsFaulted ? TryUnwrapException(t.Exception) : new OperationCanceledException( "DeleteMessagesToAsync canceled, possibly due to timing out."), message.ToSequenceNr); }, _continuationOptions) .PipeTo(message.PersistentActor) .ContinueWith(resultTask => { if (!resultTask.IsFaulted && !resultTask.IsCanceled && CanPublish) eventStream.Publish(message); }, _continuationOptions); }
public void Journal_should_replay_logically_deleted_messages_with_deleted_flag_set_on_range_deletion() { var command = new DeleteMessagesTo(Pid, 3, false); var subscriber = CreateTestProbe(); Subscribe<DeleteMessagesTo>(subscriber.Ref); Journal.Tell(command); subscriber.ExpectMsg<DeleteMessagesTo>(cmd => cmd.PersistenceId == Pid && cmd.ToSequenceNr == 3 && !cmd.IsPermanent); Journal.Tell(new ReplayMessages(1, long.MaxValue, long.MaxValue, Pid, _receiverProbe.Ref, replayDeleted: true)); _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, 1, true)); _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, 2, true)); _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, 3, true)); _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, 4)); _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, 5)); }
public void Journal_should_not_replay_permanently_deleted_messages_on_range_deletion() { var receiverProbe2 = CreateTestProbe(); var command = new DeleteMessagesTo(Pid, 3, receiverProbe2.Ref); var subscriber = CreateTestProbe(); Subscribe<DeleteMessagesTo>(subscriber.Ref); Journal.Tell(command); subscriber.ExpectMsg<DeleteMessagesTo>(cmd => cmd.PersistenceId == Pid && cmd.ToSequenceNr == 3); receiverProbe2.ExpectMsg<DeleteMessagesSuccess>(m => m.ToSequenceNr == command.ToSequenceNr); Journal.Tell(new ReplayMessages(1, long.MaxValue, long.MaxValue, Pid, _receiverProbe.Ref)); _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, 4)); _receiverProbe.ExpectMsg<ReplayedMessage>(m => IsReplayedMessage(m, 5)); receiverProbe2.ExpectNoMsg(TimeSpan.FromMilliseconds(200)); }