java.lang.Object
io.github.flink.gcp.connector.cloudtasks.sink.FailedTask
All Implemented Interfaces:
FailedElement

@Public public final class FailedTask extends Object implements 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 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 to
      task - the serialized task, or null when serialization itself failed
      errorMessage - the failure description
      cause - the underlying failure, or null
      Returns:
      the failed task
    • getDestination

      public QueueDestination 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, or null when the record could not be serialized in the first place.
    • getConnector

      public String getConnector()
      Description copied from interface: FailedElement
      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.
      Specified by:
      getConnector in interface FailedElement
    • describeDestination

      public String describeDestination()
      Returns the queue in the projects/<project>/locations/<location>/queues/<queue> form.
      Specified by:
      describeDestination in interface FailedElement
    • getPayloadBytes

      @Nullable public com.google.protobuf.ByteString getPayloadBytes()
      Returns the serialized Task — target, body, headers and authorization alike — or null when serialization itself failed.
      Specified by:
      getPayloadBytes in interface FailedElement
    • getErrorMessage

      public String getErrorMessage()
      Description copied from interface: FailedElement
      Returns the failure description. It is always present, even when FailedElement.getCause() is null, and it is the detail that FailureHandler.failJob() raises and FailureHandler.logAndDrop() logs.
      Specified by:
      getErrorMessage in interface FailedElement
    • getCause

      @Nullable public Throwable getCause()
      Description copied from interface: FailedElement
      Returns the underlying failure, or null when none is available.
      Specified by:
      getCause in interface FailedElement
    • toString

      public String toString()
      Overrides:
      toString in class Object