janvladimirmostert
02/14/2017, 1:06 PMfun 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
channel.consume(queue = "api", onMessage = (a: String, b: Envelope, c: BasicProperties, d: String){
})
If I remove the types in onMessage, IDE complains Unresolved Reference