Search in sources :

Example 1 with SubscriptionType

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

the class SubscribedEventCollector method onMessage.

@Override
public boolean onMessage(ClientOutput output, RemoteAddress remoteAddress, DirectBuffer buffer, int offset, int length) {
    messageHeaderDecoder.wrap(buffer, offset);
    offset += MessageHeaderDecoder.ENCODED_LENGTH;
    final int templateId = messageHeaderDecoder.templateId();
    final boolean messageHandled;
    if (templateId == SubscribedEventDecoder.TEMPLATE_ID) {
        subscribedEventDecoder.wrap(buffer, offset, messageHeaderDecoder.blockLength(), messageHeaderDecoder.version());
        final SubscriptionType subscriptionType = subscribedEventDecoder.subscriptionType();
        final long key = subscribedEventDecoder.key();
        final long subscriberKey = subscribedEventDecoder.subscriberKey();
        final long position = subscribedEventDecoder.position();
        final int partitionId = subscribedEventDecoder.partitionId();
        final byte[] eventBuffer = readBytes(subscribedEventDecoder::getEvent, subscribedEventDecoder::eventLength);
        final GeneralEventImpl event = new GeneralEventImpl(partitionId, key, position, EventTypeMapping.mapEventType(subscribedEventDecoder.eventType()), eventBuffer, converter);
        messageHandled = eventHandler.onEvent(subscriptionType, subscriberKey, event);
    } else {
        // ignoring
        messageHandled = true;
    }
    return messageHandled;
}
Also used : SubscriptionType(io.zeebe.protocol.clientapi.SubscriptionType) GeneralEventImpl(io.zeebe.client.event.impl.GeneralEventImpl)

Aggregations

GeneralEventImpl (io.zeebe.client.event.impl.GeneralEventImpl)1 SubscriptionType (io.zeebe.protocol.clientapi.SubscriptionType)1