Skip to content

Commit

Permalink
feat(clients/java): propagate job worker exception message to broker
Browse files Browse the repository at this point in the history
  • Loading branch information
menski committed Dec 11, 2018
1 parent 4f99d24 commit 23a70ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ private void executeJob(ActivatedJob job, Runnable doneCallback) {
job.getKey(),
job.getType(),
e);
jobClient.newFailCommand(job.getKey()).retries(job.getRetries() - 1).send();
jobClient
.newFailCommand(job.getKey())
.retries(job.getRetries() - 1)
.errorMessage(e.getMessage())
.send();
} finally {
doneCallback.run();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,12 @@ public void shouldFailJobWithErrorMessage() {
public void shouldMarkJobAsFailedAndRetryIfHandlerThrowsException() {
// given
final long jobKey = createJobOfType("foo");
final String failureMessage = "expected failure";

final RecordingJobHandler jobHandler =
new RecordingJobHandler(
(c, j) -> {
throw new RuntimeException("expected failure");
throw new RuntimeException(failureMessage);
},
(c, j) -> c.newCompleteCommand(j.getKey()).send().join());

Expand All @@ -284,7 +285,10 @@ public void shouldMarkJobAsFailedAndRetryIfHandlerThrowsException() {
assertThat(jobHandler.getHandledJobs())
.extracting(ActivatedJob::getKey)
.containsExactly(jobKey, jobKey);
assertThat(jobRecords(JobIntent.FAILED).exists()).isTrue();

final Record<JobRecordValue> failedJob = jobRecords(JobIntent.FAILED).getFirst();
assertThat(failedJob.getValue()).hasErrorMessage(failureMessage);

waitUntil(() -> jobRecords(JobIntent.COMPLETED).exists());
}

Expand Down

0 comments on commit 23a70ea

Please sign in to comment.