Search in sources :

Example 1 with ControlMessageType

use of io.zeebe.protocol.clientapi.ControlMessageType in project zeebe by zeebe-io.

the class ControlMessageHandlerManager method onFragment.

@Override
public int onFragment(DirectBuffer buffer, int offset, int length, int streamId, boolean isMarkedFailed) {
    requestHeaderDescriptor.wrap(buffer, offset);
    eventMetada.reset();
    eventMetada.requestId(requestHeaderDescriptor.requestId()).requestStreamId(requestHeaderDescriptor.streamId());
    offset += ControlMessageRequestHeaderDescriptor.headerLength();
    messageHeaderDecoder.wrap(requestBuffer, 0);
    offset += messageHeaderDecoder.encodedLength();
    requestDecoder.wrap(buffer, offset, requestDecoder.sbeBlockLength(), requestDecoder.sbeSchemaVersion());
    final ControlMessageType messageType = requestDecoder.messageType();
    lastRequestMessageType(messageType);
    final int partitionId = requestDecoder.partitionId();
    ensureBufferCapacity(requestDecoder.dataLength());
    requestDecoder.getData(requestBuffer, 0, requestDecoder.dataLength());
    final ControlMessageHandler handler = handlersByTypeId.get(messageType.value());
    if (handler != null) {
        handler.handle(actor, partitionId, requestBuffer, eventMetada);
    } else {
        sendResponse(actor, () -> {
            return errorResponseWriter.errorCode(ErrorCode.MESSAGE_NOT_SUPPORTED).errorMessage("Cannot handle control message with type '%s'.", getLastRequestMessageType().name()).tryWriteResponseOrLogFailure(eventMetada.getRequestStreamId(), eventMetada.getRequestId());
        });
    }
    return FragmentHandler.CONSUME_FRAGMENT_RESULT;
}
Also used : ControlMessageType(io.zeebe.protocol.clientapi.ControlMessageType)

Aggregations

ControlMessageType (io.zeebe.protocol.clientapi.ControlMessageType)1