Skip to content

Watch for unreadable messages

A message no format in Settings.Reads can read never reaches a handler. What that means and why. This page is how you find out it is happening and what to do.

Count them

ConsumerStats.Unreadable is attempts the subscription's source settled itself because nothing could read them. It counts each receive, so one message under MaxDeliver: 5 that stays unreadable adds five. It is outside every identity: it is not in Accepted, Exhausted or Refused, because no Delivery was made of it.

st, _ := bus.Stats("billing")
st.Unreadable

The same field is on messaging.SourceStats, which Source.Snapshot returns.

Alert on a rate, not a count. A rising Unreadable with Exhausted flat is the signature of a producer writing something the consumer does not read.

Read the log

Every unreadable receive is logged at WARN to Settings.Logger: messaging-sqs: a message on the queue could not be read, with subscription, queue and error. The error says why:

content type "", asked binary(ce-), structured: envelope: no format recognises the message

A nil Logger discards it, so set one.

Find the message

Under AtLeastOnce the message goes to the queue's dead-letter queue once it has been received maxReceiveCount times. Read it there. Under AtMostOnce it was deleted and is gone; the count and the log line are all that remain.

Fix the cause

The log says Likely cause
no format recognises the message a producer outside the estate, or a subscription without raw message delivery
more than one format claims it a producer that wrote both binary and structured attributes
a format claimed it but could not decode it a malformed event

For a producer you control, switch it to a format in Reads. For one you do not, add its format to Reads beside the defaults; see Choose a wire format. A raw-delivery mistake is fixed on the SNS subscription: Build the topology.