SpinGo / op-rabbit

The Opinionated RabbitMQ Library for Scala and Akka
Other
232 stars 73 forks source link

How do I access x-retry header integer value from the message #151

Closed AbacusIntegrationPlatform closed 6 years ago

AbacusIntegrationPlatform commented 6 years ago

How do I access x-retry header INT from the message

Currently i am trying with properties.TypedHeader[Int]("x-retry") But the out of this is <function1>

What is the right way to retrieve the x-retry count from the message header ?

AbacusIntegrationPlatform commented 6 years ago

Ok, figured it out -

import com.spingo.op_rabbit.properties._
consume(Queue.passive(queue(s"${queuename}"))) {
(body(as[String]) & optionalProperty(TypedHeader[Int]("x-retry"))) { (message, TypedHeader) =>
println (TypedHeader.getOrElse(0))
}
ack
}

TypedHeader is where we can access it.