Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagescala
themeEmacs
def sendTokafka(recode: ProducerRecod): Futrure[RecordMetadata] = {
  val promise : Promise[[RecordMetadata]] = Promise[RocordMetadata]() //RecordMetadata 타잎의 값을 돌려주는 약속을 만든다.
  val future:Future[RecordMetadata] = promise.future  //future에 대한 참조를 가져온다
  
  val callback = new CallBack(){  //송신성공시 카프카 콜백
    def onCompletition(metadata: RecordMetadata, e:Exception): Unit={
      if(e != null ) promise.failure(e)  //오류기록
      else promise.success(metadata)     //성공기록
    }
  }
  producer.send(record,callback)
  future
}



퓨쳐를 조합하기


Anchor
futureactor
futureactor

퓨쳐와 액터 조합하기

.net 에서 Actor 메시지와 Future(Task)를 조합한 샘플

...