/** * Executed from managed ledger thread when the message is persisted */ @Override public void completed(Exception exception, long ledgerId, long entryId) { if (exception != null) { ServerError serverError = (exception instanceof TopicTerminatedException) ? ServerError.TopicTerminatedError : ServerError.PersistenceError; producer.cnx.ctx().channel().eventLoop().execute(() -> { if (!(exception instanceof TopicClosedException)) { // For TopicClosed exception there's no need to send explicit error, since the client was // already notified producer.cnx.ctx().writeAndFlush(Commands.newSendError(producer.producerId, sequenceId, serverError, exception.getMessage())); } producer.cnx.completedSendOperation(producer.isNonPersistentTopic); producer.publishOperationCompleted(); recycle(); }); } else { if (log.isDebugEnabled()) { log.debug("[{}] [{}] [{}] triggered send callback. cnx {}, sequenceId {}", producer.topic, producer.producerName, producer.producerId, producer.cnx.clientAddress(), sequenceId); } this.ledgerId = ledgerId; this.entryId = entryId; producer.cnx.ctx().channel().eventLoop().execute(this); } }
public void publishMessage(long producerId, long sequenceId, ByteBuf headersAndPayload, long batchSize) { if (isClosed) { cnx.ctx().channel().eventLoop().execute(() -> { cnx.ctx().writeAndFlush(Commands.newSendError(producerId, sequenceId, ServerError.PersistenceError, "Producer is closed")); cnx.completedSendOperation(isNonPersistentTopic); cnx.ctx().channel().eventLoop().execute(() -> { cnx.ctx().writeAndFlush( Commands.newSendError(producerId, sequenceId, ServerError.ChecksumError, "Checksum failed on the broker")); cnx.completedSendOperation(isNonPersistentTopic); }); log.warn("[{}] Messages must be encrypted", getTopic().getName()); cnx.ctx().channel().eventLoop().execute(() -> { cnx.ctx().writeAndFlush(Commands.newSendError(producerId, sequenceId, ServerError.MetadataError, "Messages must be encrypted")); cnx.completedSendOperation(isNonPersistentTopic);