use of io.zeebe.client.cmd.ClientException in project zeebe by zeebe-io.
the class PollableTopicSubscriptionBuilderImpl method open.
@Override
public PollableTopicSubscription open() {
EnsureUtil.ensureNotNull("name", implBuilder.getName());
final Future<TopicSubscriberGroup> subscription = implBuilder.build();
try {
return subscription.get();
} catch (InterruptedException | ExecutionException e) {
throw new ClientException("Could not open subscription", e);
}
}
use of io.zeebe.client.cmd.ClientException in project zeebe by zeebe-io.
the class CommandRequestHandler method getResult.
@Override
public EventImpl getResult(DirectBuffer buffer, int offset, int blockLength, int version) {
decoder.wrap(buffer, offset, blockLength, version);
final long key = decoder.key();
final int partitionId = decoder.partitionId();
final long position = decoder.position();
final int eventLength = decoder.eventLength();
final DirectBufferInputStream inStream = new DirectBufferInputStream(buffer, decoder.limit() + ExecuteCommandResponseDecoder.eventHeaderLength(), eventLength);
final EventImpl result;
try {
result = objectMapper.readValue(inStream, event.getClass());
} catch (Exception e) {
throw new ClientException("Cannot deserialize event in response", e);
}
result.setKey(key);
result.setPartitionId(partitionId);
result.setTopicName(event.getMetadata().getTopicName());
result.setEventPosition(position);
if (expectedState != null && !expectedState.equals(result.getState())) {
throw new ClientCommandRejectedException(errorFunction.apply(event, result));
}
return result;
}
use of io.zeebe.client.cmd.ClientException in project zeebe by zeebe-io.
the class TaskSubscriptionBuilderImpl method open.
@Override
public TaskSubscription open() {
EnsureUtil.ensureNotNull("taskHandler", taskHandler);
subscriberBuilder.taskHandler(taskHandler);
final Future<TaskSubscriberGroup> subscriberGroup = subscriberBuilder.build();
try {
return subscriberGroup.get();
} catch (InterruptedException | ExecutionException e) {
throw new ClientException("Could not open subscription", e);
}
}
Aggregations