Class FailedTask
java.lang.Object
io.github.flink.gcp.connector.cloudtasks.sink.FailedTask
- All Implemented Interfaces:
FailedElement
A single task that terminally failed to be created in Cloud Tasks, as passed to a
FailureHandler<FailedTask>.
Carries the Task the serializer produced rather than the original record: the sink
writer is stateless and retains only serialized tasks, so by the time a creation is rejected the
original record object no longer exists. When serialization itself failed, getTask() is
null.
getPayloadBytes() is the whole serialized task, not just its HTTP body, so
the target URL, the method, the headers and the authorization survive a dead-letter round trip: a
consumer recovers them with Task.parseFrom(bytes). The task carries no name unless
taskIdExtractor(...) is set, in which case it holds the hashed one the sink composed.
Instances are created by the sink and are not serializable.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the queue in theprojects/<project>/locations/<location>/queues/<queue>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 queue the task was routed to.Returns the failure description.com.google.protobuf.ByteStringReturns the serializedTask— target, body, headers and authorization alike — ornullwhen serialization itself failed.com.google.cloud.tasks.v2.TaskgetTask()Returns the task the serializer produced, ornullwhen the record could not be serialized in the first place.static FailedTaskof(QueueDestination destination, com.google.cloud.tasks.v2.Task task, String errorMessage, Throwable cause) Creates a failed task.toString()
-
Method Details
-
of
public static FailedTask of(QueueDestination destination, @Nullable com.google.cloud.tasks.v2.Task task, String errorMessage, @Nullable Throwable cause) Creates a failed task. Intended for the sink implementation (and tests of custom handlers).- Parameters:
destination- the queue the task was routed totask- the serialized task, ornullwhen serialization itself failederrorMessage- the failure descriptioncause- the underlying failure, ornull- Returns:
- the failed task
-
getDestination
Returns the queue the task was routed to. -
getTask
@Nullable public com.google.cloud.tasks.v2.Task getTask()Returns the task 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 queue in theprojects/<project>/locations/<location>/queues/<queue>form.- Specified by:
describeDestinationin interfaceFailedElement
-
getPayloadBytes
@Nullable public com.google.protobuf.ByteString getPayloadBytes()Returns the serializedTask— target, body, headers and authorization 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
-