public interface CdcConsumer
CdcMain
application invocation.
The lifecycle of the consumer is the following:
start(MetricRegistry)
.onEvents(Iterator)
call.stop()
.IgniteLogger
, please, use, LoggerResource
annotation:
public class ChangeDataCaptureConsumer implements ChangeDataCaptureConsumer { @LoggerResource private IgniteLogger log; ... }Note, consumption of the
CdcEvent
will be started from the last saved offset.
The offset of consumptions is saved on the disk every time onEvents(Iterator)
returns true
.
Note, order of notifications are following:
Note, CdcConsumer
receive notifications on each running CDC application(node).CdcMain
,
CdcEvent
,
CacheEntryVersion
Modifier and Type | Method and Description |
---|---|
default boolean |
alive()
Checks that consumer still alive.
|
void |
onCacheChange(Iterator<CdcCacheEvent> cacheEvents)
Handles caches changes(create, edit) events.
|
void |
onCacheDestroy(Iterator<Integer> caches)
Handles cache destroy events.
|
boolean |
onEvents(Iterator<CdcEvent> events)
Handles entry changes events.
|
void |
onMappings(Iterator<TypeMapping> mappings)
Handles new mappings from type name to id.
|
void |
onTypes(Iterator<BinaryType> types)
Handles new binary types.
|
void |
start(org.apache.ignite.internal.processors.metric.MetricRegistry mreg)
Starts the consumer.
|
void |
stop()
Stops the consumer.
|
void start(org.apache.ignite.internal.processors.metric.MetricRegistry mreg)
mreg
- Metric registry for consumer specific metrics.boolean onEvents(Iterator<CdcEvent> events)
true
then current offset will be stored
and ongoing notifications after CDC application fail/restart will be started from it.events
- Entry change events.True
if current offset should be saved on the disk
to continue from it in case any failures or restart.void onTypes(Iterator<BinaryType> types)
onEvents(Iterator)
this method MUST process all types or CDC will fail.
Because, in time of invocation onEvents(Iterator)
all changed types must be available on destionation.types
- Binary types iterator.IgniteBinary
,
IgniteBinary.type(int)
,
IgniteBinary.type(Class)
,
IgniteBinary.type(String)
,
IgniteBinary.types()
void onMappings(Iterator<TypeMapping> mappings)
mappings
- Binary mapping iterator.IgniteBinary
,
IgniteBinary.typeId(String)
,
BinaryIdMapper
void onCacheChange(Iterator<CdcCacheEvent> cacheEvents)
cacheEvents
- Cache change events.Ignite.createCache(String)
,
Ignite.getOrCreateCache(String)
,
CdcCacheEvent
void onCacheDestroy(Iterator<Integer> caches)
caches
- Destroyed caches.Ignite.destroyCache(String)
,
CdcCacheEvent
,
CacheView.cacheId()
void stop()
start(MetricRegistry)
.default boolean alive()
CdcConsumer
errors in case CdcEvent
is rare or source cluster is down.True
in case consumer alive, false
otherwise.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023