!per #3704 Persistence improvements
- Channel enhancements (#3773): - Live read models (#3776): - Batch-oriented journal plugin API (#3804): - Batching of confirmations and deletions - Message deletion enhancements (more efficient range deletions)
This commit is contained in:
parent
32b76adb9a
commit
f327e1e357
55 changed files with 3474 additions and 2191 deletions
|
|
@ -7,10 +7,20 @@ package docs.persistence
|
|||
import scala.concurrent.duration._
|
||||
import scala.language.postfixOps
|
||||
|
||||
import akka.actor.ActorSystem
|
||||
import akka.actor.{ Actor, ActorSystem }
|
||||
import akka.persistence._
|
||||
|
||||
trait PersistenceDocSpec {
|
||||
val config =
|
||||
"""
|
||||
//#auto-update-interval
|
||||
akka.persistence.view.auto-update-interval = 5s
|
||||
//#auto-update-interval
|
||||
//#auto-update
|
||||
akka.persistence.view.auto-update = off
|
||||
//#auto-update
|
||||
"""
|
||||
|
||||
val system: ActorSystem
|
||||
|
||||
import system._
|
||||
|
|
@ -110,7 +120,7 @@ trait PersistenceDocSpec {
|
|||
|
||||
def receive = {
|
||||
case p @ Persistent(payload, _) =>
|
||||
channel ! Deliver(p.withPayload(s"processed ${payload}"), destination)
|
||||
channel ! Deliver(p.withPayload(s"processed ${payload}"), destination.path)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -124,8 +134,6 @@ trait PersistenceDocSpec {
|
|||
//#channel-example
|
||||
|
||||
class MyProcessor2 extends Processor {
|
||||
import akka.persistence.Resolve
|
||||
|
||||
val destination = context.actorOf(Props[MyDestination])
|
||||
val channel =
|
||||
//#channel-id-override
|
||||
|
|
@ -141,15 +149,21 @@ trait PersistenceDocSpec {
|
|||
def receive = {
|
||||
case p @ Persistent(payload, _) =>
|
||||
//#channel-example-reply
|
||||
channel ! Deliver(p.withPayload(s"processed ${payload}"), sender)
|
||||
//#channel-example-reply
|
||||
//#resolve-destination
|
||||
channel ! Deliver(p, sender, Resolve.Destination)
|
||||
//#resolve-destination
|
||||
//#resolve-sender
|
||||
channel forward Deliver(p, destination, Resolve.Sender)
|
||||
//#resolve-sender
|
||||
channel ! Deliver(p.withPayload(s"processed ${payload}"), sender.path)
|
||||
//#channel-example-reply
|
||||
}
|
||||
|
||||
//#channel-custom-listener
|
||||
class MyListener extends Actor {
|
||||
def receive = {
|
||||
case RedeliverFailure(messages) => // ...
|
||||
}
|
||||
}
|
||||
|
||||
val myListener = context.actorOf(Props[MyListener])
|
||||
val myChannel = context.actorOf(Channel.props(
|
||||
ChannelSettings(redeliverFailureListener = Some(myListener))))
|
||||
//#channel-custom-listener
|
||||
}
|
||||
|
||||
class MyProcessor3 extends Processor {
|
||||
|
|
@ -254,9 +268,13 @@ trait PersistenceDocSpec {
|
|||
PersistentChannelSettings(redeliverInterval = 30 seconds, redeliverMax = 15)),
|
||||
name = "myPersistentChannel")
|
||||
|
||||
channel ! Deliver(Persistent("example"), destination)
|
||||
channel ! Deliver(Persistent("example"), destination.path)
|
||||
//#persistent-channel-example
|
||||
|
||||
//#persistent-channel-watermarks
|
||||
PersistentChannelSettings(
|
||||
pendingConfirmationsMax = 10000,
|
||||
pendingConfirmationsMin = 2000)
|
||||
//#persistent-channel-watermarks
|
||||
//#persistent-channel-reply
|
||||
PersistentChannelSettings(replyPersistent = true)
|
||||
//#persistent-channel-reply
|
||||
|
|
@ -274,7 +292,7 @@ trait PersistenceDocSpec {
|
|||
// update state
|
||||
// ...
|
||||
// reliably deliver events
|
||||
channel ! Deliver(Persistent(event), destination)
|
||||
channel ! Deliver(Persistent(event), destination.path)
|
||||
}
|
||||
|
||||
def receiveReplay: Receive = {
|
||||
|
|
@ -290,4 +308,22 @@ trait PersistenceDocSpec {
|
|||
}
|
||||
//#reliable-event-delivery
|
||||
}
|
||||
new AnyRef {
|
||||
import akka.actor.Props
|
||||
|
||||
//#view
|
||||
class MyView extends View {
|
||||
def processorId: String = "some-processor-id"
|
||||
|
||||
def receive: Actor.Receive = {
|
||||
case Persistent(payload, sequenceNr) => // ...
|
||||
}
|
||||
}
|
||||
//#view
|
||||
|
||||
//#view-update
|
||||
val view = system.actorOf(Props[MyView])
|
||||
view ! Update(await = true)
|
||||
//#view-update
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ import akka.persistence.snapshot._
|
|||
object PersistencePluginDocSpec {
|
||||
val config =
|
||||
"""
|
||||
//#max-batch-size
|
||||
akka.persistence.journal.max-batch-size = 200
|
||||
//#max-batch-size
|
||||
//#max-message-batch-size
|
||||
akka.persistence.journal.max-message-batch-size = 200
|
||||
//#max-message-batch-size
|
||||
//#journal-config
|
||||
akka.persistence.journal.leveldb.dir = "target/journal"
|
||||
//#journal-config
|
||||
|
|
@ -119,10 +119,12 @@ trait SharedLeveldbPluginDocSpec {
|
|||
}
|
||||
|
||||
class MyJournal extends AsyncWriteJournal {
|
||||
def writeAsync(persistentBatch: Seq[PersistentRepr]): Future[Unit] = ???
|
||||
def deleteAsync(processorId: String, fromSequenceNr: Long, toSequenceNr: Long, permanent: Boolean): Future[Unit] = ???
|
||||
def confirmAsync(processorId: String, sequenceNr: Long, channelId: String): Future[Unit] = ???
|
||||
def replayAsync(processorId: String, fromSequenceNr: Long, toSequenceNr: Long)(replayCallback: (PersistentRepr) => Unit): Future[Long] = ???
|
||||
def asyncWriteMessages(messages: Seq[PersistentRepr]): Future[Unit] = ???
|
||||
def asyncWriteConfirmations(confirmations: Seq[PersistentConfirmation]): Future[Unit] = ???
|
||||
def asyncDeleteMessages(messageIds: Seq[PersistentId], permanent: Boolean): Future[Unit] = ???
|
||||
def asyncDeleteMessagesTo(processorId: String, toSequenceNr: Long, permanent: Boolean): Future[Unit] = ???
|
||||
def asyncReplayMessages(processorId: String, fromSequenceNr: Long, toSequenceNr: Long, max: Long)(replayCallback: (PersistentRepr) => Unit): Future[Unit] = ???
|
||||
def asyncReadHighestSequenceNr(processorId: String, fromSequenceNr: Long): Future[Long] = ???
|
||||
}
|
||||
|
||||
class MySnapshotStore extends SnapshotStore {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue