빅데이터/Hadoop

KAFKA 와 JAVA 의 HTTP 통신

처리2 2020. 7. 6. 09:09
반응형

kafka 연결 부분 

  def conn(ip:String,count:Int): Unit ={
      implicit val system = ActorSystem()
      implicit val materializer = ActorMaterializer()
      // needed for the future flatMap/onComplete in the end
      implicit val executionContext = system.dispatcher
      val responseFuture: Future[HttpResponse] = Http().singleRequest(HttpRequest(uri = "http://59.28.4.28:5000/sendEmail.do?ip="+ip+"&count="+count))

      responseFuture
        .onComplete {
          case Success(res) => println(res)
          case Failure(_)   => sys.error("something wrong")
        }
    }

java 부분은 그냥 mapping 으로 받으면 됩니다.

일단은 get 방식으로 연결을 했는데 더 찾아보고 post방식도 게시하도록 하겠습니다.

그리고 현재는 kafka에서 java로 보내기만 했지만 반대도 한번... ㅠㅠ

반응형