!per #3761 Reliable channels

- Built-in redelivery mechanism for Channel and PersistentChannel
- redelivery counter on ConfirmablePersistent
- redeliveries out of initial message delivery order
- relative order of redelivered messages is preserved
- configurable redelivery policy (ChannelSettings)
- Major refactorings of channels (and channel tests)
- Throughput load test for PersistentChannel

Todo:

- Paged/throtlled replay (another pull request)
- Resequencer (another pull request)
This commit is contained in:
Martin Krasser 2013-12-06 12:48:44 +01:00
parent 3231bb3729
commit 4e5ce5529c
27 changed files with 1980 additions and 844 deletions

View file

@ -4,6 +4,9 @@
package docs.persistence
import scala.concurrent.duration._
import scala.language.postfixOps
import akka.actor.ActorSystem
import akka.persistence._
@ -113,8 +116,8 @@ trait PersistenceDocSpec {
class MyDestination extends Actor {
def receive = {
case p @ ConfirmablePersistent(payload, _)
println(s"received ${payload}")
case p @ ConfirmablePersistent(payload, sequenceNr, redeliveries)
// ...
p.confirm()
}
}
@ -129,6 +132,12 @@ trait PersistenceDocSpec {
context.actorOf(Channel.props("my-stable-channel-id"))
//#channel-id-override
//#channel-custom-settings
context.actorOf(Channel.props(
ChannelSettings(redeliverInterval = 30 seconds, redeliverMax = 15)),
name = "myChannel")
//#channel-custom-settings
def receive = {
case p @ Persistent(payload, _)
//#channel-example-reply
@ -241,11 +250,44 @@ trait PersistenceDocSpec {
trait MyActor extends Actor {
val destination: ActorRef = null
//#persistent-channel-example
val channel = context.actorOf(PersistentChannel.props(),
val channel = context.actorOf(PersistentChannel.props(
PersistentChannelSettings(redeliverInterval = 30 seconds, redeliverMax = 15)),
name = "myPersistentChannel")
channel ! Deliver(Persistent("example"), destination)
//#persistent-channel-example
//#persistent-channel-reply
PersistentChannelSettings(replyPersistent = true)
//#persistent-channel-reply
}
}
new AnyRef {
import akka.actor.ActorRef
//#reliable-event-delivery
class MyEventsourcedProcessor(destination: ActorRef) extends EventsourcedProcessor {
val channel = context.actorOf(Channel.props("channel"))
def handleEvent(event: String) = {
// update state
// ...
// reliably deliver events
channel ! Deliver(Persistent(event), destination)
}
def receiveReplay: Receive = {
case event: String handleEvent(event)
}
def receiveCommand: Receive = {
case "cmd" {
// ...
persist("evt")(handleEvent)
}
}
}
//#reliable-event-delivery
}
}

View file

@ -32,6 +32,9 @@ object PersistencePluginDocSpec {
//#snapshot-config
akka.persistence.snapshot-store.local.dir = "target/snapshots"
//#snapshot-config
//#native-config
akka.persistence.journal.leveldb.native = off
//#native-config
"""
}
@ -80,6 +83,9 @@ object SharedLeveldbPluginDocSpec {
//#shared-journal-config
akka.persistence.journal.plugin = "akka.persistence.journal.leveldb-shared"
//#shared-journal-config
//#shared-store-native-config
akka.persistence.journal.leveldb-shared.store.native = off
//#shared-store-native-config
//#shared-store-config
akka.persistence.journal.leveldb-shared.store.dir = "target/shared"
//#shared-store-config