Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Await replayed event message processing to complete for invoice proce…

…ssor
  • Loading branch information...
commit fe37840dccb0d16af6a6b2f76c66592e820e9b53 1 parent ce485c2
@krasserm krasserm authored
View
7 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)
Please sign in to comment.
Something went wrong with that request. Please try again.