eligosource / eventsourced

A library for building reliable, scalable and distributed event-sourced applications in Scala
Apache License 2.0
828 stars 98 forks source link

Message.confirm() doesn't work for remote channel destinations. #107

Closed krasserm closed 11 years ago

krasserm commented 11 years ago

Reason is that Message confirmation targets and messages are currently not serialized by MessageSerialization. Until this issue is fixed, applications should create a local destination proxy for a remote destination. The proxy confirms a message delivery when when it receives a reply from the remote destination:

class DestinationProxy(remoteDestination: ActorRef) extends Actor { this: Receiver =>
  implicit val timeout = Timeout(5 seconds)

  import context.dispatcher

  def receive = {
    case event => {
      val currentMessage = message
      remoteDestination ? event onComplete {
        case Success(_) => currentMessage.confirm(true)
        case Failure(_) => currentMessage.confirm(false)
      }
    }
  }
}