I'm wrapping a Java function in a Kotlin function:...
# announcements
j
I'm wrapping a Java function in a Kotlin function:
Copy code
fun Channel.consume(
	queue: String = "",
	autoAck: Boolean = true,
	onMessage: (consumerTag: String, envelope: Envelope, properties: BasicProperties, json: String) -> Unit
){
	this.basicConsume(queue, autoAck, object : DefaultConsumer(this) {
		override fun handleDelivery(consumerTag: String?, envelope: Envelope?, properties: AMQP.BasicProperties?, body: ByteArray?) {
			onMessage(
				consumerTag ?: "",
				envelope ?: Envelope(0, false, "", ""),
				properties ?: AMQP.BasicProperties(),
				if (body != null) String(body) else "")
		}
	});
}
How do I make use of this extension function? This gives me an error saying unexpected type specification
Copy code
channel.consume(queue = "api", onMessage = (a: String, b: Envelope, c: BasicProperties, d: String){

		})
If I remove the types in onMessage, IDE complains
Unresolved Reference