Permalink
Browse files

Await replayed event message processing to complete for invoice proce…

…ssor
  • Loading branch information...
krasserm committed Oct 31, 2012
1 parent ce485c2 commit fe37840dccb0d16af6a6b2f76c66592e820e9b53
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/main/scala/org/eligosource/eventsourced/example/server/Appserver.scala
@@ -20,6 +20,8 @@ import scala.concurrent.stm.Ref
import java.io.File
import akka.actor._
+import akka.util.duration._
+import akka.util.Timeout
import org.eligosource.eventsourced.core._
import org.eligosource.eventsourced.journal.LeveldbJournal
@@ -35,6 +37,7 @@ trait Appserver {
object Appserver {
def boot(): Appserver = new Appserver {
implicit val system = ActorSystem("eventsourced")
+ implicit val timeout = Timeout(10 seconds)
val journal = LeveldbJournal(new File("target/journal"))
val extension = EventsourcingExtension(system, journal)
@@ -55,6 +58,10 @@ object Appserver {
extension.channelOf(DefaultChannelProps(2, multicastProcessor).withName("listeners"))
extension.recover()
+ // wait for processor 1 to complete processing of replayed event messages
+ // (ensures that recovery of externally visible state maintained by
+ // invoicesRef is completed when awaitProcessorCompletion returns)
+ extension.awaitProcessorCompletion(Set(1))
val invoiceService = new InvoiceService(invoicesRef, invoiceProcessor)
val statisticsService = new StatisticsService(statisticsRef)

0 comments on commit fe37840

Please sign in to comment.