Class KNetShareConsumer<K, V, TJVMK, TJVMV>
KNet extension of KafkaConsumer<K, V>
public class KNetShareConsumer<K, V, TJVMK, TJVMV> : KafkaShareConsumer<TJVMK, TJVMV>, IDynamicMetaObjectProvider, IJVMBridgeCore, IEquatable<IJVMBridgeBaseInstance>, IDisposable, IJVMBridgeBaseStatic, IJVMBridgeBase, IJVMBridgeBaseInstance, IJVMBridgeDefinition, IShareConsumer<K, V, TJVMK, TJVMV>, IShareConsumer<TJVMK, TJVMV>, ICloseable, IAutoCloseable
Type Parameters
KThe key type
VThe value type
TJVMKThe JVM type of
KTJVMVThe JVM type of
V
- Inheritance
-
ShareConsumer<TJVMK, TJVMV>KafkaShareConsumer<TJVMK, TJVMV>KNetShareConsumer<K, V, TJVMK, TJVMV>
- Implements
-
IShareConsumer<K, V, TJVMK, TJVMV>IShareConsumer<TJVMK, TJVMV>
- Derived
- Inherited Members
Constructors
KNetShareConsumer(ConsumerConfigBuilder, ISerDes<K, TJVMK>, ISerDes<V, TJVMV>, bool)
Initialize a new instance of KNetShareConsumer<K, V, TJVMK, TJVMV>
public KNetShareConsumer(ConsumerConfigBuilder props, ISerDes<K, TJVMK> keyDeserializer, ISerDes<V, TJVMV> valueDeserializer, bool useJVMCallback = false)
Parameters
propsConsumerConfigBuilderThe properties to use, see ConsumerConfigBuilder
keyDeserializerISerDes<K, TJVMK>Key serializer base on SerDes<T, TJVMT>
valueDeserializerISerDes<V, TJVMV>Value serializer base on SerDes<T, TJVMT>
useJVMCallbackbooltrue to active callback based mode
KNetShareConsumer(ConsumerConfigBuilder, bool)
Initialize a new instance of KNetShareConsumer<K, V, TJVMK, TJVMV>
public KNetShareConsumer(ConsumerConfigBuilder configBuilder, bool useJVMCallback = false)
Parameters
configBuilderConsumerConfigBuilderAn instance of ConsumerConfigBuilder
useJVMCallbackbooltrue to active callback based mode
Properties
BridgeClassName
Java class name to be instantiated
public override string BridgeClassName { get; }
Property Value
IsCompleting
true if the IShareConsumer<K, V, TJVMK, TJVMV> instance is completing async operation
public bool IsCompleting { get; }
Property Value
IsEmpty
true if the IShareConsumer<K, V, TJVMK, TJVMV> instance has an empty set of items in async operation
public bool IsEmpty { get; }
Property Value
WaitingBatches
Number of message batches in the IConsumer<K, V, TJVMK, TJVMV> instance waiting to be processed in async operation
public int WaitingBatches { get; }
Property Value
WaitingMessages
Number of messages in the IConsumer<K, V, TJVMK, TJVMV> instance waiting to be processed in async operation
public int WaitingMessages { get; }
Property Value
Methods
Consume(long, Func<ConsumerRecord<K, V, TJVMK, TJVMV>, bool>)
KNet sync extension for Poll(Duration)
public void Consume(long timeoutMs, Func<ConsumerRecord<K, V, TJVMK, TJVMV>, bool> callback)
Parameters
timeoutMslongTimeout in milliseconds
callbackFunc<ConsumerRecord<K, V, TJVMK, TJVMV>, bool>The Func<T, TResult> where receives ConsumerRecord<K, V, TJVMK, TJVMV>; return true from
callbackto dispose the object
ConsumeAsync(long)
KNet async extension for Poll(Duration)
public bool ConsumeAsync(long timeoutMs)
Parameters
timeoutMslongTimeout in milliseconds
Returns
Dispose(bool)
Implements the pattern described in https://learn.microsoft.com/en-en/dotnet/standard/garbage-collection/implementing-dispose
protected override void Dispose(bool disposing)
Parameters
disposingboolThe disposing parameter is a bool that indicates whether the method call comes from a Dispose() method (its value is true) or from a finalizer (its value is false)
Poll(TimeSpan)
KNet extension for Poll(Duration)
public ConsumerRecords<K, V, TJVMK, TJVMV> Poll(TimeSpan timeout)
Parameters
Returns
- ConsumerRecords<K, V, TJVMK, TJVMV>
SetCallback(Func<ConsumerRecord<K, V, TJVMK, TJVMV>, bool>, Action<Exception>)
Sets the Func<T, TResult> to use to receive the ConsumerRecord<K, V, TJVMK, TJVMV>
public void SetCallback(Func<ConsumerRecord<K, V, TJVMK, TJVMV>, bool> cb, Action<Exception> exceptionCallback = null)
Parameters
cbFunc<ConsumerRecord<K, V, TJVMK, TJVMV>, bool>The callback Func<T, TResult>
exceptionCallbackAction<Exception>The callback receiving Exception thrown in async operations