crabhi / celery-java

Java implementation of Celery client and worker
MIT License
97 stars 29 forks source link

Kotlin and AsyncResult #32

Open mdtrooper opened 3 years ago

mdtrooper commented 3 years ago

I am trying to code the example in language Kotlin:

/*
 * This Kotlin source file was generated by the Gradle 'init' task.
 */
package poc_kotlin_celery

import com.geneea.celery.*

fun main() {
   val client: Celery = Celery.builder()
        .brokerUri("amqp://localhost/%2F")
        .backendUri("rpc://localhost/%2F")
        .build();

   val args = arrayOf(1, 2)

   println("${client::class.simpleName}")
   println("${client::class.qualifiedName}")

   val result: Any = client.submit("task.add", args)
//   println("${result::class.simpleName}")

//   val suma: Int = result.get()

//>   println(suma)
}

But I have this error when I try to run:

$ gradle run

> Task :app:compileKotlin FAILED
e: /home/miguel/code/poc_kotlin_celery/app/src/main/kotlin/poc_kotlin_celery/App.kt: (19, 29): Not enough information to infer type variable R

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 758ms
1 actionable task: 1 executed

I think that it may be the type of result, but I was trying with AsyncResult<Int> and it failed too.