Search in sources :

Example 1 with ClientException

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);
    }
}
Also used : ClientException(io.zeebe.client.cmd.ClientException) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with ClientException

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;
}
Also used : DirectBufferInputStream(org.agrona.io.DirectBufferInputStream) EventImpl(io.zeebe.client.event.impl.EventImpl) ClientCommandRejectedException(io.zeebe.client.cmd.ClientCommandRejectedException) ClientException(io.zeebe.client.cmd.ClientException) ClientException(io.zeebe.client.cmd.ClientException) ClientCommandRejectedException(io.zeebe.client.cmd.ClientCommandRejectedException)

Example 3 with ClientException

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);
    }
}
Also used : ClientException(io.zeebe.client.cmd.ClientException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ClientException (io.zeebe.client.cmd.ClientException)3 ExecutionException (java.util.concurrent.ExecutionException)2 ClientCommandRejectedException (io.zeebe.client.cmd.ClientCommandRejectedException)1 EventImpl (io.zeebe.client.event.impl.EventImpl)1 DirectBufferInputStream (org.agrona.io.DirectBufferInputStream)1