use of io.zeebe.broker.task.processor.TaskSubscriptionRequest in project zeebe by zeebe-io.
the class AddTaskSubscriptionHandler method handle.
@Override
public void handle(final ActorControl actor, final int partitionId, final DirectBuffer buffer, final BrokerEventMetadata eventMetada) {
final TaskSubscriptionRequest request = new TaskSubscriptionRequest();
request.wrap(cloneBuffer(buffer));
final long requestId = eventMetada.getRequestId();
final int requestStreamId = eventMetada.getRequestStreamId();
final TaskSubscription taskSubscription = new TaskSubscription(partitionId, request.getLockTaskType(), request.getLockDuration(), request.getLockOwner(), requestStreamId);
taskSubscription.setCredits(request.getCredits());
final ActorFuture<Void> future = manager.addSubscription(taskSubscription);
actor.runOnCompletion(future, ((aVoid, throwable) -> {
if (throwable == null) {
final long subscriberKey = taskSubscription.getSubscriberKey();
request.setSubscriberKey(subscriberKey);
sendResponse(actor, requestStreamId, requestId, request);
} else {
sendErrorResponse(actor, requestStreamId, requestId, "Cannot add task subscription. %s", throwable.getMessage());
}
}));
}
Aggregations