use of io.zeebe.client.event.impl.EventImpl 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;
}
Aggregations