Closed Blacksmoke16 closed 4 years ago
Oh, totally missed this!
But your workaround is the correct way, a Table
can't have Integers as keys, only short strings as per protocol. And at compile time we only know that headers["x-death"]
will return an AMQ::Protocol::Field
, which is an alias for among other types; Table
, and that's why you get the error. I'm afraid type casting is required.
I'm currently working on a project that involves using dead letter queues. As such I need to be able to access the
x-death
header of a message to know how many times it has failed in order to implement a retry limit.I'm currenting doing:
However this fails to compile with the error
no overload matches 'AMQ::Protocol::Table#[]' with type Int32
I think this is because
headers
is implemented asTable
, which overrides#[]
, but only acceptsString
keys.Table
type just needs to be updated in order to allow accessing arrays in addition to singular header values.EDIT: Work around would be to do like
pp headers["x-death"].as(Array)[0].as(AMQ::Protocol::Table)["count"]
.