Enum DeserializationFailurePolicy
- All Implemented Interfaces:
Serializable,Comparable<DeserializationFailurePolicy>,java.lang.constant.Constable
Set via PubSubSourceBuilder.deserializationFailurePolicy(DeserializationFailurePolicy). Whichever is
chosen, the failure is counted in Flink's standard numRecordsInErrors metric.
toString() returns the lower-case spelling rather than the constant name, because
that spelling is what a SQL WITH clause is written in: Flink resolves an enum
ConfigOption by matching the configured value against toString(), case-insensitively and
with no other normalization. Flink's own DeliveryGuarantee carries its option spelling
the same way.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionDiscards the message and carries on, acknowledging it immediately so it is not redelivered.Fails the job.Returns the message to Pub/Sub for redelivery and carries on, leaving what to do with it to the subscription's dead-letter policy: each redelivery raises the message's delivery attempt count until Pub/Sub forwards it to the dead-letter topic. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether this policy needs a dead-letter policy on the subscription, which the source checks at startup.toString()static DeserializationFailurePolicyReturns the enum constant of this type with the specified name.static DeserializationFailurePolicy[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
FAIL
Fails the job. The message stays unacknowledged, so Pub/Sub redelivers it — which means a message that can never be deserialized fails the job again after every restart until it is removed or the schema is fixed. That is the default because silently discarding data should be a decision, not an accident. -
DROP
Discards the message and carries on, acknowledging it immediately so it is not redelivered. Failures are counted and logged at a decreasing rate, so a burst of bad messages does not flood the log.This drops data. A schema that collected records before failing keeps those — the emitted prefix has already reached the output and cannot be recalled — so a partial message is discarded partially.
-
NACK
Returns the message to Pub/Sub for redelivery and carries on, leaving what to do with it to the subscription's dead-letter policy: each redelivery raises the message's delivery attempt count until Pub/Sub forwards it to the dead-letter topic.Requires a dead-letter policy on every subscription, which the source checks at startup and refuses to run without. Nacking does not fail the job, so without one a message the schema can never convert is redelivered forever, invisibly.
Dead-lettering counts deliveries rather than causes, so an unrelated job restart raises the same counter: set the subscription's delivery-attempt limit high enough that ordinary failovers do not dead-letter healthy messages.
Like
DROP, a schema that emitted records before failing keeps those, so the message is both partially emitted and redelivered in full.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
toString
- Overrides:
toStringin classEnum<DeserializationFailurePolicy>
-
requiresDeadLetterPolicy
public boolean requiresDeadLetterPolicy()Returns whether this policy needs a dead-letter policy on the subscription, which the source checks at startup.A property of the policy rather than a comparison at the call site, because the constraint belongs next to the constant that creates it: a future policy that nacks has to answer this, and the check two packages away would otherwise silently let it through. What makes a nack need one is not the nack but the job surviving it — the message comes back and fails again forever. The reader also nacks when emitting a message downstream fails, and that one needs nothing behind it because it rethrows and the job fails visibly.
-