{"record":{"id":"adee746a92807f7b","repo":"dotnetcore/CAP","slug":"kafka-message-persisted-failed","errorCode":null,"errorMessage":"kafka message persisted failed!","messagePattern":"kafka message persisted failed!","errorType":"exception","errorClass":"PublisherSentFailedException","httpStatus":null,"severity":"error","filePath":"src/DotNetCore.CAP.Kafka/ITransport.Kafka.cs","lineNumber":61,"sourceCode":"\n            var result = await producer.ProduceAsync(message.GetName(), new Message<string, byte[]>\n            {\n                Headers = headers,\n                Key = message.Headers.TryGetValue(KafkaHeaders.KafkaKey, out var kafkaMessageKey) &&\n                      !string.IsNullOrEmpty(kafkaMessageKey)\n                    ? kafkaMessageKey\n                    : message.GetId(),\n                Value = message.Body.ToArray()!\n            });\n\n            if (result.Status is PersistenceStatus.Persisted or PersistenceStatus.PossiblyPersisted)\n            {\n                _logger.LogDebug($\"kafka topic message [{message.GetName()}] has been published.\");\n\n                return OperateResult.Success;\n            }\n\n            throw new PublisherSentFailedException(\"kafka message persisted failed!\");\n        }\n        catch (Exception ex)\n        {\n            var warpEx = new PublisherSentFailedException(ex.Message, ex);\n\n            return OperateResult.Failed(warpEx);\n        }\n        finally\n        {\n            _connectionPool.Return(producer);\n        }\n    }\n}","sourceCodeStart":43,"sourceCodeEnd":74,"githubUrl":"https://github.com/dotnetcore/CAP/blob/e52b8508e54cdb7a9ce7f9fec03d9ea8ad2710fb/src/DotNetCore.CAP.Kafka/ITransport.Kafka.cs#L43-L74","documentation":"Operational (not framework) failure logged in Kafka transport SendAsync: ProduceAsync returned a PersistenceStatus other than Persisted/PossiblyPersisted (e.g. NotPersisted), so the producer could not confirm the broker accepted the message. Typically caused by broker unavailability, timeouts, message size limits, or ack/replication failures.","triggerScenarios":"Thrown at src/DotNetCore.CAP.Kafka/ITransport.Kafka.cs:61 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify Kafka broker reachability (bootstrap servers, network, TLS) and cluster health","Increase delivery timeout / retry settings (MessageTimeoutMs, MessageSendMaxRetries) on the producer","Check topic exists, is not throttled, and max.message.bytes is not exceeded","Inspect the logged result status and broker logs to distinguish definite loss from ambiguous delivery"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e52b8508e54cdb7a9ce7f9fec03d9ea8ad2710fb","analyzedAt":"2026-09-14T14:46:34.677Z","contentChangedAt":"2026-09-14T14:46:34.677Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}