Class JobEffects
java.lang.Object
com.kingsrook.qqq.backend.core.jobs.effects.JobEffects
How a process step causes a side effect outside the job's database (spec
section 2.13). Never call the external system from a step; emit the effect:
JobEffects.emit(runBackendStepInput, "welcomeEmail", customerId, payload);
In a durable job, the effect is buffered in the chunk's scope and written to
the jobs_effect outbox with the chunk's progress (its transaction, with
SAME_TRANSACTION); the dispatcher delivers it. Its idempotency key is
jobId:chunkSeq:rowKey:effectName, so a rerun chunk emits the same keys and
nothing is doubled. Outside a job, it is delivered at once (with a fresh key;
there is no chunk to rerun) and anything but SENT throws.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe chunk sequence in the keys of job-level effects (not from a chunk). -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringemit(RunBackendStepInput input, String effectName, String rowKey, Map<String, Serializable> payload) Emit a declared effect for a row (rowKey: a stable id of the row the effect is for, e.g. its primary key).static Stringemit(RunBackendStepInput input, String effectName, String rowKey, Map<String, Serializable> payload, String payloadRef) Emit a declared effect, with a reference to a larger stored payload.static booleanemitForJob(Integer jobId, JobLevelEffect effect) Write a job-level effect (not from a chunk) to the outbox, with key jobId:-1:rowKey:effectName.
-
Field Details
-
JOB_LEVEL_CHUNK_SEQ
public static final int JOB_LEVEL_CHUNK_SEQThe chunk sequence in the keys of job-level effects (not from a chunk).- See Also:
-
-
Method Details
-
emit
public static String emit(RunBackendStepInput input, String effectName, String rowKey, Map<String, Serializable> payload) throws QExceptionEmit a declared effect for a row (rowKey: a stable id of the row the effect is for, e.g. its primary key). Returns the idempotency key.- Throws:
QException
-
emit
public static String emit(RunBackendStepInput input, String effectName, String rowKey, Map<String, Serializable> payload, String payloadRef) throws QExceptionEmit a declared effect, with a reference to a larger stored payload.- Throws:
QException
-
emitForJob
Write a job-level effect (not from a chunk) to the outbox, with key jobId:-1:rowKey:effectName. Returns true when a new row was written, false when the key was already in the outbox. Used by the job completion hook (JobCompletionEffects); external effect types only.- Throws:
QException
-