//
// Summary:
// Asynchronously send a single message to the broker. Refer to Confluent.Kafka.Producer`2.ProduceAsync(System.String,`0,`1,System.Int32,System.Boolean)
// for more information.
//
// Remarks:
// The partition the message is produced to is determined using the configured partitioner.
// Blocks if the send queue is full. Warning: if background polling is disabled
// and Poll is not being called in another thread, this will block indefinitely.
public Task<Message<TKey, TValue>> ProduceAsync(string topic, TKey key, TValue val);
//
// Summary:
// Asynchronously send a single message to the broker.
//
// Parameters:
// topic:
// The target topic.
//
// partition:
// The target partition (if -1, this is determined by the partitioner configured
// for the topic).
//
// key:
// the message key (possibly null if allowed by the key serializer).
//
// val:
// the message value (possibly null if allowed by the value serializer).
//
// blockIfQueueFull:
// Whether or not to block if the send queue is full. If false, a KafkaExcepion
// (with Error.Code == ErrorCode.Local_QueueFull) will be thrown if an attempt is
// made to produce a message and the send queue is full. Warning: blockIfQueueFull
// is set to true, background polling is disabled and Poll is not being called in
// another thread, this will block indefinitely.
//
// Returns:
// A Task which will complete with the corresponding delivery report for this request.
//
// Remarks:
// If you require strict ordering of delivery reports to be maintained, you should
// use a variant of ProduceAsync that takes an IDeliveryHandler parameter, not a
// variant that returns a Task<Message> because Tasks are completed on arbitrary
// thread pool threads and can be executed out of order.
public Task<Message<TKey, TValue>> ProduceAsync(string topic, TKey key, TValue val, int partition, bool blockIfQueueFull);
//
// Summary:
// Asynchronously send a single message to the broker. Refer to Confluent.Kafka.Producer`2.ProduceAsync(System.String,`0,`1,System.Int32,System.Boolean)
// for more information.
//
// Remarks:
// Blocks if the send queue is full. Warning: if background polling is disabled
// and Poll is not being called in another thread, this will block indefinitely.
public Task<Message<TKey, TValue>> ProduceAsync(string topic, TKey key, TValue val, int partition);
//
// Summary:
// Asynchronously send a single message to the broker. Refer to Confluent.Kafka.Producer`2.ProduceAsync(System.String,`0,`1,System.Int32,System.Boolean)
// for more information.
//
// Remarks:
// The partition the message is produced to is determined using the configured partitioner.
public Task<Message<TKey, TValue>> ProduceAsync(string topic, TKey key, TValue val, bool blockIfQueueFull);
文档未声明 ProduceAsync
线程安全或不安全。
它是线程安全的吗?
1条答案
按热度按时间rks48beu1#
是的,是的
客户机上的所有操作都是线程安全的(api中记录了一些小的异常)。
好吧,在c#客户机中还没有这样的方法(或者只有私有/内部方法)
https://github.com/confluentinc/confluent-kafka-dotnet/wiki/client-creationhttps://github.com/edenhill/librdkafka/wiki/faq#库线程安全吗