Class ConsumerInterceptor<K, V>
Listener for Kafka ConsumerRebalanceListener. Extends JVMBridgeListener, implements IConsumerInterceptor<K, V>
public class ConsumerInterceptor<K, V> : JVMBridgeListener, IDynamicMetaObjectProvider, IJVMBridgeCore, IEquatable<IJVMBridgeBaseInstance>, IDisposable, IJVMBridgeBaseStatic, IConsumerInterceptor<K, V>, IJVMBridgeBase, IJVMBridgeBaseInstance, IJVMBridgeDefinition, IConfigurable, IAutoCloseable
Type Parameters
KV
- Inheritance
-
ConsumerInterceptor<K, V>
- Implements
-
IConsumerInterceptor<K, V>
- Derived
Remarks
Dispose the object to avoid a resource leak, the object contains a reference to the corresponding JVM object
Constructors
ConsumerInterceptor(IJVMBridgeBaseInitializer)
Initializer used internally by JCOBridge. Do not use directly.
[Obsolete("This public initializer is needed for JCOBridge internal use, other uses can produce unidentifiable behaviors.")]
public ConsumerInterceptor(IJVMBridgeBaseInitializer initializer)
Parameters
initializerIJVMBridgeBaseInitializer
ConsumerInterceptor(params object[])
Generic constructor used by JCOBridge when a derived class needs to forward arguments to the base JVMBridgeBase class.
public ConsumerInterceptor(params object[] args)
Parameters
argsobject[]
Properties
BridgeClassName
Java class name to be instantiated
public override string BridgeClassName { get; }
Property Value
OnClose
public Action OnClose { get; set; }
Property Value
Remarks
Assign a delegate to handle the event without subclassing. If both this handler and a virtual method override are present, the delegate takes precedence. Set to null to delegate to the virtual method.
OnConfigure
public Action<Map<String, object>> OnConfigure { get; set; }
Property Value
Remarks
Assign a delegate to handle the event without subclassing. If both this handler and a virtual method override are present, the delegate takes precedence. Set to null to delegate to the virtual method.
OnOnCommit
public Action<Map<TopicPartition, OffsetAndMetadata>> OnOnCommit { get; set; }
Property Value
Remarks
Assign a delegate to handle the event without subclassing. If both this handler and a virtual method override are present, the delegate takes precedence. Set to null to delegate to the virtual method.
OnOnConsume
public Func<ConsumerRecords<K, V>, ConsumerRecords<K, V>> OnOnConsume { get; set; }
Property Value
- Func<ConsumerRecords<K, V>, ConsumerRecords<K, V>>
Remarks
Assign a delegate to handle the event without subclassing. If both this handler and a virtual method override are present, the delegate takes precedence. Set to null to delegate to the virtual method.
OnOnConsumeDispose
Optional handler invoked after the event handler returns, to dispose the JVM object returned by this event.
public Action<ConsumerRecords<K, V>> OnOnConsumeDispose { get; set; }
Property Value
- Action<ConsumerRecords<K, V>>
Remarks
Set OnOnConsumeDispose when the event handler returns a JVM-backed object that is no longer needed after the call. The handler receives the return value and is responsible for calling Dispose() on it, releasing the underlying JVM global reference immediately instead of waiting for the .NET garbage collector to finalize it. If not set, the return value is not disposed automatically.
Methods
Close()
public virtual void Close()
Configure(Map<String, object>)
public virtual void Configure(Map<String, object> arg0)
Parameters
Configure(Map<string, Object>)
Configure this class with the given key-value pairs
public virtual void Configure(Map<string, Object> configs)
Parameters
InitializeHandlers(Type)
Handlers initializer for ConsumerInterceptor
protected virtual void InitializeHandlers(Type listenerRuntimeType)
Parameters
listenerRuntimeTypeType
ListenerShallManageEvent(int)
Invoked from the JVMBridgeListener on each received event to notify the user which can decide to abort the execution for the specific event returning false
protected override bool ListenerShallManageEvent(int eventIndex)
Parameters
eventIndexintThe index of the event triggered as returned from AddEventHandler(string, EventHandler) or AddEventHandler<TDataClass>(string, EventHandler<CLRListenerEventArgs<TDataClass>>)
Returns
Remarks
By default every event continues the execution and reads the data from JVM; this implies an extra cost which can be limited using ListenerShallManageEvent(int) or the ListenerShallManageEventIndex/ListenerShallManageEventName handlers. Returning false the control is immediately returned to the JVM, anyway the user has received the notification. It can be useful in scenarios where the user is interested in few events and the other are simply discarded to optimize the execution speed. By default, this function invokes ListenerShallManageEventIndex, then try ListenerShallManageEventName if they are set or return true
ListenerShallManageEventHandlers(int)
protected virtual bool ListenerShallManageEventHandlers(int eventIndex)
Parameters
eventIndexint
Returns
OnCommit(Map<TopicPartition, OffsetAndMetadata>)
public virtual void OnCommit(Map<TopicPartition, OffsetAndMetadata> arg0)
Parameters
arg0Map<TopicPartition, OffsetAndMetadata>
OnConsume(ConsumerRecords<K, V>)
public virtual ConsumerRecords<K, V> OnConsume(ConsumerRecords<K, V> arg0)
Parameters
arg0ConsumerRecords<K, V>