title: Found java.util.concurrent.Future Required scala.concurrent.Future
body: <p>Related: <a href="https://stackoverflow.com/questions/17215421/scala-concurrent-future-wrapper-for-java-util-concurrent-future">scala.concurrent.Future wrapper for java.util.concurrent.Future</a></p>
  
  <p>This came from my other question:</p>
  
  <p><a href="https://stackoverflow.com/questions/46099303/how-to-integrate-akka-streams-kafka-reactive-kafka-into-akka-http-application">How to integrate akka streams kafka (reactive-kafka) into akka http application?</a></p>
  
  <p>I have a AKKA HTTP application, and I'd like to send a message/ProducerRecord to Kafka in the onComplete function in my route, like the following:</p>
  
  <pre><code>val producer : KafkaProducer = new KafkaProducer(producerSettings)
  
  val routes : Route = 
    post {
      entity(as[User]) { user =&gt;
        val createUser = userService.create(user)
        onSuccess(createUser) {
          case Invalid(y: NonEmptyList[Err]) =&gt;  
            complete(BadRequest -&gt; "invalid user")
          case Valid(u: User) =&gt; { 
            val producerRecord = 
              new ProducerRecord[Array[Byte], String]("topic1","some message")
  
            onComplete(producer.send(producerRecord)) { _ =&gt;
              complete(ToResponseMarshallable((StatusCodes.Created, u)))
            }
          }
        }
      }
    }
  </code></pre>
  
  <p>However, the <strong>onComplete(producer send producerRecord)</strong> is generating the following type mismatch error:</p>
  
  <p>[error]  found   : Future[org.apache.kafka.clients.producer.RecordMetadata] (in java.util.concurrent) 
  [error]  required: Future[org.apache.kafka.clients.producer.RecordMetadata] (in scala.concurrent) 
  [error]             onCompleteRecordMetadata { _ =></p>
  
  <p>Is there any way around this, maybe by using the Producer as as sink (<a href="http://doc.akka.io/docs/akka-stream-kafka/current/producer.html#producer-as-a-sink" rel="nofollow noreferrer">http://doc.akka.io/docs/akka-stream-kafka/current/producer.html#producer-as-a-sink</a>) instead of the java <strong>producer.send</strong> function?</p>