Class ImmutableJobRecordValue

java.lang.Object
io.camunda.zeebe.protocol.record.value.ImmutableJobRecordValue
All Implemented Interfaces:
JsonSerializable, RecordValue, RecordValueWithVariables, JobRecordValue, ProcessInstanceRelated

@ParametersAreNonnullByDefault @Immutable public final class ImmutableJobRecordValue extends Object implements JobRecordValue
Immutable implementation of JobRecordValue.

Use the builder to create immutable instances: ImmutableJobRecordValue.builder().

  • Method Details

    • getVariables

      public Map<String,Object> getVariables()
      Specified by:
      getVariables in interface RecordValueWithVariables
      Returns:
      the variables of this record. Can be empty.
    • getProcessInstanceKey

      public long getProcessInstanceKey()
      Specified by:
      getProcessInstanceKey in interface ProcessInstanceRelated
      Returns:
      the key of the corresponding process instance
    • getType

      public String getType()
      Specified by:
      getType in interface JobRecordValue
      Returns:
      the type of the job
    • getCustomHeaders

      public Map<String,String> getCustomHeaders()
      Specified by:
      getCustomHeaders in interface JobRecordValue
      Returns:
      user-defined headers associated with this job
    • getWorker

      public String getWorker()
      Specified by:
      getWorker in interface JobRecordValue
      Returns:
      the assigned worker to complete the job
    • getRetries

      public int getRetries()
      Specified by:
      getRetries in interface JobRecordValue
      Returns:
      remaining retries
    • getRetryBackoff

      public long getRetryBackoff()
      Specified by:
      getRetryBackoff in interface JobRecordValue
      Returns:
      the time of backoff in milliseconds. If backoff is disabled this method returns 0 (default value).
    • getRecurringTime

      public long getRecurringTime()
      Specified by:
      getRecurringTime in interface JobRecordValue
      Returns:
      the timestamp when this job record should be recurred. This method is used by backoff to determine the date when the job is needed to be recurred after backoff.
    • getDeadline

      public long getDeadline()
      Specified by:
      getDeadline in interface JobRecordValue
      Returns:
      the unix timestamp until when the job is exclusively assigned to this worker (time unit is milliseconds since unix epoch). If the deadline is exceeded, it can happen that the job is handed to another worker and the work is performed twice. If this property is not set it will return '-1'.
    • getErrorMessage

      public String getErrorMessage()
      Specified by:
      getErrorMessage in interface JobRecordValue
      Returns:
      the message that contains additional context of the failure/error. It is set by the job worker then the processing fails because of a technical failure or a non-technical error.
    • getErrorCode

      public String getErrorCode()
      Specified by:
      getErrorCode in interface JobRecordValue
      Returns:
      the error code to identify the business error. It is set by the job worker then the processing fails because of a non-technical error that should be handled by the process.
    • getElementId

      public String getElementId()
      Specified by:
      getElementId in interface JobRecordValue
      Returns:
      the element id of the corresponding service task
    • getElementInstanceKey

      public long getElementInstanceKey()
      Specified by:
      getElementInstanceKey in interface JobRecordValue
      Returns:
      the element instance key of the corresponding service task
    • getBpmnProcessId

      public String getBpmnProcessId()
      Specified by:
      getBpmnProcessId in interface JobRecordValue
      Returns:
      the bpmn process id of the corresponding process definition
    • getProcessDefinitionVersion

      public int getProcessDefinitionVersion()
      Specified by:
      getProcessDefinitionVersion in interface JobRecordValue
      Returns:
      the version of the corresponding process definition
    • getProcessDefinitionKey

      public long getProcessDefinitionKey()
      Specified by:
      getProcessDefinitionKey in interface JobRecordValue
      Returns:
      the process key of the corresponding process definition
    • withVariables

      public final ImmutableJobRecordValue withVariables(Map<String,? extends Object> entries)
      Copy the current immutable object by replacing the variables map with the specified map. Nulls are not permitted as keys or values. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      entries - The entries to be added to the variables map
      Returns:
      A modified copy of this object
    • withProcessInstanceKey

      public final ImmutableJobRecordValue withProcessInstanceKey(long value)
      Copy the current immutable object by setting a value for the processInstanceKey attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for processInstanceKey
      Returns:
      A modified copy of the this object
    • withType

      public final ImmutableJobRecordValue withType(String value)
      Copy the current immutable object by setting a value for the type attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for type (can be null)
      Returns:
      A modified copy of the this object
    • withCustomHeaders

      public final ImmutableJobRecordValue withCustomHeaders(Map<String,? extends String> entries)
      Copy the current immutable object by replacing the customHeaders map with the specified map. Nulls are not permitted as keys or values. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      entries - The entries to be added to the customHeaders map
      Returns:
      A modified copy of this object
    • withWorker

      public final ImmutableJobRecordValue withWorker(String value)
      Copy the current immutable object by setting a value for the worker attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for worker (can be null)
      Returns:
      A modified copy of the this object
    • withRetries

      public final ImmutableJobRecordValue withRetries(int value)
      Copy the current immutable object by setting a value for the retries attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for retries
      Returns:
      A modified copy of the this object
    • withRetryBackoff

      public final ImmutableJobRecordValue withRetryBackoff(long value)
      Copy the current immutable object by setting a value for the retryBackoff attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for retryBackoff
      Returns:
      A modified copy of the this object
    • withRecurringTime

      public final ImmutableJobRecordValue withRecurringTime(long value)
      Copy the current immutable object by setting a value for the recurringTime attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for recurringTime
      Returns:
      A modified copy of the this object
    • withDeadline

      public final ImmutableJobRecordValue withDeadline(long value)
      Copy the current immutable object by setting a value for the deadline attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for deadline
      Returns:
      A modified copy of the this object
    • withErrorMessage

      public final ImmutableJobRecordValue withErrorMessage(String value)
      Copy the current immutable object by setting a value for the errorMessage attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for errorMessage (can be null)
      Returns:
      A modified copy of the this object
    • withErrorCode

      public final ImmutableJobRecordValue withErrorCode(String value)
      Copy the current immutable object by setting a value for the errorCode attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for errorCode (can be null)
      Returns:
      A modified copy of the this object
    • withElementId

      public final ImmutableJobRecordValue withElementId(String value)
      Copy the current immutable object by setting a value for the elementId attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for elementId (can be null)
      Returns:
      A modified copy of the this object
    • withElementInstanceKey

      public final ImmutableJobRecordValue withElementInstanceKey(long value)
      Copy the current immutable object by setting a value for the elementInstanceKey attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for elementInstanceKey
      Returns:
      A modified copy of the this object
    • withBpmnProcessId

      public final ImmutableJobRecordValue withBpmnProcessId(String value)
      Copy the current immutable object by setting a value for the bpmnProcessId attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for bpmnProcessId (can be null)
      Returns:
      A modified copy of the this object
    • withProcessDefinitionVersion

      public final ImmutableJobRecordValue withProcessDefinitionVersion(int value)
      Copy the current immutable object by setting a value for the processDefinitionVersion attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for processDefinitionVersion
      Returns:
      A modified copy of the this object
    • withProcessDefinitionKey

      public final ImmutableJobRecordValue withProcessDefinitionKey(long value)
      Copy the current immutable object by setting a value for the processDefinitionKey attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for processDefinitionKey
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutableJobRecordValue that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Returns a lazily computed hash code from attributes: variables, processInstanceKey, type, customHeaders, worker, retries, retryBackoff, recurringTime, deadline, errorMessage, errorCode, elementId, elementInstanceKey, bpmnProcessId, processDefinitionVersion, processDefinitionKey.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value JobRecordValue with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • copyOf

      public static ImmutableJobRecordValue copyOf(JobRecordValue instance)
      Creates an immutable copy of a JobRecordValue value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable JobRecordValue instance
    • builder

      public static ImmutableJobRecordValue.Builder builder()
      Creates a builder for ImmutableJobRecordValue.
       ImmutableJobRecordValue.builder()
          .putVariable|putAllVariables(String => Object) // variables mappings
          .withProcessInstanceKey(long) // optional processInstanceKey
          .withType(String | null) // nullable type
          .putCustomHeader|putAllCustomHeaders(String => String) // customHeaders mappings
          .withWorker(String | null) // nullable worker
          .withRetries(int) // optional retries
          .withRetryBackoff(long) // optional retryBackoff
          .withRecurringTime(long) // optional recurringTime
          .withDeadline(long) // optional deadline
          .withErrorMessage(String | null) // nullable errorMessage
          .withErrorCode(String | null) // nullable errorCode
          .withElementId(String | null) // nullable elementId
          .withElementInstanceKey(long) // optional elementInstanceKey
          .withBpmnProcessId(String | null) // nullable bpmnProcessId
          .withProcessDefinitionVersion(int) // optional processDefinitionVersion
          .withProcessDefinitionKey(long) // optional processDefinitionKey
          .build();
       
      Returns:
      A new ImmutableJobRecordValue builder