Upgrading Play framework version, which led to an Akka upgrade, which deprecated Materializer.settings
, with a reference to “Use attributes to access settings from stages”. The attribute i need to read (not write) is maxFixedBufferSize
.
I have access to the materializer, but not that much else (I don’t really know what “stages” are).
I was getting it by just doing materializer.settings.maxFixedBufferSize, but I’m concerned that will go away soon.
Question: How do I read that value in a non-deprecated way?
The reason I need it is that I need make sure we don’t drop any actor messages even under load, so I need an effectively unbounded buffer, but maxFixedBufferSize
is typically very large (1000000000 by default it seems), so when Buffers.scala contains:
private[akka] object Buffer {
val FixedQueueSize = 128
val FixedQueueMask = 127
def apply[T](size: Int, effectiveAttributes: Attributes): Buffer[T] =
apply(size, effectiveAttributes.mandatoryAttribute[ActorAttributes.MaxFixedBufferSize].size)
def apply[T](size: Int, max: Int): Buffer[T] =
if (size < FixedQueueSize || size < max) FixedSizeBuffer(size)
else new BoundedBuffer(size)
}
Then the line if (size < FixedQueueSize || size < max) FixedSizeBuffer(size)
becomes very dangerous - whatever reasonable size I specify I’ll allocate a FixedSizeBuffer
of that length. That’s quite undesirable, as most of the time, most of my buffers will only need to store 1-2 messages.
So the only way to get what I actually want, i.e. a BoundedBuffer
(which has the sensible strategy of using a small fixed array and then switching to a dynamic queue as needed), is to pass in a size
of maxFixedBufferSize
.
Thanks!