use of org.apache.pulsar.common.api.proto.BaseCommand in project pulsar by apache.
the class ServerCnx method newMessageAndIntercept.
public ByteBufPair newMessageAndIntercept(long consumerId, long ledgerId, long entryId, int partition, int redeliveryCount, ByteBuf metadataAndPayload, long[] ackSet, String topic, long epoch) {
BaseCommand command = Commands.newMessageCommand(consumerId, ledgerId, entryId, partition, redeliveryCount, ackSet, epoch);
ByteBufPair res = Commands.serializeCommandMessageWithSize(command, metadataAndPayload);
try {
val brokerInterceptor = getBrokerService().getInterceptor();
if (brokerInterceptor != null) {
brokerInterceptor.onPulsarCommand(command, this);
CompletableFuture<Consumer> consumerFuture = consumers.get(consumerId);
if (consumerFuture != null && consumerFuture.isDone() && !consumerFuture.isCompletedExceptionally()) {
Consumer consumer = consumerFuture.getNow(null);
brokerInterceptor.messageDispatched(this, consumer, ledgerId, entryId, metadataAndPayload);
}
} else {
log.debug("BrokerInterceptor is not set in newMessageAndIntercept");
}
} catch (Exception e) {
log.error("Exception occur when intercept messages.", e);
}
return res;
}
use of org.apache.pulsar.common.api.proto.BaseCommand in project pulsar by apache.
the class PulsarCommandSenderImpl method sendSendReceiptResponse.
@Override
public void sendSendReceiptResponse(long producerId, long sequenceId, long highestId, long ledgerId, long entryId) {
BaseCommand command = Commands.newSendReceiptCommand(producerId, sequenceId, highestId, ledgerId, entryId);
safeIntercept(command, cnx);
ByteBuf outBuf = Commands.serializeWithSize(command);
cnx.ctx().writeAndFlush(outBuf);
}
use of org.apache.pulsar.common.api.proto.BaseCommand in project pulsar by apache.
the class PulsarCommandSenderImpl method sendGetOrCreateSchemaErrorResponse.
@Override
public void sendGetOrCreateSchemaErrorResponse(long requestId, ServerError error, String errorMessage) {
BaseCommand command = Commands.newGetOrCreateSchemaResponseErrorCommand(requestId, error, errorMessage);
safeIntercept(command, cnx);
ByteBuf outBuf = Commands.serializeWithSize(command);
cnx.ctx().writeAndFlush(outBuf);
}
use of org.apache.pulsar.common.api.proto.BaseCommand in project pulsar by apache.
the class PulsarCommandSenderImpl method sendProducerSuccessResponse.
@Override
public void sendProducerSuccessResponse(long requestId, String producerName, long lastSequenceId, SchemaVersion schemaVersion, Optional<Long> topicEpoch, boolean isProducerReady) {
BaseCommand command = Commands.newProducerSuccessCommand(requestId, producerName, lastSequenceId, schemaVersion, topicEpoch, isProducerReady);
safeIntercept(command, cnx);
ByteBuf outBuf = Commands.serializeWithSize(command);
cnx.ctx().writeAndFlush(outBuf);
}
use of org.apache.pulsar.common.api.proto.BaseCommand in project pulsar by apache.
the class PulsarCommandSenderImpl method sendPartitionMetadataResponse.
@Override
public void sendPartitionMetadataResponse(ServerError error, String errorMsg, long requestId) {
BaseCommand command = Commands.newPartitionMetadataResponseCommand(error, errorMsg, requestId);
safeIntercept(command, cnx);
ByteBuf outBuf = Commands.serializeWithSize(command);
cnx.ctx().writeAndFlush(outBuf);
}
Aggregations