Class FailedMessage
java.lang.Object
io.github.flink.gcp.connector.pubsub.sink.FailedMessage
- All Implemented Interfaces:
FailedElement
A single message that terminally failed to be published to Pub/Sub, as passed to a
FailureHandler<FailedMessage>.
Carries the PubsubMessage the serializer produced rather than the original record: the
sink writer is stateless and retains only serialized messages, so by the time a publish is
rejected the original record object no longer exists. When serialization itself failed, getPubsubMessage() is null.
getPayloadBytes() is the whole serialized message, not just its data, so the
attributes and the ordering key survive a dead-letter round trip: a consumer recovers them with
PubsubMessage.parseFrom(bytes).
Instances are created by the sink and are not serializable.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the topic in theprojects/<p>/topics/<t>form.getCause()Returns the underlying failure, ornullwhen none is available.Returns the connector that produced the failure, as a lower-case identifier ("bigquery","bigtable","cloudtasks","pubsub","spanner") — stable, so dead-letter consumers can key on it.Returns the topic the message was routed to.Returns the failure description.com.google.protobuf.ByteStringReturns the serializedPubsubMessage— payload, attributes and ordering key alike — ornullwhen serialization itself failed.com.google.pubsub.v1.PubsubMessageReturns the message the serializer produced, ornullwhen the record could not be serialized in the first place.static FailedMessageof(TopicDestination destination, com.google.pubsub.v1.PubsubMessage message, String errorMessage, Throwable cause) Creates a failed message.toString()
-
Method Details
-
of
public static FailedMessage of(TopicDestination destination, @Nullable com.google.pubsub.v1.PubsubMessage message, String errorMessage, @Nullable Throwable cause) Creates a failed message. Intended for the sink implementation (and tests of custom handlers).- Parameters:
destination- the topic the message was routed tomessage- the serialized message, ornullwhen serialization itself failederrorMessage- the failure descriptioncause- the underlying failure, ornull- Returns:
- the failed message
-
getDestination
Returns the topic the message was routed to. -
getPubsubMessage
@Nullable public com.google.pubsub.v1.PubsubMessage getPubsubMessage()Returns the message the serializer produced, ornullwhen the record could not be serialized in the first place. -
getConnector
Description copied from interface:FailedElementReturns the connector that produced the failure, as a lower-case identifier ("bigquery","bigtable","cloudtasks","pubsub","spanner") — stable, so dead-letter consumers can key on it.- Specified by:
getConnectorin interfaceFailedElement
-
describeDestination
Returns the topic in theprojects/<p>/topics/<t>form.- Specified by:
describeDestinationin interfaceFailedElement
-
getPayloadBytes
@Nullable public com.google.protobuf.ByteString getPayloadBytes()Returns the serializedPubsubMessage— payload, attributes and ordering key alike — ornullwhen serialization itself failed.- Specified by:
getPayloadBytesin interfaceFailedElement
-
getErrorMessage
Description copied from interface:FailedElementReturns the failure description. It is always present, even whenFailedElement.getCause()isnull, and it is the detail thatFailureHandler.failJob()raises andFailureHandler.logAndDrop()logs.- Specified by:
getErrorMessagein interfaceFailedElement
-
getCause
Description copied from interface:FailedElementReturns the underlying failure, ornullwhen none is available.- Specified by:
getCausein interfaceFailedElement
-
toString
-