use of io.zeebe.client.task.TaskHandler in project zeebe by zeebe-io.
the class RecordingTaskHandler method handle.
@Override
public void handle(TasksClient client, TaskEvent task) {
final TaskHandler handler = taskHandlers[nextTaskHandler];
nextTaskHandler = Math.min(nextTaskHandler + 1, taskHandlers.length - 1);
try {
handler.handle(client, task);
} finally {
handledTasks.add(task);
}
}
use of io.zeebe.client.task.TaskHandler in project zeebe by zeebe-io.
the class TaskSubscriptionTest method shouldNotLoseCreditsOnFailureToReportTaskFailure.
/**
* i.e. if signalling task failure itself fails
*/
@Test
public void shouldNotLoseCreditsOnFailureToReportTaskFailure() throws InterruptedException {
// given
broker.stubTaskSubscriptionApi(123L);
failTaskFailure();
final int subscriptionCapacity = 8;
final AtomicInteger failedTasks = new AtomicInteger(0);
final TaskHandler taskHandler = (c, t) -> {
failedTasks.incrementAndGet();
throw new RuntimeException("foo");
};
clientRule.tasks().newTaskSubscription(clientRule.getDefaultTopicName()).handler(taskHandler).lockOwner("owner").lockTime(1000L).taskFetchSize(subscriptionCapacity).taskType("foo").open();
final RemoteAddress clientAddress = broker.getReceivedControlMessageRequests().get(0).getSource();
for (int i = 0; i < subscriptionCapacity; i++) {
broker.pushLockedTask(clientAddress, 123L, i, i, "owner", "foo");
}
// when
TestUtil.waitUntil(() -> failedTasks.get() == 8);
// give the client a bit of time to submit credits; this is not coupled to any defined event, so we just sleep for a bit
Thread.sleep(500L);
// then
final List<ControlMessageRequest> creditRequests = getCreditRequests().collect(Collectors.toList());
assertThat(creditRequests).isNotEmpty();
final int numSubmittedCredits = creditRequests.stream().mapToInt((r) -> (int) r.getData().get("credits")).sum();
assertThat(numSubmittedCredits).isGreaterThan(0);
}
use of io.zeebe.client.task.TaskHandler in project zeebe by zeebe-io.
the class RecordingTaskHandler method handle.
@Override
public void handle(TasksClient client, TaskEvent task) {
final TaskHandler handler = taskHandlers[nextTaskHandler];
nextTaskHandler = Math.min(nextTaskHandler + 1, taskHandlers.length - 1);
try {
handler.handle(client, task);
} finally {
handledTasks.add(task);
}
}
Aggregations