rd_kafka_produce

@brief Produce and send a single message to broker.

\p rkt is the target topic which must have been previously created with rd_kafka_topic_new().

rd_kafka_produce() is an asynch non-blocking API.

\p partition is the target partition, either: - RD_KAFKA_PARTITION_UA (unassigned) for automatic partitioning using the topic's partitioner function, or - a fixed partition (0..N)

\p msgflags is zero or more of the following flags OR:ed together: RD_KAFKA_MSG_F_BLOCK - block \p produce*() call if \p queue.buffering.max.messages or \p queue.buffering.max.kbytes are exceeded. Messages are considered in-queue from the point they are accepted by produce() until their corresponding delivery report callback/event returns. It is thus a requirement to call rd_kafka_poll() (or equiv.) from a separate thread when F_BLOCK is used. See WARNING on \c RD_KAFKA_MSG_F_BLOCK above.

RD_KAFKA_MSG_F_FREE - rdkafka will free(3) \p payload when it is done with it. RD_KAFKA_MSG_F_COPY - the \p payload data will be copied and the \p payload pointer will not be used by rdkafka after the call returns.

.._F_FREE and .._F_COPY are mutually exclusive.

If the function returns -1 and RD_KAFKA_MSG_F_FREE was specified, then the memory associated with the payload is still the caller's responsibility.

\p payload is the message payload of size \p len bytes.

\p key is an optional message key of size \p keylen bytes, if non-NULL it will be passed to the topic partitioner as well as be sent with the message to the broker and passed on to the consumer.

\p msg_opaque is an optional application-provided per-message opaque pointer that will provided in the delivery report callback (dr_cb) for referencing this message.

Returns 0 on success or -1 on error in which case errno is set accordingly: - ENOBUFS - maximum number of outstanding messages has been reached: "queue.buffering.max.messages" (RD_KAFKA_RESP_ERR__QUEUE_FULL) - EMSGSIZE - message is larger than configured max size: "messages.max.bytes". (RD_KAFKA_RESP_ERR_MSG_SIZE_TOO_LARGE) - ESRCH - requested \p partition is unknown in the Kafka cluster. (RD_KAFKA_RESP_ERR__UNKNOWN_PARTITION) - ENOENT - topic is unknown in the Kafka cluster. (RD_KAFKA_RESP_ERR__UNKNOWN_TOPIC)

@sa Use rd_kafka_errno2err() to convert errno to rdkafka error code.

extern (C) nothrow @nogc
int
rd_kafka_produce
(,
int32_t partition
,,
void* payload
,
size_t len
,
const(void)* key
,
size_t keylen
,)

Meta