use of io.zeebe.util.sched.ActorControl 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());
}
}));
}
use of io.zeebe.util.sched.ActorControl in project zeebe by zeebe-io.
the class RemoveTopicSubscriptionHandler method handle.
@Override
public void handle(final ActorControl actor, final int partitionId, final DirectBuffer buffer, final BrokerEventMetadata metadata) {
final int requestStreamId = metadata.getRequestStreamId();
final long requestId = metadata.getRequestId();
final CloseSubscriptionRequest request = new CloseSubscriptionRequest();
request.wrap(cloneBuffer(buffer));
final ActorFuture<Void> future = subscriptionService.closeSubscriptionAsync(partitionId, request.getSubscriberKey());
actor.runOnCompletion(future, ((aVoid, throwable) -> {
if (throwable == null) {
sendResponse(actor, requestStreamId, requestId, request);
} else {
sendErrorResponse(actor, requestStreamId, requestId, "Cannot close topic subscription. %s", throwable.getMessage());
}
}));
}
Aggregations